diff --git a/root/.config/nvim/lua/lsp/init.lua b/root/.config/nvim/lua/lsp/init.lua index a530fda..41051bf 100644 --- a/root/.config/nvim/lua/lsp/init.lua +++ b/root/.config/nvim/lua/lsp/init.lua @@ -225,10 +225,16 @@ function M.lspconfig() attach_codelens(client, bufnr) end, M.get_capabilities()) - vim.keymap.del("n", "]d") - vim.keymap.del("n", "[d") - vim.keymap.del("n", "]D") - vim.keymap.del("n", "[D") + -- remove default nvim lsp keymap + if vim.version.ge(vim.version(), { 0, 10, 0 }) then + vim.keymap.del("n", "]d") + vim.keymap.del("n", "[d") + vim.keymap.del("n", "]D") + vim.keymap.del("n", "[D") + vim.keymap.del({"x", "n"}, "gra") + vim.keymap.del("n", "grn") + vim.keymap.del("n", "grr") + end -- Use LspAttach autocommand to only map the following keys -- after the language server attaches to the current buffer vim.api.nvim_create_autocmd("LspAttach", { @@ -241,22 +247,21 @@ function M.lspconfig() -- Mappings. -- See `:help vim.lsp.*` for documentation on any of the below functions local bufopts = { noremap = true, silent = true, buffer = ev.buf } - vim.keymap.set("n", "grD", vim.lsp.buf.declaration, bufopts) - vim.keymap.set("n", "grd", vim.lsp.buf.definition, bufopts) - -- vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) - vim.keymap.set("n", "gri", vim.lsp.buf.implementation, bufopts) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) + 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", "sh", 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", "grt", vim.lsp.buf.type_definition, bufopts) - if vim.version.ge({ 0, 10, 0 }, vim.version()) then - vim.keymap.set("n", "grn", vim.lsp.buf.rename, bufopts) - vim.keymap.set({ "n", "x" }, "gra", vim.lsp.buf.code_action, bufopts) - vim.keymap.set("n", "grr", vim.lsp.buf.references, bufopts) - end + vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, bufopts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts) + -- range_code_action and range_formatting are deprecated + vim.keymap.set({ "n", "x" }, "ac", vim.lsp.buf.code_action, bufopts) vim.keymap.set({ "n", "x" }, "fmt", function() vim.lsp.buf.format({ async = true }) end, bufopts) diff --git a/root/.vim/vimrc.d/coc.vim b/root/.vim/vimrc.d/coc.vim index 24fffd9..5046c3b 100644 --- a/root/.vim/vimrc.d/coc.vim +++ b/root/.vim/vimrc.d/coc.vim @@ -11,8 +11,6 @@ autocmd FileType python ++once call coc#config('python.formatting.provider', g:p function! s:show_documentation() if CocAction('hasProvider', 'hover') call CocActionAsync('doHover') - else - call feedkeys('K', 'in') endif endfunction @@ -44,23 +42,23 @@ nmap [de (coc-diagnostic-prev-error) nmap ]de (coc-diagnostic-next-error) " GoTo code navigation. -nmap grd (coc-definition) -nmap grt (coc-type-definition) -nmap gri (coc-implementation) +nmap gd (coc-definition) +nmap gt (coc-type-definition) +nmap gi (coc-implementation) " See Also: :HelpRg mapping in root/.vim/vimrc.d/fzf.vim -nmap grr (coc-references) +nmap gr (coc-references) " Use K to show documentation in preview window. nnoremap K :call show_documentation() " Applying code actions to the selected code block " Example: `aap` for current paragraph -xmap gra (coc-codeaction-selected) +xmap ac (coc-codeaction-selected) " Remap keys for applying code actions at the cursor position -nmap gra (coc-codeaction-cursor) +nmap ac (coc-codeaction-cursor) " Remap keys for apply code actions affect whole buffer -nmap grs (coc-codeaction-source) +nmap as (coc-codeaction-source) " Apply the most preferred quickfix action to fix diagnostic on the current line nmap qf (coc-fix-current) @@ -72,7 +70,7 @@ nmap re (coc-codeaction-refactor-selected) " Run the Code Lens action on the current line nmap cl (coc-codelens-action) -nmap grn (coc-rename) +nmap rn (coc-rename) nmap fmt (coc-format) xmap fmt (coc-format-selected)