Vim-go: Setup vim-go + deoplete

Created on 18 Oct 2020  路  23Comments  路  Source: fatih/vim-go

What did you do? (required: The issue will be closed when not provided)

I just started use vim and therefore wanted to setup vim-go together with deoplete. I started with a bare minimal init.vim shown below. Sadly I can鈥榯 get deoplete to work with vim-go, although deoplete works for me with other plugins (e.g. I tested omnisharp-vim).

I thought this should be an issue with deoplete first, but because other plugins work well with it, I suspect this to be somehow related to vim-go.

I hope my setup isn鈥檛 wrong, but I am also pretty new to all of that. So I am really sorry in advance if my configuration is messed up.

Thanks for all your help!

What did you expect to happen?

A popup with all the auto complete options from omnifunc after writing fmt.P in the following go program:

package main

import "fmt"

func main() {
        fmt.P
}

What happened instead?

No popup is shown at all. If I trigger omnifunc manually all auto complete options correctly show up. But without triggering it manually (CTRL+X + CTRL+O) I can鈥榯 get it to show up.

Configuration (MUST fill this out):

vim-go version: Current master

vimrc you used to reproduce:



vimrc

call plug#begin()

Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }

call plug#end()

let g:deoplete#enable_at_startup = 1
call deoplete#custom#option('omni_patterns', { 'go': '[^. *t]\.w*' })

Vim version (first three lines from :version):


NVIM v0.4.4
Build type: Release
LuaJIT 2.0.5

Go version (go version):


go version go1.15.3 linux/amd64

Go environment

go env Output:


GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/blub/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build737496797=/tmp/go-build -gno-record-gcc-switches"

gopls version

gopls version Output:


golang.org/x/tools/gopls v0.5.1
golang.org/x/tools/[email protected] h1:AF3Uh7HF08SZpKFfgJO6zfF3bbxyDXWqdkK4kMXiQ1o=

vim-go configuration:

vim-go configuration

g:go_jump_to_error = 1
g:go_loaded_gosnippets = 1
g:go_loaded_install = 1

filetype detection configuration:

filetype detection

filetype detection:ON plugin:ON indent:ON

Most helpful comment

I have fixed the problem. Please update deoplete to the latest.

All 23 comments

I am not a deoplete user, but it looks like your pattern is currently

call deoplete#custom#option('omni_patterns', { 'go': '[^. \t].\w' })

but according to a comment on #2185 and the vim-go help it should be

call deoplete#custom#option('omni_patterns', {'go': '[^. *\t]\.\w*'})

Thanks for your quick response!

Sadly this is just a visualization bug within GitHub. My init.vim contains the correct line. Even when I edit my original post the correct line is shown there, but somehow some characters like "*" are removed when rendered.

Edit: Seems like my init.vim was rendered as markdown. Because the configuration line contained 2x"*" it was rendered as italic. Should be fixed now.

I seem to be having the same problem as you are. Was it due to a recent update?

Is it because you're using . instead of \.? 馃

https://github.com/Shougo/deoplete.nvim/issues/965#issuecomment-482925193

@bhcleek This is another bug of this vimrc rendering here in Github. I am sorry. But in reality and even in the editor view of my original post the "" before "." is there.

I just noticed something else:
When I delete many characters in one line of text, the autocomplete flashes up for a moment. But it closes itself directly after that. So maybe it's just that the popup is closing itself right away?

Note: I double checked the rendering of my init.vim in the original post. Now it should really look like the one on my PC. Sorry, I just copied the contents of my init.vim into the template and didn't validate that it is rendered correctly.

@roberthmiller I just started to use vim-go so my setup is quite new. So I can't tell if it's because of some recent changes/updates or my configuration just being bad.

From that minimal vim setup, it should be working. Does work?

Just did a quick test in nvim and it should work as expected for you there. It's just the omnifunc that is not working as expected.

works for me. It just doesn't work in combination with deoplete.

Same issue here. Not working anymore after updating my plugins. is still working though.
I've tried to add call deoplete#custom#option('omni_patterns', { 'go': '[^. *\t]\.\w*' }) to my .vimrc but it doesn't work either.

Was the vimrc that you posted the minimal necessary to replicate the issue or did either not determine the minimal necessary or perhaps elide a lot that you thought wasn't necessary?

Since C-x,C-o works, we know that the omnifunc is working correctly.

I'd look into my completeopt setting if I were you.

It's the minimal necessary .vimrc/init.vim to replicate this issue for me. Everyting else was removed. I even setup a VM to check if it works in a complete clean environment.

FWIW I use daily nvim builds and daily vim builds. I have the latest vim-go (a5e253) and the latest deoplete (8987c9) and everything works fine with regards to autocompletion for both vim and nvim.

I reverted to just the default 'completeopt' (menu,preview) and the vimrc posted in the OP I achieved very poor autocompletion. There was some, but it was all in-file completion. So I also sourced my deoplete config along with the basic config in OP and autocompletion worked as expected. So I commented out sections of my deoplete config until it failed again. The only time it failed was when I commented this out:

call deoplete#custom#option({
            \ 'sources': { 
            \       '_': ['file'],
            \       'vim': ['vim'],
            \       },
            \ 'omni_patterns': { 'go': '[^. *\t]\.\w*' }
            \ })

I don't see any particularly interesting difference tbh, but if I remove the 'sources' section autocompletion only does in-file completion.

FTR, in the case where I was just sourcing a very basic vimrc these were the 'complete' and 'completeopt' settings (should be the defaults)

complete: .,w,b,u,t
completeopt: menu,preview

some more experimenting shows me that the '_' entry in 'sources' is the one that seems to 'fix' things. Without that entry I get only in-file autocompletion. Not certain why this would be but seems like a deoplete issue if there is any issue at all.

Not certain why this would be but seems like a deoplete issue if there is any issue at all.

This is most certainly not a vim-go issue. The fact that C-x,C-o works for everyone is evidence of that; vim-go only sets up the omnifunc. If C-x,C-o works, then the problem does not lie with vim-go.

I believe the problem started at deoplete commit a072a. Prior to that commit the 'basic' vimrc in OP works. After that it fails.
I've stared at the code for that commit for awhile and have no idea why it would cause this problem.

This will be my last post on this topic in this bug tracker barring other evidence. There is a workaround if you don't want to bother reporting a bug in the deoplete bug tracker.

@WhoIsSethDaniel, @bhcleek Thank you so much for looking into this. You are right! After adding the sources section to my deoplete configuration everything worked fine!

I assumed it to be a vim-go issue after trying other language-plugins with deoplete (like omnisharp-vim) which worked without issues and without any further configuration. Sorry that this was wrong.

I will open an issue in the deoplete repository later today and see how that goes. Do you think it's worth documenting somewhere in vim-go that this configuration of deoplete is necessary right now?

Yep, the sources thing worked for me as well. Thanks for the help!

@bhcleek Should this be added the the documentation? It currently just shows that the omni_pattern is a required option.

Let's not update documentation just yet. If there's a deoplete bug, then presumably they'll fix whatever is wrong and the vim-go documentation is right.

I have fixed the problem. Please update deoplete to the latest.

I can confirm that it's working with the latest deoplete and without further configuration. Thank you all!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielmanesku picture danielmanesku  路  4Comments

jongillham picture jongillham  路  3Comments

surest picture surest  路  3Comments

wpaulino picture wpaulino  路  4Comments

Michael-F-Ellis picture Michael-F-Ellis  路  3Comments