10

I'm Neovim user

and I use Plugin neoclide/coc.vim for autocompletion

but when my cursor focus out, I can not get suggestion box again
(How can I call this box? suggest box or hint box? I want to know this box name)

I want to trigger it and see again, Is there any command or variable for this?

enter image description here

devstefancho
  • 2,072
  • 4
  • 17
  • 34

4 Answers4

15

Yes, the answer is on the front page of CoC's github project. You need to map something to coc#refresh(). For instance, to use Ctrl + Space to trigger completion, you need to put the following in your vimrc:

inoremap <silent><expr> <c-space> coc#refresh()

There are more examples on the project's page.

doopNudles
  • 635
  • 4
  • 9
  • I think this answer is for autocomplete, my question is about suggestion box in above picture, – devstefancho Sep 02 '20 at 10:43
  • 2
    Perhaps you are referring to show documentation? From coc README: "Use K to show documentation in preview window." `nnoremap K :call show_documentation()` – Puhlze Feb 16 '21 at 18:15
7

TLDR: try this Ctrl+@

I found this in README of neoclide/coc.nvim:

" Use <c-space> to trigger completion.
if has('nvim')
  inoremap <silent><expr> <c-space> coc#refresh()
else
  inoremap <silent><expr> <c-@> coc#refresh()
endif

The weirdness here is that, Ctrl+Space is not working, despite using neovim NOT vim.

But there is a good trick to get your desired key binding as it appears from your terminal emulator point of view:

  1. Enter insert mode
  2. Press Ctrl+v
  3. Then press your keys you want to bind, Ctrl+Space

Ops! nothing is inserted in my case. It seems that my terminal doesn't recognize using Ctrl and Space or understands this keybinding differently and intercepts it. So this is the real problem!

Things I tried to solve the problem:

  1. I changed the default coc config a little bit:
    inoremap <silent><expr> <c-space> coc#refresh()
    inoremap <silent><expr> <c-@> coc#refresh()
    
  2. I tried bash as I was using zsh as a shell, but the problem is still there.
  3. Then I tried another terminal emulator and the problem is solved, alhamdulillah.
Mohammed Samir
  • 376
  • 3
  • 9
3

I've commented in https://github.com/neoclide/coc.nvim/issues/2299#issuecomment-686293001

The suggestion box in your image is signatureHelp. If you want to reopen it, you need to trigger triggerCharacters in your function, usually is ( and ,. The triggerCharacters is defined by LS.

fannheyward
  • 18,599
  • 12
  • 71
  • 109
3

To Browse from suggestion box:

- <Tab > 

- <Ctrl - x> <Ctrl -f>

- <Ctrl - p ><Ctrl -n>

- <Ctrl - n ><Ctrl -n>

To Confirm selection

- <Ctrl - y>   
islamux
  • 97
  • 5