Vim自动完成Go的提示

huangapple go评论153阅读模式
英文:

Vim Autocomplete Hints for Go

问题

我在使用https://github.com/nsf/gocode和https://github.com/Shougo/neocomplete.vim来进行Go自动补全。

它的效果非常好,只有一个小问题。当我输入类似于fmt.pri的内容时,自动补全选项如下所示:

fmt.Println(a ...interface{}) (n int, err error)

对于我这个刚接触Go的人来说,这非常有帮助,因为现在我知道了这个方法需要哪些参数,参数的类型是什么,以及返回值是什么。
不幸的是,一旦我写完括号,这些信息就消失了。
fmt.Println(

所以对于我第一次使用的更复杂的方法,我陷入了困境,不得不跳转到源代码定义或运行godoc。

最好能够在Vim底部的命令/状态行附近的某个地方提供这些信息,这样会更方便。

有人知道如何实现这样的功能吗?

预览窗口会导致我的Vim崩溃,所以不是一个选项。

英文:

I use https://github.com/nsf/gocode in conjunction with https://github.com/Shougo/neocomplete.vim for my Go autocompletion.

It works really well, except for one little thing. When I type something like
fmt.pri
I get autocomplete option like so:

fmt.Println(a ...interface{}) (n int, err error)

Since I'm new to Go, this is super helpful, because now I know what arguments the method takes, what are the types, and also what does it return.
Unfortunately, as soon as I write past bracket, the information is gone.
fmt.Println(

So on more complex methods that I'm using for first time, I'm stuck, and have to jump to source definition, or run godoc.

It would be much easier to have that information available somewhere, preferably on the bottom of Vim where the command/status line is.

Does anyone know how such a thing could be achieved?

Preview window breaks my Vim so it's not an option.

答案1

得分: 1

我使用 autocomplpop(嗯,我的分支)它有一个功能,它会在一个小的分割窗口中显示完成的文本,并保持显示。当你设置...

let g:acp_completeoptPreview = 1

我相信neocomplcache也有类似的功能。浏览一下它的文档,它在几个地方讨论了预览窗口。在它的文档中搜索"preview",看看你能找到什么。

这个功能最终由包含"preview"的'completeopt'控制(:h completeopt)。自动完成的插件通常会设置这些值作为它们的功能的一部分,这就是为什么使用autocomplpop时,你需要使用它的选项来控制它,而不仅仅是执行'completeopt+=preview'。

英文:

I use autocomplpop (well, my fork of it) and it has a feature where it does a small split window with the completion text in it that sticks around. It does this when you set...

let g:acp_completeoptPreview = 1

I'm sure neocomplcache has a similar feature. Glancing through its documentation it discusses a preview window in several places. Search for preview in its docs and see what you can find.

This is ultimately controlled by 'completeopt' containing 'preview' (:h completeopt). The auto-completing packages often set these values as part of their functionality, which is why with autocomplpop you need to use its option to control it instead of just doing 'completeopt+=preview'.

huangapple
  • 本文由 发表于 2013年11月24日 00:05:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/20164541.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定