10

I have recently shifted from youCompleteMe to ConquerOfCompletions and I have an issue in the auto-complete. when I was using YCM, to go through the auto-complete options tab used to work. But now in COC, I am using tsserver from the javascript completions I am not able to use tab. I know arrow keys are working but they are slowing my productivity. Please provide a solution for me to solve this issue where I can easily access the auto-complete options.

Thank You

2 Answers 2

12

From the COC documentation, you need to edit your .vimrc https://github.com/neoclide/coc.nvim/wiki/Completion-with-sources:

Use or custom key for trigger completion

You can make use of coc#refresh() for trigger completion like this:

" use <tab> for trigger completion and navigate to the next complete item
function! s:check_back_space() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~ '\s'
endfunction

inoremap <silent><expr> <Tab>
      \ pumvisible() ? "\<C-n>" :
      \ <SID>check_back_space() ? "\<Tab>" :
      \ coc#refresh()

Note: the could be remapped by another plugin, use :verbose imap to check if it's mapped as expected.

" use <c-space>for trigger completion
inoremap <silent><expr> <c-space> coc#refresh()

Some terminals may send when you press , so you could instead:

" use <c-space>for trigger completion
inoremap <silent><expr> <NUL> coc#refresh()

Improve the completion experience

Use <Tab> and <S-Tab> to navigate the completion list:

inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
2
  • I actually have just got the answer from the coc-snippets README file. Anyway thank you so much for answering Commented Aug 13, 2020 at 9:33
  • Thanks, this is very easy to use. Would be great if the completion also places down the rest of the snippet as well such as opening and closing curly brackets after a function or a resource call etc. But that has to do with coc config. Commented Jul 7, 2021 at 13:03
0

Mine wasn't working because of the space between "\ pumvisible", "\ <sid" and "\ coc.." in the snippet below.

inoremap <silent><expr> <Tab>
      \ pumvisible() ? "\<C-n>" :
      \ <SID>check_back_space() ? "\<Tab>" :
      \ coc#refresh()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.