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

x/tools/gopls: didn't jump definition #38199

Closed
skanehira opened this issue Apr 1, 2020 · 3 comments
Closed

x/tools/gopls: didn't jump definition #38199

skanehira opened this issue Apr 1, 2020 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@skanehira
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go version go1.14.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/Users/skanehira/dev/go/bin"
GOCACHE="/Users/skanehira/Library/Caches/go-build"
GOENV="/Users/skanehira/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/skanehira/dev/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/skanehira/dev/go/src/github.com/skanehira/pgw/api/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rl/v_7b584d44bcj5261sh56l200000gn/T/go-build018767148=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Use vim-lsp and run :LspDefinition but it didn't works.

vim-lsp log
木  4/ 2 00:39:05 2020:[{"response":{"data":{"__data__":"vim-lsp","server_name":"gopls"},"message":"server already started"}}]
木  4/ 2 00:39:05 2020:[{"response":{"data":{"__data__":"vim-lsp","init_result":{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"executeCommandProvider":{"commands":["tidy","upgrade.dependency","generate"]},"documentHighlightProvider":true,"hoverProvider":true,"typeDefinitionProvider":true,"definitionProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"foldingRangeProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","source.fixAll","source.organizeImports"]},"textDocumentSync":{"save":{},"change":2,"openClose":true},"codeLensProvider":{},"workspace":{"workspaceFolders":{"changeNotifications":"workspace/didChangeWorkspaceFolders","supported":true}},"documentLinkProvider":{},"implementationProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentSymbolProvider":true,"renameProvider":true,"completionProvider":{"triggerCharacters":["."]}},"serverInfo":{"name":""}}},"server_name":"gopls"},"message":"lsp server already initialized"}}]
木  4/ 2 00:39:05 2020:["--->",1,"gopls",{"method":"workspace/didChangeConfiguration","params":{"settings":{}}}]
木  4/ 2 00:39:05 2020:[{"response":{"data":{"__data__":"vim-lsp","server_name":"gopls"},"message":"configuration sent"}}]
木  4/ 2 00:39:05 2020:[{"response":{"data":{"path":"file:///Users/skanehira/dev/go/src/github.com/skanehira/test/main.go","__data__":"vim-lsp","server_name":"gopls"},"message":"already opened"}}]
木  4/ 2 00:39:05 2020:[{"response":{"data":{"path":"file:///Users/skanehira/dev/go/src/github.com/skanehira/test/main.go","__data__":"vim-lsp","server_name":"gopls"},"message":"not dirty"}}]
木  4/ 2 00:39:05 2020:["--->",1,"gopls",{"method":"textDocument/definition","on_notification":"---funcref---","params":{"textDocument":{"uri":"file:///Users/skanehira/dev/go/src/github.com/skanehira/test/main.go"},"position":{"character":17,"line":5}}}]
木  4/ 2 00:39:05 2020:["<---",1,{"method":"workspace/configuration","jsonrpc":"2.0","id":6,"params":{"items":[{"section":"gopls","scopeUri":"file:///Users/skanehira/dev/go/src/github.com/skanehira/test"},{"section":"gopls-test","scopeUri":"file:///Users/skanehira/dev/go/src/github.com/skanehira/test"}]}}]
木  4/ 2 00:39:05 2020:["--->",1,"gopls",{"id":6,"result":[null,null]}]
木  4/ 2 00:39:05 2020:["<---",1,"gopls",{"response":{"id":5,"jsonrpc":"2.0","error":{"data":null,"code":0,"message":"no object for ident NAME"}},"request":{"id":5,"jsonrpc":"2.0","method":"textDocument/definition","params":{"textDocument":{"uri":"file:///Users/skanehira/dev/go/src/github.com/skanehira/test/main.go"},"position":{"character":17,"line":5}}}}]
木  4/ 2 00:39:05 2020:["<---(stderr)",1,"gopls",["2020/04/02 00:39:05 failed to load workspace packages, skipping diagnostics: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- ./]: exit status 1: go: cannot find main module, but found .git/config in /Users/skanehira/dev/go/src/github.com/skanehira/test","\tto create a module there, run:","\tgo mod init","","\tmessage=\"failed to load workspace packages, skipping diagnostics\"","\terror=\"go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- ./]: exit status 1: go: cannot find main module, but found .git/config in /Users/skanehira/dev/go/src/github.com/skanehira/test\\n\\tto create a module there, run:\\n\\tgo mod init\\n\"","\tsnapshot=1","\tdirectory=\"file:///Users/skanehira/dev/go/src/github.com/skanehira/test\"",""]]
木  4/ 2 00:39:05 2020:["<---",1,"gopls",{"response":{"method":"window/logMessage","jsonrpc":"2.0","params":{"message":"2020/04/02 00:39:05 failed to load workspace packages, skipping diagnostics: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- ./]: exit status 1: go: cannot find main module, but found .git/config in /Users/skanehira/dev/go/src/github.com/skanehira/test\n\tto create a module there, run:\n\tgo mod init\n\n\tmessage=\"failed to load workspace packages, skipping diagnostics\"\n\terror=\"go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- ./]: exit status 1: go: cannot find main module, but found .git/config in /Users/skanehira/dev/go/src/github.com/skanehira/test\\n\\tto create a module there, run:\\n\\tgo mod init\\n\"\n\tsnapshot=1\n\tdirectory=\"file:///Users/skanehira/dev/go/src/github.com/skanehira/test\"","type":1}}}]
木  4/ 2 00:39:05 2020:["<---",1,"gopls",{"response":{"method":"window/logMessage","jsonrpc":"2.0","params":{"message":"2020/04/02 00:39:05 go/packages.Load\n\tmessage=\"go/packages.Load\"\n\tsnapshot=1\n\tdirectory=\"/Users/skanehira/dev/go/src/github.com/skanehira/test\"\n\tquery=[\"./\"]\n\tpackages=0","type":3}}}]

My project tree is following.

$ tree test
test
├── gorilla
│   └── gorilla.go
└── main.go

Then main.go

package main

import "github.com/skanehira/test/gorilla"

func main() {
	println(gorilla.NAME)
}

Then gorilla.go

package gorilla

const NAME = "gorilla"

What did you expect to see?

Jump definition

What did you see instead?

Didn't jump definition

@gopherbot gopherbot added this to the Unreleased milestone Apr 1, 2020
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Apr 1, 2020
@gopherbot
Copy link
Contributor

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@stamblerre
Copy link
Contributor

What is your value of GO111MODULE? Also, did those files already exist on disk when you started Vim?

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 1, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.4.0 Apr 1, 2020
@skanehira
Copy link
Contributor Author

skanehira commented Apr 2, 2020

What is your value of GO111MODULE?

Value was on.
I try change it to auto and it works!
Thank you :)

@golang golang locked and limited conversation to collaborators Apr 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants