From 2f6c617a6213ebb7150aacc72b523653edbb1f39 Mon Sep 17 00:00:00 2001 From: Marcel Schneider Date: Wed, 21 Sep 2022 13:03:27 +0200 Subject: [PATCH] Update for new coc.nvim --- init.vim | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) 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)