Skip to content

Gocode Golang Completion

Iury O. G. Figueiredo edited this page Jul 3, 2020 · 3 revisions

Golang autocompletion plugin using gocode engine.

gohints-screenshot-0

Install

The gohints plugin uses the package:

https://github.com/nsf/gocode

However nsf is not being maintained anymore. It is advisable to use:

https://github.com/mdempsky/gocode

You need to install the gocode package.

Then open your ~/.vy/vyrc file and place the code below in the extra plugins section.

from vyapp.plugins.gohints import GolangCompletion
GolangCompletion.PATH ='/path/to/gocode'
autocall(GolangCompletion)

The attribute PATH is the gocode executable. Supposing your go projects stay in ~/.go/ then the gocode would stay in ~/.go/bin/.

After that just open some go file and press:

<Control-Key-period>

In INSERT mode for getting hints, The event above happens when you keep control key held and press the period key.

Note: In case gohints doesn't work then run the daemon in debug mode. It will display info about gohints requests.

gocode -s -debug

It may issue something like:

[tau@archlinux ~]$ gocode -s -debug
2020/07/03 19:09:54 listen unix /tmp/gocode-daemon.tau: bind: address already in use

In that case you can remove the gocode-daemon file.

Clone this wiki locally