diff --git a/init.vim b/init.vim index 2d3d705..e10264e 100644 --- a/init.vim +++ b/init.vim @@ -358,13 +358,23 @@ set shortmess+=c " always show signcolumns set signcolumn=yes -" Use tab for trigger completion with characters ahead and navigate. -" Use command ':verbose imap ' to make sure tab is not mapped by other plugin. +" {{{ coc completion +"Use and to navigate completion list: + +function! CheckBackSpace() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~ '\s' +endfunction +inoremap coc#pum#visible() ? coc#_select_confirm() + \: "\u\\=coc#on_enter()\" + +" Insert when previous text is space, refresh completion if not. inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() -inoremap pumvisible() ? "\" : "\" + \ coc#pum#visible() ? coc#pum#next(1): + \ CheckBackSpace() ? "\" : + \ coc#refresh() +inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" +"}}} function! s:check_back_space() abort let col = col('.') - 1 @@ -374,10 +384,6 @@ endfunction " Use to trigger completion. inoremap coc#refresh() -" Use to confirm completion, `u` means break undo chain at current position. -" Coc only does snippet and additional edit on confirm. -inoremap pumvisible() ? "\" : "\u\" - " Use `[c` and `]c` to navigate diagnostics nmap [c (coc-diagnostic-prev) nmap ]c (coc-diagnostic-next)