From 6c5f19bf6524fc38c4288858f9f03c0fbc325556 Mon Sep 17 00:00:00 2001 From: Oxbian Date: Sat, 2 Dec 2023 22:03:41 +0100 Subject: ADD: CoC Lsp, and update README --- vim/keymaps.vim | 74 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 31 deletions(-) (limited to 'vim/keymaps.vim') diff --git a/vim/keymaps.vim b/vim/keymaps.vim index 9570949..e568816 100644 --- a/vim/keymaps.vim +++ b/vim/keymaps.vim @@ -7,6 +7,9 @@ let g:maplocalleader = ',' nnoremap :WhichKey '' nnoremap :WhichKey ',' +" Treat long paragraph as a line +map j gj +map k gk """""""""""""""""""" " Window movement @@ -146,34 +149,43 @@ noremap s? z= """"""""""""""""""" " LSP """"""""""""""""""" - -inoremap pumvisible() ? "\" : "\" -inoremap pumvisible() ? "\" : "\" - -" Go to definition -nnoremap ld :LspDefinition - -" Go next diagnostic -nnoremap lnd :LspNextDiagnostic - -" Go previous diagnostic -nnoremap lpd :LspPreviousDiagnostic - -" Go to reference -nnoremap lf :LspReferences - -" Rename object -nnoremap lr :LspRename - -" LSP stop server -nnoremap ls :LspStopServer - -" peek definition of object -nnoremap lp :LspPeekDefinition - -" Code Action -nnoremap la :LspCodeAction - -" Hover information -nnoremap lh :LspHover - +inoremap + \ coc#pum#visible() ? coc#pum#next(1) : + \ CheckBackspace() ? "\" : + \ coc#refresh() +inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" + +" Make to accept selected completion item or notify coc.nvim to format +" u breaks current undo, please make your own choice +inoremap coc#pum#visible() ? coc#pum#confirm() + \: "\u\\=coc#on_enter()\" + +nmap gp (coc-diagnostic-prev) +nmap gn (coc-diagnostic-next) + +" GoTo code navigation +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" Use K to show documentation in preview window +nnoremap gh :call ShowDocumentation() + +function! ShowDocumentation() + if CocAction('hasProvider', 'hover') + call CocActionAsync('doHover') + else + call feedkeys('K', 'in') + endif +endfunction + +" Highlight the symbol and its references when holding the cursor +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming +nmap gR (coc-rename) + +" Formatting selected code +xmap gf (coc-format-selected) +nmap gf (coc-format-selected) -- cgit v1.2.3