diff options
Diffstat (limited to 'nvim')
-rw-r--r-- | nvim/.config/nvim/lua/lsp_config.lua | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/nvim/.config/nvim/lua/lsp_config.lua b/nvim/.config/nvim/lua/lsp_config.lua index 66ced3d..63a51d8 100644 --- a/nvim/.config/nvim/lua/lsp_config.lua +++ b/nvim/.config/nvim/lua/lsp_config.lua @@ -13,32 +13,43 @@ local buf_map = function(bufnr, mode, lhs, rhs, opts) }) end -map('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>') -map('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>') -map('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>') -map('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>') - -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) + vim.cmd("command! LspDef lua vim.lsp.buf.definition()") + vim.cmd("command! LspDeclaration lua vim.lsp.buf.declaration()") + vim.cmd("command! LspFormatting lua vim.lsp.buf.formatting()") + vim.cmd("command! LspCodeAction lua vim.lsp.buf.code_action()") + vim.cmd("command! LspHover lua vim.lsp.buf.hover()") + vim.cmd("command! LspRename lua vim.lsp.buf.rename()") + vim.cmd("command! LspRefs lua vim.lsp.buf.references()") + vim.cmd("command! LspTypeDef lua vim.lsp.buf.type_definition()") + vim.cmd("command! LspImplementation lua vim.lsp.buf.implementation()") + vim.cmd("command! LspDiagPrev lua vim.diagnostic.goto_prev()") + vim.cmd("command! LspDiagNext lua vim.diagnostic.goto_next()") + vim.cmd("command! LspDiagLine lua vim.diagnostic.open_float()") + vim.cmd("command! LspSignatureHelp lua vim.lsp.buf.signature_help()") + -- Enable completion triggered by <c-x><c-o> 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 - buf_map(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>') - buf_map(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>') - buf_map(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>') - buf_map(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>') - buf_map(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>') - buf_map(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>') - buf_map(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>') - buf_map(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>') - buf_map(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>') - buf_map(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>') - buf_map(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>') - buf_map(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>') - buf_map(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>') + buf_map(bufnr, 'n', 'gD', ':LspDeclaration<cr>') + buf_map(bufnr, 'n', 'gd', ':LspDef<cr>') + buf_map(bufnr, 'n', 'gy', ':LspTypeDef<cr>') + buf_map(bufnr, 'n', 'gi', ':LspImplementation<cr>') + buf_map(bufnr, 'n', 'gr', ':LspRefs<cr>') + buf_map(bufnr, 'n', 'K', ':LspHover<cr>') + buf_map(bufnr, 'n', '[d', ':LspDiagPrev<cr>') + buf_map(bufnr, 'n', ']d', ':LspDiagNext<cr>') + buf_map(bufnr, 'n', '<leader>d', ':LspDiagLine<cr>') + buf_map(bufnr, 'n', '<C-k>', ':LspSignatureHelp<cr>') + buf_map(bufnr, 'n', '<space>wa', ':lua vim.lsp.buf.add_workspace_folder()<cr>') + buf_map(bufnr, 'n', '<space>wr', ':lua vim.lsp.buf.remove_workspace_folder()<cr>') + buf_map(bufnr, 'n', '<space>wl', ':lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>') + buf_map(bufnr, 'n', '<space>rn', ':LspRename<cr>') + buf_map(bufnr, 'n', '<space>ca', ':LspCodeAction<cr>') + buf_map(bufnr, 'n', '<space>f', ':LspFormatting<cr>') end -- Use a loop to conveniently call 'setup' on multiple servers and |