deoplete-plugins/deoplete-go

Autocompletion does not show for imported packages

lcmen opened this issue · 5 comments

lcmen commented

Hi!
I have a problem with deoplate-go (latest version) on nvim 0.2.1-dev. OmniCompletion via <C-X><C-O> works fine it does not show completion using deoplate for imported packages.

Example:

package sample

import (
	"fmt"
)

func main() {
	fmt.Pr
}

It should show available functions but it doesn't.

I have a few plugins for go:

 Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }

 Plug 'fatih/vim-go', { 'for': 'go' }
 Plug 'zchee/deoplete-go', { 'do': 'make' }
lcmen commented
    let g:deoplete#enable_at_startup = 1
    let g:deoplete#sources#go#gocode_binary = $GOPATH.'/bin/gocode'
    let g:deoplete#sources#go#sort_class = ['package', 'func', 'type', 'var', 'const']
    let g:deoplete#sources = {}
    let g:deoplete#sources.go = ['buffer', 'go']

I tried to comment those lines one by one but it didn't help.

It looks like deoplate does not picks up all completions. For my code I see completions correctly but not for imported packages.

lcmen commented

If I run nvim -u path/to/tests/deoplate-go.vim path/to/tests/fmt.go this is what I see when I put a cursor after fmt.:

screen shot 2017-08-19 at 19 55 52

Also omnicompletion with <C-X><C-O>does not work either.

lcmen commented

I've found root of the problem. My GOROOT was not set correctly (I'm using [asdf-golang](https://github.com/kennyp/asdf-golang for managing go versions). asdf-golang has problem with dynamically setting the GOROOT variable.

When GOROOT is not set gocode excpets root to be in /usr/local/go but it should be ~/.asdf/installs/golang/your.go.version/go. It's a little bit strange because go env GOLANG returns correct version.

@zchee can we rely on go env GOLANG when we pass GOROOT variable to gocode daemon?

Hm. I don't understand.
When GOROOT is updated?

No response