From e6abbca8efbbdee467d3780f3dc9f03c15b8eaec Mon Sep 17 00:00:00 2001 From: Kevin Cotugno Date: Fri, 7 Jan 2022 06:16:37 -0700 Subject: [PATCH] Add lsp keymaps --- .config/nvim/init.vim | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index b8961e0..9809c69 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -265,6 +265,34 @@ let g:tagbar_type_go = { \ } lua <lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) + buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) + buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) +end + vim.o.completeopt = "menuone,noselect" require'compe'.setup { enabled = true; @@ -290,10 +318,15 @@ require'compe'.setup { luasnip = true; }; }; -require'lspconfig'.gopls.setup{} +require'lspconfig'.gopls.setup{ + on_attach = on_attach +} require'lspconfig'.solargraph.setup{ + on_attach = on_attach; bundlerPath = 'bin/bundle'; useBundler = true; } -require'lspconfig'.rust_analyzer.setup{} +require'lspconfig'.rust_analyzer.setup{ + on_attach = on_attach +} EOF