summaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/confs/coc.vim
diff options
context:
space:
mode:
Diffstat (limited to 'neovim/.config/nvim/confs/coc.vim')
-rw-r--r--neovim/.config/nvim/confs/coc.vim37
1 files changed, 37 insertions, 0 deletions
diff --git a/neovim/.config/nvim/confs/coc.vim b/neovim/.config/nvim/confs/coc.vim
new file mode 100644
index 0000000..033d490
--- /dev/null
+++ b/neovim/.config/nvim/confs/coc.vim
@@ -0,0 +1,37 @@
+" Use tab for trigger completion with characters ahead and navigate.
+" NOTE: There's always complete item selected by default, you may want to enable
+" no select by `"suggest.noselect": true` in your configuration file.
+" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
+" other plugin before putting this into your config.
+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>"
+
+function! CheckBackspace() abort
+ let col = col('.') - 1
+ return !col || getline('.')[col - 1] =~# '\s'
+endfunction
+
+" Use K to show documentation in preview window.
+nnoremap <silent> H :call ShowDocumentation()<CR>
+
+function! ShowDocumentation()
+ if CocAction('hasProvider', 'hover')
+ call CocActionAsync('doHover')
+ else
+ call feedkeys('H', 'in')
+ endif
+endfunction
+
+" Highlight the symbol and its references when holding the cursor.
+autocmd CursorHold * silent call CocActionAsync('highlight')
+
+" Symbol renaming.
+nmap <leader>rn <Plug>(coc-rename)