How to select neoclide/coc.nvim language server autocomplete suggestions in vim

204 Views Asked by At

enter image description here

I am using neoclide/coc.nvim plugin in vim on OSX

How do I select one of these suggestions, what is the command or shortcut to navigate and select them? I do not seem to have the ability to move around with vim standard navigation over the suggestion list window.

1

There are 1 best solutions below

0
fannheyward On

<C-n> and <C-p> to select, also you can map <tab> to do selection, <CR> to confirm the suggestion.

function! CheckBackspace() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

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>"

inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
                              \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"

Check :h coc-completion-default for the default mappings, and :h coc-completion-example for more.