英文:
vim-go: Can't get autocompletion
问题
我正在尝试使用vim-go,但是无法使自动补全功能正常工作。
我的Go环境运行良好,我成功运行了:GoInstallBinaries命令,并且可以使用任何:GoXXX命令而没有错误。但是我无法使自动补全功能正常工作。
- 当我在一个点号后按下
<Ctrl-o>时,vim只是在状态栏中在-- INSERTION --和-- (insertion) --模式之间切换,并将我的光标向左移动一个字符。 - 当我按下
<Ctrl-x>时,状态栏中只显示-- mode ^X (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)。
有时(很少)在连续按下<Ctrl-o>后,它会显示vim-go的自动补全提示...
vim-go是唯一安装的插件,使用pathogen。
英文:
I'm trying to use vim-go, but I can't get autocompletion to work.
My go environment works well, I succesfully ran :GoInstallBinaries, and I can use any :GoXXX command without errors. But I can't get autocompletion to work.
- When I hit
<Ctrl-o>after a dot, vim just switches in the status bar between-- INSERTION --and-- (insertion) --modes (what's the difference btw ?) and moves my cursor one character to the left. - When I hit
<Ctrl-x>, It just shows-- mode ^X (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)in the status bar.
Sometimes (rarely) after spamming <Ctrl-o> it shows the vim-go autocompletion tooltip ...
vim-go is the only plugin installed, using pathogen.
答案1
得分: 6
Omni completion(Go 插件提供的)是通过 <C-x><C-o> 触发的,即按下 Ctrl + X,然后按下 Ctrl-O。你描述的提示符(-- mode ^X (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y))暗示了这一点。
如果这对你来说太麻烦,你可以定义一个 插入模式映射 来简化操作;下面是一个(全局)示例,可以放在你的 ~/.vimrc 文件中:
:inoremap <C-b> <C-x><C-o>
如果你使用 GVIM,你还可以使用类似 IDE 的 <C-Space>,而不是示例中的 <C-g> 触发键。
英文:
Omni completion (which the Go plugin offers) is triggered via <C-x><C-o>, that is Ctrl + X followed by Ctrl-O. The prompt (-- mode ^X (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)) you've described hints at that.
If that is too cumbersome for you, you can define an insert mode mapping to shorten that; here's a (global) example to be put into your ~/.vimrc:
:inoremap <C-b> <C-x><C-o>
If you use GVIM, you can also use the IDE-like <C-Space> instead of the example <C-g> trigger.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论