aboutsummaryrefslogtreecommitdiff
path: root/vim/keymaps.vim
diff options
context:
space:
mode:
authorOxbian <got.dacs@slmail.me>2023-12-02 22:03:41 +0100
committerOxbian <got.dacs@slmail.me>2023-12-02 22:03:41 +0100
commit6c5f19bf6524fc38c4288858f9f03c0fbc325556 (patch)
treeff16fe3d4429b0309756eab4f38e4908d04204c0 /vim/keymaps.vim
parent900c5ae36832b3426596b59cb89b6e5c1f87e38b (diff)
downloadvimrc-6c5f19bf6524fc38c4288858f9f03c0fbc325556.tar.gz
vimrc-6c5f19bf6524fc38c4288858f9f03c0fbc325556.zip
ADD: CoC Lsp, and update README
Diffstat (limited to 'vim/keymaps.vim')
-rw-r--r--vim/keymaps.vim74
1 files changed, 43 insertions, 31 deletions
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 <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
+" Treat long paragraph as a line
+map j gj
+map k gk
""""""""""""""""""""
" Window movement
@@ -146,34 +149,43 @@ noremap <leader>s? z=
"""""""""""""""""""
" LSP
"""""""""""""""""""
-
-inoremap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
-inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
-
-" Go to definition
-nnoremap <leader>ld :LspDefinition<cr>
-
-" Go next diagnostic
-nnoremap <leader>lnd :LspNextDiagnostic<cr>
-
-" Go previous diagnostic
-nnoremap <leader>lpd :LspPreviousDiagnostic<cr>
-
-" Go to reference
-nnoremap <leader>lf :LspReferences<cr>
-
-" Rename object
-nnoremap <leader>lr :LspRename<cr>
-
-" LSP stop server
-nnoremap <leader>ls :LspStopServer<cr>
-
-" peek definition of object
-nnoremap <leader>lp :LspPeekDefinition<cr>
-
-" Code Action
-nnoremap <leader>la :LspCodeAction<cr>
-
-" Hover information
-nnoremap <leader>lh :LspHover<cr>
-
+inoremap <silent><expr> <TAB>
+ \ coc#pum#visible() ? coc#pum#next(1) :
+ \ CheckBackspace() ? "\<Tab>" :
+ \ coc#refresh()
+inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
+
+" Make <CR> to accept selected completion item or notify coc.nvim to format
+" <C-g>u breaks current undo, please make your own choice
+inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
+ \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
+
+nmap <silent> gp <Plug>(coc-diagnostic-prev)
+nmap <silent> gn <Plug>(coc-diagnostic-next)
+
+" GoTo code navigation
+nmap <silent> gd <Plug>(coc-definition)
+nmap <silent> gy <Plug>(coc-type-definition)
+nmap <silent> gi <Plug>(coc-implementation)
+nmap <silent> gr <Plug>(coc-references)
+
+" Use K to show documentation in preview window
+nnoremap <silent> gh :call ShowDocumentation()<CR>
+
+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 <leader>gR <Plug>(coc-rename)
+
+" Formatting selected code
+xmap <leader>gf <Plug>(coc-format-selected)
+nmap <leader>gf <Plug>(coc-format-selected)
ArKa projects. All rights to me, and your next child right arm.