How to trigger autocomplete suggestion box in vim or neovim (Plugin neoclide/coc.vim)

ste*_*cho 4 vim autocomplete vim-plugin

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?

在此处输入图片说明

Moh*_*mir 7

TLDR:试试这个Ctrl+@

我在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
Run Code Online (Sandbox Code Playgroud)

这里奇怪的是,尽管使用neovim NOT vim,但不起作用。Ctrl+Space

但是有一个很好的技巧可以让您获得所需的键绑定,就像从终端仿真器的角度来看的那样:

  1. 进入insert模式
  2. Ctrl+v
  3. 然后按下你想要绑定的按键,Ctrl+Space

行动!我的案例中没有插入任何内容。看来我的终端无法识别使用 Ctrl 和 Space,或者以不同的方式理解此键绑定并拦截它。所以这才是真正的问题!

我尝试解决问题的事情:

  1. 我稍微改变了默认的 coc 配置:
    inoremap <silent><expr> <c-space> coc#refresh()
    inoremap <silent><expr> <c-@> coc#refresh()
    
    Run Code Online (Sandbox Code Playgroud)
  2. 我尝试了bash,因为我使用zsh作为 shell,但问题仍然存在。
  3. 然后我尝试了另一个终端模拟器,问题解决了,alhamdulillah。


小智 6

是的,答案在 CoC 的github 项目首页。您需要将某些内容映射到 coc#refresh()。例如,要使用Ctrl+Space触发完成,您需要在 vimrc 中放入以下内容:

inoremap <silent><expr> <c-space> coc#refresh()
Run Code Online (Sandbox Code Playgroud)

项目页面上有更多示例。

  • 也许您指的是显示文档?来自 coc 自述文件:“使用 K 在预览窗口中显示文档。” `nnoremap &lt;silent&gt; K :call &lt;SID&gt;show_documentation()&lt;CR&gt;` (2认同)

fan*_*ard 3

我在https://github.com/neoclide/coc.nvim/issues/2299#issuecomment-686293001发表评论

图像中的建议框是signatureHelp。如果你想重新打开它,你需要triggerCharacters在你的函数中触发,通常是(,。触发器字符由 LS 定义。