Vim-go: E718: Funcref required

Created on 18 Apr 2019  ·  19Comments  ·  Source: fatih/vim-go

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

Open nvim with any golang file.

What did you expect to happen?

No vim error messages popping up.

What happened instead?

The following error message greets me when opening golang files:

Errorr detected while processing function <SNR>36_register[5]..go#lsp#DidOpen
line   13:
E718: Funcref required

Configuration (MUST fill this out):

  • vim-go version: 9a4f21e5343437bdb4619f19b48cbf6d5cb7755c

  • vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):

if &compatible
  set nocompatible
endif

set runtimepath+=~/.local/share/dein.nvim/repos/github.com/Shougo/dein.vim

if dein#load_state('~/.local/share/dein.nvim')
  call dein#begin('~/.local/share/dein.nvim')
  call dein#add('~/.local/share/dein.nvim/repos/github.com/Shougo/dein.vim')
  call dein#add('fatih/vim-go')
  call dein#end()
  call dein#save_state()
endif
  • Vim version (first three lines from :version):
NVIM v0.3.4
Build type: Release
LuaJIT 2.0.5

(Archlinux from community repo.)

  • Go version (go version):

go version go1.12.4 linux/amd64

  • Go environment (go env):
GOARCH="amd64"
GOBIN="/home/user/work/golang/bin"
GOCACHE="/dev/shm/user/cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/work/golang"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build172276371=/tmp/go-build -gno-record-gcc-switches"

No idea how to provide better/useful information or how to try to fix this.

Most helpful comment

Issue was fixed for me be just running :GoUpdateBinaries. Did not need to clean plugin cache

All 19 comments

I have an extremely similar environment to yourself and have also started seeing this error when opening or saving any Go file:

Error detected while processing function <SNR>19_register[5]..go#lsp#DidOpen:                                                                                                                                                                                                                                                                                  
line   13:
E718: Funcref required

Details:

$ go version
go version go1.12.4 linux/amd64

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dan/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dan/dev/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build817225651=/tmp/go-build -gno-record-gcc-switches"

$ nvim --version
NVIM v0.3.4
Build type: Release
LuaJIT 2.0.5

Stripped everything out of my vimrc so it only contains the following:

call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go'
call plug#end()

What is the output of :verbose function go#lsp#DidOpen?

   function go#lsp#DidOpen(fname) abort                                                                      
        Last set from ~/.local/share/dein.nvim/.cache/init.vim/.dein/autoload/go/lsp.vim
1    if get(b:, 'go_lsp_did_open', 0)
2      return
3    endif
4
5    if !filereadable(a:fname)
6      return
7    endif
8
9    let l:lsp = s:lspfactory.get()
10   let l:msg = go#lsp#message#DidOpen(fnamemodify(a:fname, ':p'), join(go#util#GetLines(), "\n") . "\n")
11   let l:state = s:newHandlerState('')
12   let l:state.handleResult = funcref('s:noop')
13   call l:lsp.sendMessage(l:msg, l:state)
14
15   let b:go_lsp_did_open = 1
   endfunction

Reverted 0c7aff2 in ~/.local/share/dein.nvim/repos/github.com/fatih/vim-go. Error messages persist. Not sure if there are issues with caching from dein, or something.

@transferkraM thanks for the info about go#lsp#DidOpen. As you can see, line 13 of that function doesn't use a function reference, nor does what it's calling, lsp.sendMessage. Perhaps you have an older version cached somehow. Can you search your system for l:lsp.sendMessage?

Can you duplicate this without dein?

@bhcleek l:lsp.sendMessage is found in ~/.local/share/dein.nvim/repos/github.com/fatih/vim-go/autoload/go/lsp.vim only:

149:  function! l:lsp.sendMessage(data, handler) dict abort
335:  call l:lsp.sendMessage(l:msg, l:state)
357:  call l:lsp.sendMessage(l:msg, l:state)
380:  call l:lsp.sendMessage(l:msg, l:state)
403:  call l:lsp.sendMessage(l:msg, l:state)
419:  call l:lsp.sendMessage(l:msg, l:state)
432:  call l:lsp.sendMessage(l:msg, l:state)
466:  call l:lsp.sendMessage(l:msg, l:state)
493:  call l:lsp.sendMessage(l:msg, l:state)
515:  call l:lsp.sendMessage(l:msg, l:state)

For reference lsp.vim has shasum: 7e45a7eafa8a394ea22295700af8884aedeec85c0cebe540190d2be171d7ccd7

Before I'd like to test all of this without dein I'd like to reference @syscll comment as it seems he isn't using dein but plugged.

@syscll's comment isn't helpful. I'm aware of when the change was introduced to use go#lsp#DidOpen more frequently, but that doesn't explain why it's failing on your system on latest master.

On my system, autoload/go/lsp.vim has the same shasum :

❯❯❯ shasum -a 256 autoload/go/lsp.vim
7e45a7eafa8a394ea22295700af8884aedeec85c0cebe540190d2be171d7ccd7  autoload/go/lsp.vim

edit: spelling

Ah! dein caching. Reverted 0c7aff2, call dein#recache_runtimepath() and the error messages disappear.

you shouldn't need to revert that commit; it's going to be essential for gopls to work as expected.

When you use the latest master and run call dein#recache_runtimepath(), do you still have a problem?

@bhcleek Thanks a lot for digging into this with me. master is fine after updating dein caches. (Learned a lot the last two hours!) Everything feels usable and correct now.

@bhcleek sorry for the lack of input on my end. I also fixed the issue by cleaning plug cache and running :GoUpdateBinaries.

Issue was fixed for me be just running :GoUpdateBinaries. Did not need to clean plugin cache

I use vim-plug and am seeing this. :GoUpdateBinaries did not resolve it.

Nevermind. I seem to have hit https://github.com/fatih/vim-go/issues/2233

I also ran into this. To keep you binaries in-sync the docs now recommended this for vim-plug users:

Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }`

Somehow exactly this message was triggered in my case by disabled tpop/vim-fugitive plugin, which has been used in statusline. Enabling it back, solved the issue, as well as removing call to fugitive#statusline() in vimrc.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhangjing picture zhangjing  ·  3Comments

Michael-F-Ellis picture Michael-F-Ellis  ·  3Comments

groob picture groob  ·  3Comments

derekchiang picture derekchiang  ·  3Comments

danielmanesku picture danielmanesku  ·  4Comments