Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim Autocomplete Hints for Go

Tags:

vim

go

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.

like image 651
if __name__ is None Avatar asked Nov 23 '13 16:11

if __name__ is None


People also ask

Does vim support autocomplete?

Vim text editor supports autocompletion for the standard text files by default. Also, when configured properly, Vim enables an autocomplete feature for files with code in the languages it recognizes.

How do I get code suggestions in Vim?

and press *Ctrl + x* followed by *Ctrl + o* to see the auto-complete suggestions as below. This is how you can enable and use the auto-complete feature of Vim editor to write Javascript programs. Each time you open the Vim editor, it takes some effort to enable the auto-complete functionality.


1 Answers

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'.

like image 181
John Eikenberry Avatar answered Sep 29 '22 14:09

John Eikenberry