Merge branch 'main' of github.com:jim-fx/.dotfiles

This commit is contained in:
2021-11-22 18:45:53 +01:00
24 changed files with 679 additions and 185 deletions

View File

@ -1,49 +1,11 @@
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Import additional configuration files
#
# Imports are loaded in order, skipping all missing files, with the importing
# file being loaded last. If a field is already present in a previous import, it
# will be replaced.
#
# All imports must either be absolute paths starting with `/`, or paths relative
# to the user's home directory starting with `~/`.
#import:
# - /path/to/alacritty.yml
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
#env:
# TERM variable
#
# This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will
# check the local terminfo database and use `alacritty` if it is
# available, otherwise `xterm-256color` is used.
#TERM: alacritty
# Window dimensions (changes require restart)
#
# Number of lines/columns (not pixels) in the terminal. The number of columns
# must be at least `2`, while using a value of `0` for columns and lines will
# fall back to the window manager's recommended size.
#dimensions:
# columns: 0
# lines: 0
# Window position (changes require restart)
#
# Specified in number of pixels.
# If the position is not set, the window manager will handle the placement.
#position:
# x: 0
# y: 0
# Window padding (changes require restart)
#
# Blank space added around the window in pixels. This padding is scaled
# by DPI and the specified value is always added at both opposing sides.
window:
padding:
x: 10
@ -175,7 +137,6 @@ font:
# Colors (Tomorrow Night)
colors:
# Default colors
primary:
background: '#000000'
foreground: '#c5c8c6'

View File

@ -27,20 +27,10 @@ if u.has_plugin("cmp") then
set tabstop=2
]]
-- Debug indentations
if false then
vim.cmd [[
set list
set listchars=eol:⏎,tab:->,trail:_,nbsp:⎵
]]
end
g.hidden = true --unload buffers when hidden
g.filetype = true -- execute autocommands based on filetype
o.autoread = true
o.lazyredraw = true
-- Search
o.inccommand = 'nosplit' -- show substitutions incrementally
o.ignorecase = true
@ -69,7 +59,7 @@ if u.has_plugin("cmp") then
cmd [[command Format :lua vim.lsp.buf.formatting()]]
cmd [[command FormatSync :lua vim.lsp.buf.formatting_sync()]]
cmd [[set noshowmode]] --to get rid of thing like --INSERT--
cmd [[set noshowcmd]] --to get rid of display of last command
cmd [[set shortmess+=F]] --to get rid of the file name displayed in the command line bar
@ -81,9 +71,11 @@ if u.has_plugin("cmp") then
-- Enable Theming / Syntax
o.syntax = "enable"
o.termguicolors = true
cmd("colorscheme material")
cmd("colorscheme tokyonight")
g.material_terminal_italics = 1
g.material_theme_style = "darker"
g.tokyonight_style = "night"
g.tokyonight_transparent_sidebar = true;
-- Remove background color
require("transparent").setup({enable = true})
@ -151,7 +143,6 @@ if u.has_plugin("cmp") then
g.wiki_link_extension = ".md"
-- KeyBindings
g.mapleader = " "
require "keymappings"
require "nvim-tmux-navigation".setup {
@ -171,9 +162,8 @@ if u.has_plugin("cmp") then
require "treesitter-conf"
-- Autocompletion Setup
o.completeopt = "menuone,noselect,noinsert"
require "autocomplete"
require "snippets"
require "cmp-conf"
-- LSP Config
require "lspinstaller-conf"
@ -198,13 +188,9 @@ if u.has_plugin("cmp") then
}
)
-- Autocompletion Setup
o.completeopt = "menuone,noselect,noinsert"
require "autocomplete"
-- LSP Config
require "lspinstaller-conf"
require "lsp-utils"
require "lsp-conf"
else
vim.cmd[[PackerSync]]

View File

@ -1,11 +1,6 @@
local cmd = vim.cmd;
cmd [[
augroup auto_format
au!
au BufWritePre * silent! lua vim.lsp.buf.formatting_sync(nil, 300)<CR>
augroup END
augroup highlight_yank
au!
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 150 }

View File

@ -1,51 +0,0 @@
-- luasnip setup
local luasnip = require "luasnip"
local cmp = require "cmp"
cmp.setup {
completion = {
completeopt = "menu,menuone,noselect"
},
preselect = "none",
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end
},
mapping = {
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true
},
["<Tab>"] = function(fallback)
if vim.fn.pumvisible() == 1 then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-n>", true, true, true), "n")
elseif luasnip.expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
else
fallback()
end
end,
["<S-Tab>"] = function(fallback)
if vim.fn.pumvisible() == 1 then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-p>", true, true, true), "n")
elseif luasnip.jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
else
fallback()
end
end
},
sources = {
{name = "nvim_lsp"},
{name = "luasnip"},
{name = "path"}
}
}
-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)

