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: gopls not detecting embedded projects #71081

Closed
kkrime opened this issue Jan 2, 2025 · 2 comments
Closed

x/tools/gopls: gopls not detecting embedded projects #71081

kkrime opened this issue Jan 2, 2025 · 2 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@kkrime
Copy link

kkrime commented Jan 2, 2025

Go version

gopls v0.17.1

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/kkrime/Library/Caches/go-build'
GOENV='/Users/kkrime/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/kkrime/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/kkrime/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/kkrime/go/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/kkrime/go/pkg/mod/golang.org/[email protected]/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.3'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/kkrime/go/src/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/c3/rzmnfcrn17g80qs3g6pj43xr0000gn/T/go-build3355237921=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

If we have the following:
outter_project: /User/kkrime/go/src/outter_project
inner_project: /User/kkrime/go/src/outter_project/inner_project

Both projects are vaild go projects with all the files you'd expect in the root of a golang project folder

What did you see happen?

If you open the outter_project first then open the inner_project, then gopls will only return the outter_project as a workspace_folder

nvim outta_project/main.go outter_project/innner_project/main.go -O

If you do it the other way round i.e first open the inner_project then open the outter_project, gopls will return both projects workspace_folder

nvim outter_project/innner_project/main.go outta_project/main.go -O

What did you expect to see?

gopls should return both projects workspace_folders in both senarios

@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 Jan 2, 2025
@gopherbot gopherbot added this to the Unreleased milestone Jan 2, 2025
@findleyr
Copy link
Member

findleyr commented Jan 3, 2025

Hi @kkrime, gopls does not return workspace folders: those are provided by the LSP client. Which nvim client are you using?

FWIW, I use coc.nvim, and frequently work in the x/tools and x/tools/gopls modules. I use a go.work file to unify the two modules into a single workspace.

Nevertheless, if you open a file in inner_project, gopls should automatically detect the distinct build configuration, and work correctly in the inner module. But it won't consider the module part of the workspace until you open a file in it.

Closing as (AFAICT) this is a client issue. Please comment if I'm misunderstanding.

@findleyr findleyr closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants