Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoInfo not reporting type information #1927

Closed
pennz opened this issue Aug 26, 2018 · 13 comments
Closed

GoInfo not reporting type information #1927

pennz opened this issue Aug 26, 2018 · 13 comments

Comments

@pennz
Copy link

pennz commented Aug 26, 2018

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

Install neo-vim and updated vim-go to the newest commit 0aa956f.

What did you expect to happen?

GoInfo can work fine.

What happened instead?

GoInfo cannot work. And it reports the following message when I tried to run GoInfo

Error detected while processing function <SNR>16_auto_type_info:
line    3:
E119: Not enough arguments for function: go#tool#Info

After reset vim-go to 3d8f9d2, it works fine. I did not do the bisec, 3d8f9d2 is just a commit works fine for me.

Configuration (MUST fill this out):

  • vim-go version:
    0aa956f

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

set nocompatible			
call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go', { 'tag': '*' }
Plug 'AndrewRadev/splitjoin.vim'
Plug 'SirVer/ultisnips'
call plug#end()

set nocompatible
filetype off

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-go'
call vundle#end()
filetype plugin indent on

let mapleader = ","

map <C-n> :cnext<CR>
map <C-m> :cprevious<CR>


let g:go_fmt_command = "goimports"
let g:go_autodetect_gopath = 1
let g:go_list_type = "quickfix"

let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_generate_tags = 1

let g:go_metalinter_autosave = 1
let g:go_metalinter_autosave_enabled = ['vet', 'golint']
let g:go_metalinter_deadline = "5s"

let g:go_auto_type_info = 1
let g:go_auto_sameids = 1

let g:go_decls_includes = "func,type"
nmap <C-g> :GoDecls<cr>
nmap <C-G> :GoDeclsDir<cr>
imap <C-g> <esc>:<C-u>GoDeclsDir<cr>

augroup go
  autocmd!

  autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4

  autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR>

  autocmd FileType go nmap <leader>t  <Plug>(go-test)

  autocmd FileType go nmap <leader>r  <Plug>(go-run)

  autocmd FileType go nmap <Leader>d <Plug>(go-doc)

  autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle)

  autocmd FileType go nmap <Leader>i <Plug>(go-info)

  autocmd FileType go nmap <Leader>l <Plug>(go-metalinter)

  autocmd FileType go nmap <Leader>v <Plug>(go-def-vertical)
  autocmd FileType go nmap <Leader>s <Plug>(go-def-split)

  autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit')
  autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
  autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split')
  autocmd Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe')
augroup END

function! s:build_go_files()
  let l:file = expand('%')
  if l:file =~# '^\f\+_test\.go$'
    call go#test#Test(0, 1)
  elseif l:file =~# '^\f\+\.go$'
    call go#cmd#Build(0)
  endif
endfunction
  • Vim version (first three lines from :version):
    NVIM v0.3.1
    Build type: Release
    LuaJIT 2.0.5

  • Go version (go version):
    go version go1.10.1 darwin/amd64

  • Go environment (go env):

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/vincent/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/vincent/works/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/kl/jmjcrkxs61df9pgkps1h607m0000gn/T/go-build911026632=/tmp/go-build -gno-record-gcc-switches -fno-common"
@bhcleek bhcleek added the bug label Aug 26, 2018
@bhcleek
Copy link
Collaborator

bhcleek commented Aug 26, 2018

I can confirm this is happening. Strangely, re-sourcing ftplugin/go/commands.vim seems to fix it.

@bhcleek bhcleek removed the bug label Aug 26, 2018
@bhcleek
Copy link
Collaborator

bhcleek commented Aug 26, 2018

It was happening on my system due to the way I have it setup for development. You may have two copies of vim-go's ftplugin/go/commands.vim on your system. Can you please run :verbose command? Was GoInfo last set from where you you have vim-go installed?

@pennz
Copy link
Author

pennz commented Aug 27, 2018

verbose command show

...
!   GoImportAs  *                    customlist    call go#import#SwitchImport(1, <f-args>, '<bang>')
        Last set from ~/.vim/plugged/vim-go/ftplugin/go/commands.vim
    GoImports   0                                  call go#fmt#Format(1)
        Last set from ~/.vim/plugged/vim-go/ftplugin/go/commands.vim
    GoInfo      0                                  call go#tool#Info()
        Last set from ~/.vim/plugged/vim-go/ftplugin/go/commands.vim
!   GoInstall   *                                  call go#cmd#Install(<bang>0, <f-args>)
        Last set from ~/.vim/plugged/vim-go/ftplugin/go/commands.vim
...

Was GoInfo last set from where you you have vim-go installed?

I have not set GoInfo before vim-go is installed. But I have

  • moved from vim to neovim
  • reinstalled vim-go, moving it to .vim/bundle then moving it back to .vim/plugged

And there indeed are two vim-go.

$ find . -name "vim-go"                                                                                                                                           
./plugged/vim-go
./pack/plugins/start/vim-go

After removed them all and used Plugin 'fatih/vim-go' to load vim-go, the GoInfo will not report error but it won't show anything. And in the verbose command, it shows

    GoInfo      0                                  call go#tool#Info()
        Last set from ~/.vim/bundle/vim-go/ftplugin/go/commands.vim

Other Go commands work fine.

@bhcleek bhcleek changed the title GoInfo reports E119: Not enough arguments for function: go#tool#Info GoInfo not reporting type information Aug 27, 2018
@bhcleek
Copy link
Collaborator

bhcleek commented Aug 27, 2018

@pennz I'm unable to duplicate the problem you're seeing. However, there's a PR waiting to be approved that may resolve this for you. Can you see if you still have the same problem with #1926 ?

@pennz
Copy link
Author

pennz commented Aug 28, 2018

@bhcleek The #1926 won't help. Besides, after pathing the pull to master b6381dd , I got this error:

Error detected while processing function <SNR>84_auto_type_info:
line    3:
E118: Too many arguments for function: go#tool#Info

And if I run GoInfo via comand, I got this error message:

Error detected while processing /Users/vincent/.vim/plugged/vim-polyglot/autoload/go/config.vim:
line  426:
E122: Function go#config#FoldEnable already exists, add ! to replace it
Error detected while processing function go#tool#Info[3]..go#complete#Info[2]..<SNR>176_async_info[41]..<SNR>176_gocodeCommand:
line   16:
E117: Unknown function: go#config#GocodeProposeSource
E15: Invalid expression: go#config#GocodeProposeSource()
Error detected while processing function go#tool#Info[3]..go#complete#Info[2]..<SNR>176_async_info[54]..go#job#Start:
line   28:
E475: Invalid argument: expected String or List

It seems go#config#FoldEnable is defined in vim-polyglot too.
Other commands like GoDoc work fine, still.

GoInfo in verbose command ( yes, I moved to vim-plugin as plugin manager and confirmed there is only one vim-go in .vim folder)

    GoInfo      0                                  call go#tool#Info()
        Last set from ~/.vim/plugged/vim-go/ftplugin/go/commands.vim

The log I got by running nvim -V20vim-go-log is uploaded to dropbox: vim-go-log

@bhcleek
Copy link
Collaborator

bhcleek commented Aug 28, 2018

vim-polyglot is introducing older versions of vim-go code into your environment; please try to duplicate the problem without any other plugins loaded.

@pennz
Copy link
Author

pennz commented Aug 29, 2018

@bhcleek After I removed other plugins, error messages won't be reported when I run GoInfo, but I always cannot get any response from GoInfo neither, sometimes I got .
Could you please help to check this? Maybe it is because the gocode I use is not the one from nsf/gocode , but from mdempsky/gocode? Or the version of gocode I use is wrong?

18845 function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[7]..<SNR>48_sync_gocode[12]..go#util#Exec[17]..<SNR>45_exec[7]..<SNR>45_sys
      tem returning '[1, [{''word'': ''I'', ''abbr'': ''ty...e InboundHandlerManager interface''}]]'
