-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
ctrl+] behavior does not navigate to symbols in the same module but different source file #2716
Comments
The files are outside of GOPATH/src? Does it matter if you have a go.mod file? |
They are not outside GOPATH/src. I am not using go.mod, but I can try to see if that has an effect. |
If I create a go.mod file with the package, navigation does not work at all, not even giving errors. |
Thanks. Let's focus on the GOPATH mode situation first. I create a quick package that replicates what I understand your description to be and recorded it. I don't see any problems: I noticed that the vimrc you posted is rather short and doesn't include some things that I would expect to have (e.g. Does it work if you execute |
:GoDef behaves the same as ctrl+] |
I have another platform running vim-go which was working, where, as an experiment, I cleaned out go/bin and re-ran GoUpdateBinaries to re-install. Now it has the same behavior. I suspect an updated third party module might be to blame. |
The only binary involved here outside of the go toolchain is gopls. What's the gopls log output if you add |
I should also point out that you can change |
{"method":"initialize","jsonrpc":"2.0","id":1,"params":{"rootUri":"file:///home/ubuntu/mesa/go/src/foo","capabilities":{"workspace":{"workspaceFolders":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":true}},"textDocument":{"completion":{"completionItem":{"snippetSupport":false}},"hover":{"contentFormat":["plaintext"]}}},"processId":1874,"workspaceFolders":[{"uri":"file:///home/ubuntu/mesa/go/src/foo","name":"/home/ubuntu/mesa/go/src/foo"}]}} {"id":1,"jsonrpc":"2.0","result":null} {"jsonrpc":"2.0","method":"client/registerCapability","params":{"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"}]},"id":1} stderr: 2020/02/11 06:04:50 debug server listening on port 41593 {"method":"textDocument/didOpen","jsonrpc":"2.0","params":{"textDocument":{"uri":"file:///home/ubuntu/mesa/go/src/foo/fileb.go","version":1,"languageId":"go","text":"package foo\n\nimport (\n\t\"fmt\"\n)\n\ntype Bar struct {\n\ta int\n}\n\nfunc DoSomething(f *Foo, b *Bar) {\n\t// ctrl+] in Bar works (inside this file), Foo does not (inside the package, but not this file)\n\tfmt.Println(\"\") // Println works (outside this package)\n}\n"}}} {"method":"initialized","jsonrpc":"2.0","params":{}} {"jsonrpc":"2.0","result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"completionProvider":{"triggerCharacters":["."]},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":true,"codeLensProvider":{},"documentLinkProvider":{},"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":true,"foldingRangeProvider":true,"executeCommandProvider":{"commands":["tidy"]},"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":""}},"id":1} {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/02/11 06:04:50 Build info\n----------\ngolang.org/x/tools/gopls v0.3.1\n golang.org/x/tools/gopls@v0.3.1 h1:yNTWrf4gc4Or0UecjOas5pzOa3BL0WDDyKDV4Wz5VaM=\n github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=\n github.com/sergi/go-diff@v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=\n golang.org/x/mod@v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=\n golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=\n golang.org/x/tools@v0.0.0-20200204151227-34c67990bfe7 h1:hWZVyLW37WdETuLIGQMvQIhMfXXAOANmAIEAluZMy3c=\n golang.org/x/xerrors@v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=\n honnef.co/go/tools@v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=\n mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=\n\nGo info\n-------\ngo version go1.13.3 linux/amd64\n\nGO111MODULE=\"\"\nGOARCH=\"amd64\"\nGOBIN=\"\"\nGOCACHE=\"/home/ubuntu/.cache/go-build\"\nGOENV=\"/home/ubuntu/.config/go/env\"\nGOEXE=\"\"\nGOFLAGS=\"\"\nGOHOSTARCH=\"amd64\"\nGOHOSTOS=\"linux\"\nGONOPROXY=\"\"\nGONOSUMDB=\"\"\nGOOS=\"linux\"\nGOPATH=\"/home/ubuntu/mesa/go\"\nGOPRIVATE=\"\"\nGOPROXY=\"https://proxy.golang.org,direct\"\nGOROOT=\"/usr/src/go1.13.3/go\"\nGOSUMDB=\"sum.golang.org\"\nGOTMPDIR=\"\"\nGOTOOLDIR=\"/usr/src/go1.13.3/go/pkg/tool/linux_amd64\"\nGCCGO=\"gccgo\"\nAR=\"ar\"\nCC=\"gcc\"\nCXX=\"g++\"\nCGO_ENABLED=\"1\"\nGOMOD=\"\"\nCGO_CFLAGS=\"-g -O2\"\nCGO_CPPFLAGS=\"\"\nCGO_CXXFLAGS=\"-g -O2\"\nCGO_FFLAGS=\"-g -O2\"\nCGO_LDFLAGS=\"-g -O2\"\nPKG_CONFIG=\"pkg-config\"\nGOGCCFLAGS=\"-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build590064323=/tmp/go-build -gno-record-gcc-switches\"\n"}} {"id":2,"jsonrpc":"2.0","result":[{"buildFlags":[],"hoverKind":"NoDocumentation"},{"buildFlags":[],"hoverKind":"NoDocumentation"}]} {"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///home/ubuntu/mesa/go/src/foo","section":"gopls"},{"scopeUri":"file:///home/ubuntu/mesa/go/src/foo","section":"gopls-/home/ubuntu/mesa/go/src/foo"}]},"id":2} {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"2020/02/11 06:04:50 initial workspace load failed: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- ./... builtin]: exit status 1: go build foo: failed to cache compiled Go files\n"}} {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/02/11 06:04:50 go/packages.Load\n\tsnapshot = 0\n\tquery = [./... builtin]\n\tpackages = 0"}} stderr: stderr: 2020/02/11 06:04:50 initial workspace load failed: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- ./... builtin]: exit status 1: go build foo: failed to cache compiled Go files {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/02/11 06:04:50 go/packages.Load\n\tsnapshot = 1\n\tpackage = command-line-arguments\n\tfiles = [/home/ubuntu/mesa/go/src/foo/fileb.go]"}} {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/02/11 06:04:50 go/packages.Load\n\tsnapshot = 1\n\tquery = [file=/home/ubuntu/mesa/go/src/foo/fileb.go]\n\tpackages = 1"}} {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/ubuntu/mesa/go/src/foo/fileb.go","version":1,"diagnostics":[{"range":{"start":{"line":10,"character":20},"end":{"line":10,"character":23}},"severity":1,"source":"compiler","message":"undeclared name: Foo"}]}} |
It looks like the problem here is gopls, but I'm not sure what would cause the error it's reporting. @stamblerre can you provide any guidance? @PaulForgey what version of vim-go are you using? If you're on v1.22, you can run |
I suspect an intermediate outside module used in the building the binary has perhaps updated. It's the only way I can explain taking a previously working installation and breaking it by simply re-building the binaries clean. |
I'm on v1.22 (also tried master), I already did GoUpdateBinaries gopls so I am actually on.. v0.3.1?? Let me try that again from v1.22.. that puts me on v0.3.1 |
in the meantime, setting go_def_mode to godef lets me get on with my workday.. |
@PaulForgey Does |
@bhcleek yes |
While I am consistently reproducing this on both Linux (4.9.37) and MacOS (Darwin 18.7.0) with the same version of vim in this report, go_def_mode set to 'godef' does have random wrong behavior as well, which sometimes changes after either :e or :w, flapping between not seeing symbols outside the file, navigating to the wrong file entirely, or working. |
I'm not able to replicate any of the problems described here. If you can provide a complete set of steps to replicate this on a clean system, I'm happy to investigate more. |
Sorry for not replying here earlier. In the
@PaulForgey: Do you consistently see this error? /cc @jayconrod for |
If you can reproduce the error @stamblerre Retrying |
@stamblerre I do constantly see that and missed it myself. After cleaning again and this time making sure no oddly owned/perm’d files were left behind, I am no longer consistently seeing this. |
:go build never fails, but I do go build from the command line with editors open all the time, and so perhaps I could be tripping on some cache concurrency issues. |
@PaulForgey: Glad things are working again. If you run into this again, please do report an issue on the Go repository. |
@PaulForgey should we close this? |
yes, thank you. |
What did you do? (required: The issue will be closed when not provided)
Try to navigate to a symbol using ctrl+].
Small reproduction:
filea.go
fileb.go
What did you expect to happen?
In the example fileb.go, navigate to the symboles Foo, Bar and Println
What happened instead?
Foo is not found, able to navigate to Bar and Println
Configuration (MUST fill this out):
vim-go version:
vimrc
you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):vimrc
Vim version (first three lines from
:version
):VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jan 7 2020 00:59:23)
Included patches: 1-96
Compiled by ubuntu@ip-172-31-37-247
Go version (
go version
):go version go1.13.3 linux/amd64
Go environment
go env
Output:gopls version
gopls version
Output:The text was updated successfully, but these errors were encountered: