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

GoTo command not work with vendor in Golang? #2985

Closed
12 tasks done
jiajunhuang opened this issue Apr 13, 2018 · 12 comments
Closed
12 tasks done

GoTo command not work with vendor in Golang? #2985

jiajunhuang opened this issue Apr 13, 2018 · 12 comments

Comments

@jiajunhuang
Copy link

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) before filing your issue:

  • I have read and understood YCM's CONTRIBUTING document.
  • I have read and understood YCM's CODE_OF_CONDUCT document.
  • I have read and understood YCM's README, especially the
    Frequently Asked Questions section.
  • I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. (Example Google
    search.
    )
  • If filing a bug report, I have included the output of vim --version.
  • If filing a bug report, I have included the output of :YcmDebugInfo.
  • If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • If filing a bug report, I have included a minimal test case that reproduces
    my issue, including what I expected to happen and what actually happened.
  • If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt gift of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

Provide a clear description of the problem, including the following key
questions:

  • What did you do?

Include steps to reproduce here.

  1. create main.go in gopath
package main

import (
	"go.uber.org/zap"
)

func main() {
	logger, _ := zap.NewProduction()
	defer logger.Sync()

	logger.Info("haha")
}
  1. run dep ensure -add "go.uber.org/zap"

  2. use vim, open main.go, jump to line 11, under Info of logger.Info, and run :YcmCompleter GoTo,
    got RuntimeError: Can't find a definition.

Include description of a minimal test case, including any actual code required
to reproduce the issue.

  • What did you expect to happen?

jump to definition of Info inner vendor directory.

Include description of the expected behaviour.

  • What actually happened?

nothing but RuntimeError: Can't find a definition.

Include description of the observed behaviour, including actual output,
screenshots, etc.

Diagnostic data

Output of vim --version

NVIM v0.2.2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-OyJkBd/neovim-0.2.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=2 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim-OyJkBd/neovim-0.2.2/build/config -I/build/neovim-OyJkBd/neovim-0.2.2/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/build/neovim-OyJkBd/neovim-0.2.2/build/src/nvim/auto -I/build/neovim-OyJkBd/neovim-0.2.2/build/include
Compiled by pkg-vim-maintainers@lists.alioth.debian.org

Features: +acl +iconv +jemalloc +tui 
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Output of YcmDebugInfo

Printing YouCompleteMe debug information...                                                             
-- Client logfile: /tmp/ycm_k6wkcljd.log
-- Server Python interpreter: /home/jiajun/.py3k/bin/python
-- Server Python version: 3.6.3
-- Server has Clang support compiled in: False
-- Clang version: None
-- No extra configuration file found
-- Server running at: http://127.0.0.1:44727
-- Server process ID: 3464
-- Server logfiles:
--   /tmp/ycmd_44727_stdout_e296vmt2.log
--   /tmp/ycmd_44727_stderr_3hml12e5.log

Contents of YCM, ycmd and completion engine logfiles

Include link here to a gist containing the entire logfiles for ycm, ycmd
and any completer logfiles listed by :YcmToggleLogs.

OS version, distribution, etc.

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux testing (buster)
Release:	testing
Codename:	buster

Output of build/install commands

./install.py --go-completer

@micbou
Copy link
Collaborator

micbou commented Apr 14, 2018

I can reproduce the issue and the ycmd logs show this error (godef is used to jump to definition):

RuntimeError: Command godef -i -f=main.go -json -o=126 failed with code 2 and error "godef: no declaration found for logger.Info".

Running directly the command with the latest version of godef raises the same error:

$ godef -i -f=main.go -o=126 < main.go
parseLocalPackage error: no more package files found
godef: no declaration found for logger.Info

so it looks like an issue with godef. Would you mind reporting it to the godef repository?

@jiajunhuang
Copy link
Author

okay, thank you

@timfeirg
Copy link

timfeirg commented Apr 20, 2018

Ran into the same issue today, found out that vim-go's :GoDef will work as expected, if you've installed the upstream godef into your $PATH.

ycmd uses a old fork of godef which doesn't really deal with golang vendor directories.

you can use vim-go's :GoDef if you want this fixed ugly and fast.

autocmd FileType go nnoremap <C-c>g :<C-u>call go#def#Jump("vsplit")<CR>

@jiajunhuang

@micbou
Copy link
Collaborator

micbou commented Apr 20, 2018

@timfeirg Did you read my comment? I tried with the latest version of Godef. Are you sure you are talking about the same issue?

@timfeirg
Copy link

I'm sorry, I didn't exactly carry out the steps to verify that it's fixed.

I just put the example code in main.go, go get -d go.uber.org/zap, and then did a :GoDef on the logger.info method, this does work, so I just assumed that the latest version of the upstream godef works.

Also, I was seeing the upstream godef correctly finds the dependencies in the vendor directories, and just think that it's pretty convincing. @micbou

@micbou
Copy link
Collaborator

micbou commented Apr 20, 2018

The :GoDef command from vim-go is working because it uses Guru by default, not Godef. I guess we should switch to that tool.

@jiajunhuang
Copy link
Author

hello, after compile latest YCM with --go-completer, auto completion code in vendor still not work, will this issue be fixed? thank you!

@jiajunhuang
Copy link
Author

using language server protocol now.

@jiajunhuang
Copy link
Author

still not work, hope to be fixed

@jiajunhuang jiajunhuang reopened this Aug 27, 2018
@cherrot
Copy link

cherrot commented Dec 27, 2018

Can I configure ycm to use guru in Golang?

@puremourning
Copy link
Member

No

@bstaletic
Copy link
Collaborator

We have switched to gopls which solves the issue with the GoTo subcommand.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants