diff --git a/.config/nvim/ftplugin/dockerfile.lua b/.config/nvim/ftplugin/dockerfile.lua deleted file mode 100644 index 435b148..0000000 --- a/.config/nvim/ftplugin/dockerfile.lua +++ /dev/null @@ -1,8 +0,0 @@ --- packages -require'lspconfig'.dockerls.setup { - on_attach = require'lspbinds', -} - --- variables - --- keybindings diff --git a/.config/nvim/ftplugin/python.lua b/.config/nvim/ftplugin/python.lua index 90e69fb..997a2c6 100644 --- a/.config/nvim/ftplugin/python.lua +++ b/.config/nvim/ftplugin/python.lua @@ -1,7 +1,4 @@ -- packages -require'lspconfig'.pyright.setup { - on_attach = require'lspbinds', -} -- variables vim.cmd("let g:black_linelength=79") diff --git a/.config/nvim/ftplugin/sh.lua b/.config/nvim/ftplugin/sh.lua deleted file mode 100644 index 966fa33..0000000 --- a/.config/nvim/ftplugin/sh.lua +++ /dev/null @@ -1,8 +0,0 @@ --- packages -require'lspconfig'.bashls.setup{ - on_attach = require'lspbinds', -} - --- variables - --- keybindings diff --git a/.config/nvim/ftplugin/yaml.lua b/.config/nvim/ftplugin/yaml.lua index 1bfc25b..27064ad 100644 --- a/.config/nvim/ftplugin/yaml.lua +++ b/.config/nvim/ftplugin/yaml.lua @@ -1,7 +1,4 @@ -- packages -require'lspconfig'.yamlls.setup { - on_attach = require'lspbinds', -} -- variables vim.o.shiftwidth = 2 diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 0520644..528abd3 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,6 +1,6 @@ -- packages vim.cmd("packadd nvim-treesitter") -require'nvim-treesitter.configs'.setup { +require"nvim-treesitter.configs".setup { auto_install = true, highlight = {enable = true}, } @@ -8,12 +8,13 @@ require'nvim-treesitter.configs'.setup { vim.cmd("packadd black") vim.cmd("packadd indent-blankline") -require'indent_blankline'.setup { +require"indent_blankline".setup { show_current_context = true, show_current_context_start = true, } vim.cmd("packadd nvim-lspconfig") +require"pack_lspconfig" vim.cmd("packadd vim-dirdiff") diff --git a/.config/nvim/lua/lspbinds.lua b/.config/nvim/lua/lspbinds.lua deleted file mode 100644 index 4b64ad4..0000000 --- a/.config/nvim/lua/lspbinds.lua +++ /dev/null @@ -1,30 +0,0 @@ --- Mappings. --- See `:help vim.diagnostic.*` for documentation on any of the below functions -local opts = { noremap=true, silent=true } -vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) - -return function(client, bufnr) - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local bufopts = { noremap=true, silent=true, buffer=bufnr } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set('n', 'wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, bufopts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) -end diff --git a/.config/nvim/lua/pack_lspconfig.lua b/.config/nvim/lua/pack_lspconfig.lua new file mode 100644 index 0000000..6a5a9eb --- /dev/null +++ b/.config/nvim/lua/pack_lspconfig.lua @@ -0,0 +1,41 @@ +lspconfig = require"lspconfig" + +-- Mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +local opts = { noremap=true, silent=true } +vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) + +local servers = { + "bashls", + "dockerls", + "pyright", + "yamlls", +} + +for _, server in ipairs(servers) do + lspconfig[server].setup{on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap=true, silent=true, buffer=bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + end} +end