18846
18847 continuing in function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[7]..<SNR>48_sync_gocode[12]..go#util#Exec[17]..<SNR>45_exec
18848
18849 line 8:   return [l:out, go#util#ShellError()]
18850 calling function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[7]..<SNR>48_sync_gocode[12]..go#util#Exec[17]..<SNR>45_exec[8]..go#
      util#ShellError()
18851
18852 line 1:   return v:shell_error
18853 function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[7]..<SNR>48_sync_gocode[12]..go#util#Exec[17]..<SNR>45_exec[8]..go#util#She
      llError returning #0
18854
18855 continuing in function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[7]..<SNR>48_sync_gocode[12]..go#util#Exec[17]..<SNR>45_exec
18856
18857 function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[7]..<SNR>48_sync_gocode[12]..go#util#Exec[17]..<SNR>45_exec returning ['[1,
       [{''word'': ''I'', ''abbr'': ''t...boundHandlerManager interface''}]]', 0]
18858
18859 continuing in function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[7]..<SNR>48_sync_gocode[12]..go#util#Exec
18860
18861 function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[7]..<SNR>48_sync_gocode[12]..go#util#Exec returning ['[1, [{''word'': ''I''
      , ''abbr'': ''t...boundHandlerManager interface''}]]', 0]
18862
18863 continuing in function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[7]..<SNR>48_sync_gocode
18865 line 13:   finally
18866 line 14:     let $GOROOT = old_goroot
18867 line 15:   endtry
18868 line 16:
18869 line 17:   if l:err != 0
18870 line 18:     return "[0, []]"
18871 line 19:   endif
18872 line 20:
18873 line 21:   if &encoding != 'utf-8'
18874 line 22:     let l:result = iconv(l:result, 'utf-8', &encoding)
18875 line 23:   endif
18876 line 24:
18877 line 25:   return l:result
18878 function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[7]..<SNR>48_sync_gocode returning '[1, [{''word'': ''I'', ''abbr'': ''ty...
      e InboundHandlerManager interface''}]]'
18879
18880 continuing in function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info
18881
18882 line 10:
18883 line 11:   let result = s:info_filter(a:auto, result)
18884 calling function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[11]..<SNR>48_info_filter(1, '[1, [{''word'': ''I'', ''abbr'': ''ty.
      ..e InboundHandlerManager interface''}]]')
18885
18886 line 1:   if empty(a:result)
18887 line 2:     return ""
18888 line 3:   endif
18889 line 4:
18890 line 5:   let l:result = eval(a:result)
18891 line 6:   if len(l:result) != 2
18892 line 7:     return ""
18893 line 8:   endif
18894 line 9:
18895 line 10:   let l:candidates = l:result[1]
18896 line 11:   if len(l:candidates) == 1
18897 line 12:     " When gocode panics in vim mode, it returns
18898 line 13:     "     [0, [{'word': 'PANIC', 'abbr': 'PANIC PANIC PANIC', 'info': 'PANIC PANIC PANIC'}]]
18899 line 14:     if a:auto && l:candidates[0].info ==# "PANIC PANIC PANIC"
18900 line 15:       return ""
18901 line 16:     endif
18902 line 17:
18903 line 18:     return l:candidates[0].info
18904 line 19:   endif
18905 line 20:
18906 line 21:   let filtered = []
18907 line 22:   let wordMatch = '\<' . expand("<cword>") . '\>'
18908 line 23:   " escape single quotes in wordMatch before passing it to filter
18909 line 24:   let wordMatch = substitute(wordMatch, "'", "''", "g")
18910 line 25:   let filtered = filter(l:candidates, "v:val.info =~ '".wordMatch."'")
18911 line 26:
18912 line 27:   if len(l:filtered) != 1
18913 line 28:     return ""
18914 function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[11]..<SNR>48_info_filter returning ''
18915
18916 continuing in function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info
18917
18918 line 12:   call s:info_complete(a:auto, result)
18919 calling function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[12]..<SNR>48_info_complete(1, '')
18920
18921 line 1:   if !empty(a:result)
18922 line 2:     echo "vim-go: " | echohl Function | echon a:result | echohl None
18923 line 2:  echohl Function | echon a:result | echohl None
18924 line 2:  echon a:result | echohl None
18925 line 2:  echohl None
18926 line 3:   endif
18927 function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info[12]..<SNR>48_info_complete returning #0
18928
18929 continuing in function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info
18930
18931 function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info[4]..<SNR>48_sync_info returning #0
18932
18933 continuing in function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info
18934
18935 function <SNR>13_auto_type_info[3]..go#tool#Info[3]..go#complete#Info returning #0
18936
18937 continuing in function <SNR>13_auto_type_info[3]..go#tool#Info
18938
18939 line 4:   elseif l:mode == 'guru'
18940 line 5:     call go#guru#DescribeInfo()
18941 line 6:   else
18942 line 7:     call go#util#EchoError('go_info_mode value: '. l:mode .' is not valid. Valid values are: [gocode, guru]')
18943 line 8:   endif
18944 function <SNR>13_auto_type_info[3]..go#tool#Info returning #0