View File

@ -0,0 +1,92 @@
-- luasnip setup
local luasnip = require "luasnip"
local lspkind = require "lspkind"
local cmp = require "cmp"
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
cmp.setup {
formatting = {
format = lspkind.cmp_format({with_text = true, menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
nvim_lua = "[Lua]",
latex_symbols = "[Latex]",
})}),
},
completion = {
completeopt = "menu,menuone",
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end
},
mapping = {
['<C-Leader>'] = cmp.mapping.complete(),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
},
sources = {
{name = "nvim_lsp"},
{name = "luasnip"},
{name = "path"},
{name = "buffer"},
{name = "calc"}
}
}
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
require'lspconfig'.html.setup {
capabilities = capabilities
}
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))

View File

@ -0,0 +1,8 @@
local cmd = vim.cmd;
cmd [[
augroup auto_format
au!
au BufWritePre * FormatSync
augroup END
]]

View File

@ -5,15 +5,11 @@ local cmd = vim.cmd;
local options = {noremap = true}
local remap = {noremap = false}
--map("n", "<Space>", "<Nop>", remap)
--map("n", " ", "<Nop>", remap)
g.mapleader = " "
map("n", "<C-p>", ":Telescope find_files<CR>", options)
--map("n", "<C-f>", ":Telescope grep_string<CR>", options)
map("n", "<C-f>", ":Telescope live_grep<CR>", options)
-- LSP Functionality
map("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", options)
map("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", options)
@ -23,9 +19,10 @@ map("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", options)
map("n", "<Leader>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", options)
map("n", "<Leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", options)
map("n", "<Leader>c", "<cmd>lua vim.lsp.buf.code_action()<CR>", options)
map("n", "<Leader><C-f>", "<cmd>lua vim.lsp.buf.formatting()<CR>", options)
map("n", "<Leader><C-f>", ":Format<CR>", options)
map("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", options)
map("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", options)
map("n", "<leader>t", ":TroubleToggle<CR>", remap)
-- Navigate Buffers
map("n", "<C-h>", "<C-w>h", options)
@ -37,8 +34,10 @@ map("n", "Y", "yy", options)
map("n", "<Leader>k", "{",options)
map("n", "<Leader>j", "}",options)
map("n", "<Leader><C-j>", "<cmd>move +1<CR>", options)
map("n", "<Leader><C-k>", "<cmd>move -2<CR>", options)
map("n", "<A-j>", "<cmd>move +1<CR>", options)
map("n", "<A-k>", "<cmd>move -2<CR>", options)
map("i", "<A-j>", "<cmd>move +1<CR>", options)
map("i", "<A-k>", "<cmd>move -2<CR>", options)
-- Faster git merge
map("n", "<Leader>gd", ":Gvdiffsplit!<CR>", options)
@ -69,6 +68,3 @@ map("i", "<C-s>", "<Esc>:w<CR>i", options)
-- Update vim config
map("n", "<C-u>", "<Esc>:source $MYVIMRC<CR>", options)
-- Y yank until the end of line
map("n", "Y", "y$", {noremap = true})

View File

@ -1,42 +1,9 @@
local nvim_lsp = require "lspconfig"
local lsp = require "lspconfig"
local lsp_status = require("lsp-status")
local utils = require("utils")
-- function to attach completion when setting up lsp
local function on_attach(client)
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings.
local opts = {noremap = true, silent = true}
-- Set some keybinds conditional on server capabilities
if client.resolved_capabilities.document_formatting then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
elseif client.resolved_capabilities.document_range_formatting then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
end
-- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec(
[[
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
autocmd CursorHold *.* :lua vim.lsp.diagnostic.show_line_diagnostics()
augroup END
]],
false
)
end
local function on_attach()
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
end
local system_name = ""
@ -58,7 +25,7 @@ local runtime_path = vim.split(package.path, ";")
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
nvim_lsp.sumneko_lua.setup {
lsp.sumneko_lua.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities,
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
@ -72,7 +39,7 @@ nvim_lsp.sumneko_lua.setup {
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {"vim"}
globals = {"vim", "bufnr", "use"}
},
workspace = {
-- Make the server aware of Neovim runtime files
@ -88,37 +55,36 @@ nvim_lsp.sumneko_lua.setup {
-- Go Language Server
nvim_lsp.gopls.setup {
lsp.gopls.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities
}
-- Html Setup
nvim_lsp.html.setup {
lsp.html.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities,
filetypes = {"html"}
}
-- Svelte Language Server
nvim_lsp.svelte.setup {
lsp.svelte.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities
}
-- Typescript Language Server
local function organize_imports()
local params = {
command = "_typescript.organizeImports",
arguments = {vim.api.nvim_buf_get_name(0)},
title = ""
}
vim.lsp.buf.execute_command(params)
local params = {
command = "_typescript.organizeImports",
arguments = {vim.api.nvim_buf_get_name(bufnr)},
title = ""
}
vim.lsp.buf_request_sync(bufnr, "workspace/executeCommand", params, 500)
end
nvim_lsp.tsserver.setup {
lsp.tsserver.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities,
commands = {
@ -129,17 +95,20 @@ nvim_lsp.tsserver.setup {
}
}
-- JSON ls setup
lsp.jsonls.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities
}
-- Setup diagnostics formaters and linters for non LSP provided files
nvim_lsp.diagnosticls.setup {
lsp.diagnosticls.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities,
cmd = {"diagnostic-languageserver", "--stdio"},
filetypes = {
"lua",
"sh",
"markdown",
"json",
"jsonc",
"yaml",
"toml"
},

View File

@ -50,7 +50,7 @@ local nvimConfig =
{
cmd = "cd $HOME/.dotfiles && nvim configs/init.lua && cd -",
direction = "float",
on_close = function(term)
on_close = function()
Terminal:close()
u.ReloadConfig()
end

View File

@ -12,7 +12,7 @@ return require("packer").startup(function()
use "alexghergh/nvim-tmux-navigation"
-- Theming Section
use "kaicataldo/material.vim"
use 'folke/tokyonight.nvim'
use "xiyaowong/nvim-transparent"
-- Layout Plugins
@ -39,22 +39,39 @@ return require("packer").startup(function()
-- Obsidian / Roam like features
-- use "lervag/wiki.vim"
-- Lsp Errors
use "folke/lsp-colors.nvim"
use "onsails/lspkind-nvim"
use {
"folke/trouble.nvim",
requires = "kyazdani42/nvim-web-devicons",
config = function()
require("trouble").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
end
}
-- Syntax / Autocomplete
use "neovim/nvim-lspconfig"
use "hrsh7th/nvim-cmp"
use "hrsh7th/cmp-nvim-lsp"
use "hrsh7th/cmp-path"
use "hrsh7th/cmp-calc"
use "hrsh7th/cmp-buffer"
use "hrsh7th/cmp-cmdline"
use "L3MON4D3/LuaSnip"
use "saadparwaiz1/cmp_luasnip"
use "rafamadriz/friendly-snippets"
use "beyondmarc/glsl.vim"
use "tpope/vim-commentary"
use "williamboman/nvim-lsp-installer"
use "nvim-lua/lsp-status.nvim"
use "L3MON4D3/LuaSnip"
use "windwp/nvim-autopairs"
use "neoclide/jsonc.vim"
use {
@ -64,8 +81,8 @@ return require("packer").startup(function()
-- Preview Markdown
use "ellisonleao/glow.nvim"
-- Autoformat
-- Autoformat
--use "sbdchd/neoformat"
-- use "lukas-reineke/format.nvim"

View File

@ -1,4 +1,5 @@
local parser_configs = require("nvim-treesitter.parsers").get_parser_configs()
parser_configs.http = {
install_info = {
url = "https://github.com/NTBBloodbath/tree-sitter-http",
@ -6,7 +7,16 @@ local parser_configs = require("nvim-treesitter.parsers").get_parser_configs()
branch = "main"
}
}
parser_configs.glsl = {
filetype = "vert",
filetypes = {"vert","frag"}
}
require "nvim-treesitter.configs".setup {
indent = {
enable = true
},
ensure_installed = {
"bash",
"yaml",

View File

@ -27,6 +27,7 @@ alias D="pnpm dev"
alias B="pnpm build"
alias T="pnpm test"
alias P="git push"
alias p="git pull"
alias lt="tree -L 2 --filelimit 150 --dirsfirst"