You can get the whole log at New log with other plugins removed

@bhcleek
Copy link
Collaborator

bhcleek commented Aug 29, 2018

@pennz prior to 4fdc590, mdempsky/gocode wasn't fully compatible with vim-go. Please:

  • close vim
  • update to vim-go's latest master
  • open vim and run :GoUpdateBinaries

and then try again. Note, however, that mdempsky/gocode does not autobuild_ your packages, so you're trying to run :GoInfo to get information about an identifier from a package that is not installed (e.g. go install $TARGETPKG from the commandline or :GoInstall from within the target package's source using vim-go) in the package's to your $GOPATH/pkg directory, mdempsky/gocode will not be be able to find it and therefore will not output anything....

@pennz
Copy link
Author

pennz commented Aug 29, 2018

@bhcleek Thanks.

Now it works better after following your steps and runing go install -i $TARGETPKG, but now some issues can be seen about GoInfo:

If I am editing this code,

 22 type DokodemoDoor struct {
 23     policyManager core.PolicyManager
 24     config        *Config
 25     address       net.Address
 26     port          net.Port
 27 }
  1. when the cursor is at letter 'd' in type DokodemoDoor struct {, GoInfo will feedback "vim-go: type Dokod invalid type".
  2. even he cursor is at letter 'r' in type DokodemoDoor struct {, GoInfo will feedback "vim-go: type DokodemoDoor invalid type".

The log is here

@bhcleek bhcleek removed the bug label Aug 30, 2018
@bhcleek
Copy link
Collaborator

bhcleek commented Aug 30, 2018

@pennz it sounds like your original issue is resolved. I'm going to close this, but feel free to open a new issue to promote your most recent comment to a new issue.

To debug your issue, you can run

gocode close
gocode -s -debug

And then analyze the output to see if you can identify the problem.

Also, note that without using source mode in mdempsky/gocode, its results will be based on the package as it was last installed, so if you edit your source without installing, you may not see the info you expect.

@bhcleek bhcleek closed this as completed Aug 30, 2018
@pennz
Copy link
Author

pennz commented Aug 30, 2018

Thanks. I will debug about this and report whatever might be interesting.

@andreimatei
Copy link

I've just upgraded vim-go and I'm getting the same error: Not enough arguments for function: go#tool#Info. BUT, only when I'm using my shortcut. If I type :GoInfo, it works fine.
I have the following in my .vimrc.

let g:go_def_mode = 'guru'
let g:go_autodetect_gopath = 0
au FileType go nmap <Space> <Plug>(go-info)

And so pressing space gives me the error, typing ":GoInfo" works. Does this ring any bells?

@bikbah
Copy link

bikbah commented Sep 5, 2018

I've just upgraded vim-go and I'm getting the same error: Not enough arguments for function: go#tool#Info.

Have the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants