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: provide a way to exclude directories from workspace symbol search #48939

Closed
hyangah opened this issue Oct 13, 2021 · 3 comments
Closed
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Oct 13, 2021

context: https://stackoverflow.com/questions/69408844/how-to-exclude-vendor-directory-from-go-symbol-search

I wanted to suggest directoryFilter initially and found it doesn't get applied to workspace symbol request.

"gopls" {
  "build.directoryFilters": ["-vendor"]
}
gopls trace (v0.7.2 built with go1.18-577bb7dba1) ``` [Trace - 09:32:15.684 AM] Received request 'workspace/configuration - (2)'. Params: {"items":[{"scopeUri":"file:///Users/hakim/projects/delve","section":"gopls"}]}

[Trace - 09:32:15.700 AM] Sending response 'workspace/configuration - (2)' in 16ms.
Result: [{"build.directoryFilters":["-vendor"]}]

[Info - 9:32:15 AM] 2021/10/13 09:32:15 go env for /Users/hakim/projects/delve
(root /Users/hakim/projects/delve)
(go version go version devel go1.18-577bb7dba1 Mon Oct 11 17:02:03 2021 +0000 darwin/amd64)
(valid build configuration = true)
(build flags: [])
GONOSUMDB=
GOPROXY=https://proxy.golang.org,direct
GOSUMDB=sum.golang.org
GO111MODULE=
GOFLAGS=
GOMODCACHE=/Users/hakim/go/pkg/mod
GOROOT=/Users/hakim/sdk/gotip
GONOPROXY=
GOPATH=/Users/hakim/go
GOPRIVATE=
GOMOD=/Users/hakim/projects/delve/go.mod
GOCACHE=/Users/hakim/Library/Caches/go-build
GOINSECURE=

[Trace - 09:32:16.349 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/13 09:32:16 go/packages.Load\n\tsnapshot=0\n\tdirectory=/Users/hakim/projects/delve\n\tquery=[builtin github.com/go-delve/delve/...]\n\tpackages=86\n"}

[Info - 9:32:16 AM] 2021/10/13 09:32:16 go/packages.Load
snapshot=0
directory=/Users/hakim/projects/delve
query=[builtin github.com/go-delve/delve/...]
packages=86

[Trace - 09:32:16.737 AM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"end","message":"Finished loading packages."}}

[Trace - 09:32:16.740 AM] Received request 'client/registerCapability - (3)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/*.*tmpl","kind":7},{"globPattern":"/*.{go,mod,sum,work,tmpl}","kind":7},{"globPattern":"{/Users/hakim/projects/delve/cmd,/Users/hakim/projects/delve/cmd/dlv,/Users/hakim/projects/delve/cmd/dlv/cmds,/Users/hakim/projects/delve/pkg,/Users/hakim/projects/delve/pkg/astutil,/Users/hakim/projects/delve/pkg/config,/Users/hakim/projects/delve/pkg/dwarf,/Users/hakim/projects/delve/pkg/dwarf/dwarfbuilder,/Users/hakim/projects/delve/pkg/dwarf/frame,/Users/hakim/projects/delve/pkg/dwarf/godwarf,/Users/hakim/projects/delve/pkg/dwarf/line,/Users/hakim/projects/delve/pkg/dwarf/loclist,/Users/hakim/projects/delve/pkg/dwarf/op,/Users/hakim/projects/delve/pkg/dwarf/reader,/Users/hakim/projects/delve/pkg/dwarf/regnum,/Users/hakim/projects/delve/pkg/dwarf/util,/Users/hakim/projects/delve/pkg/elfwriter,/Users/hakim/projects/delve/pkg/gobuild,/Users/hakim/projects/delve/pkg/goversion,/Users/hakim/projects/delve/pkg/locspec,/Users/hakim/projects/delve/pkg/logflags,/Users/hakim/projects/delve/pkg/proc,/Users/hakim/projects/delve/pkg/proc/amd64util,/Users/hakim/projects/delve/pkg/proc/core,/Users/hakim/projects/delve/pkg/proc/core/minidump,/Users/hakim/projects/delve/pkg/proc/fbsdutil,/Users/hakim/projects/delve/pkg/proc/gdbserial,/Users/hakim/projects/delve/pkg/proc/internal,/Users/hakim/projects/delve/pkg/proc/internal/ebpf,/Users/hakim/projects/delve/pkg/proc/linutil,/Users/hakim/projects/delve/pkg/proc/macutil,/Users/hakim/projects/delve/pkg/proc/native,/Users/hakim/projects/delve/pkg/proc/test,/Users/hakim/projects/delve/pkg/proc/winutil,/Users/hakim/projects/delve/pkg/terminal,/Users/hakim/projects/delve/pkg/terminal/colorize,/Users/hakim/projects/delve/pkg/terminal/starbind,/Users/hakim/projects/delve/pkg/version,/Users/hakim/projects/delve/service,/Users/hakim/projects/delve/service/api,/Users/hakim/projects/delve/service/dap,/Users/hakim/projects/delve/service/dap/daptest,/Users/hakim/projects/delve/service/dap/daptest/gen,/Users/hakim/projects/delve/service/debugger,/Users/hakim/projects/delve/service/internal,/Users/hakim/projects/delve/service/internal/sameuser,/Users/hakim/projects/delve/service/rpc1,/Users/hakim/projects/delve/service/rpc2,/Users/hakim/projects/delve/service/rpccommon,/Users/hakim/projects/delve/service/test,/Users/hakim/projects/delve/vendor,/Users/hakim/projects/delve/vendor/github.com,/Users/hakim/projects/delve/vendor/github.com/cosiner,/Users/hakim/projects/delve/vendor/github.com/cosiner/argv,/Users/hakim/projects/delve/vendor/github.com/cpuguy83,/Users/hakim/projects/delve/vendor/github.com/cpuguy83/go-md2man,/Users/hakim/projects/delve/vendor/github.com/cpuguy83/go-md2man/v2,/Users/hakim/projects/delve/vendor/github.com/cpuguy83/go-md2man/v2/md2man,/Users/hakim/projects/delve/vendor/github.com/creack,/Users/hakim/projects/delve/vendor/github.com/creack/pty,/Users/hakim/projects/delve/vendor/github.com/derekparker,/Users/hakim/projects/delve/vendor/github.com/derekparker/trie,/Users/hakim/projects/delve/vendor/github.com/google,/Users/hakim/projects/delve/vendor/github.com/google/go-dap,/Users/hakim/projects/delve/vendor/github.com/hashicorp,/Users/hakim/projects/delve/vendor/github.com/hashicorp/golang-lru,/Users/hakim/projects/delve/vendor/github.com/hashicorp/golang-lru/simplelru,/Users/hakim/projects/delve/vendor/github.com/mattn,/Users/hakim/projects/delve/vendor/github.com/mattn/go-isatty,/Users/hakim/projects/delve/vendor/github.com/mattn/go-runewidth,/Users/hakim/projects/delve/vendor/github.com/peterh,/Users/hakim/projects/delve/vendor/github.com/peterh/liner,/Users/hakim/projects/delve/vendor/github.com/russross,/Users/hakim/projects/delve/vendor/github.com/russross/blackfriday,/Users/hakim/projects/delve/vendor/github.com/russross/blackfriday/v2,/Users/hakim/projects/delve/vendor/github.com/shurcooL,/Users/hakim/projects/delve/vendor/github.com/shurcooL/sanitized_anchor_name,/Users/hakim/projects/delve/vendor/github.com/sirupsen,/Users/hakim/projects/delve/vendor/github.com/sirupsen/logrus,/Users/hakim/projects/delve/vendor/github.com/spf13,/Users/hakim/projects/delve/vendor/github.com/spf13/cobra,/Users/hakim/projects/delve/vendor/github.com/spf13/cobra/doc,/Users/hakim/projects/delve/vendor/github.com/spf13/pflag,/Users/hakim/projects/delve/vendor/go.starlark.net,/Users/hakim/projects/delve/vendor/go.starlark.net/internal,/Users/hakim/projects/delve/vendor/go.starlark.net/internal/compile,/Users/hakim/projects/delve/vendor/go.starlark.net/internal/spell,/Users/hakim/projects/delve/vendor/go.starlark.net/resolve,/Users/hakim/projects/delve/vendor/go.starlark.net/starlark,/Users/hakim/projects/delve/vendor/go.starlark.net/syntax,/Users/hakim/projects/delve/vendor/golang.org,/Users/hakim/projects/delve/vendor/golang.org/x,/Users/hakim/projects/delve/vendor/golang.org/x/arch,/Users/hakim/projects/delve/vendor/golang.org/x/arch/arm64,/Users/hakim/projects/delve/vendor/golang.org/x/arch/arm64/arm64asm,/Users/hakim/projects/delve/vendor/golang.org/x/arch/x86,/Users/hakim/projects/delve/vendor/golang.org/x/arch/x86/x86asm,/Users/hakim/projects/delve/vendor/golang.org/x/sys,/Users/hakim/projects/delve/vendor/golang.org/x/sys/internal,/Users/hakim/projects/delve/vendor/golang.org/x/sys/internal/unsafeheader,/Users/hakim/projects/delve/vendor/golang.org/x/sys/unix,/Users/hakim/projects/delve/vendor/golang.org/x/tools,/Users/hakim/projects/delve/vendor/golang.org/x/tools/go,/Users/hakim/projects/delve/vendor/golang.org/x/tools/go/gcexportdata,/Users/hakim/projects/delve/vendor/golang.org/x/tools/go/internal,/Users/hakim/projects/delve/vendor/golang.org/x/tools/go/internal/gcimporter,/Users/hakim/projects/delve/vendor/golang.org/x/tools/go/internal/packagesdriver,/Users/hakim/projects/delve/vendor/golang.org/x/tools/go/packages,/Users/hakim/projects/delve/vendor/golang.org/x/tools/internal,/Users/hakim/projects/delve/vendor/golang.org/x/tools/internal/fastwalk,/Users/hakim/projects/delve/vendor/golang.org/x/tools/internal/gopathwalk,/Users/hakim/projects/delve/vendor/golang.org/x/tools/internal/semver,/Users/hakim/projects/delve/vendor/golang.org/x/tools/internal/span,/Users/hakim/projects/delve/vendor/gopkg.in,/Users/hakim/projects/delve/vendor/gopkg.in/yaml.v2}","kind":7}]}}]}

[Trace - 09:32:16.889 AM] Sending response 'client/registerCapability - (3)' in 148ms.
Result:

[Trace - 09:32:16.889 AM] Received request 'client/registerCapability - (4)'.
Params: {"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"}]}

[Trace - 09:32:16.890 AM] Sending response 'client/registerCapability - (4)' in 0ms.
Result:

[Trace - 09:32:16.927 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/13 09:32:16 discovered missing identifiers: map[memRecordCycle:true pageBits:true]\n\tpackage="runtime"\n"}

[Info - 9:32:16 AM] 2021/10/13 09:32:16 discovered missing identifiers: map[memRecordCycle:true pageBits:true]
package="runtime"

[Trace - 09:32:17.198 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/13 09:32:17 discovered missing identifiers: map[fieldKey:true]\n\tpackage="github.com/sirupsen/logrus"\n"}

[Info - 9:32:17 AM] 2021/10/13 09:32:17 discovered missing identifiers: map[fieldKey:true]
package="github.com/sirupsen/logrus"

[Trace - 09:32:17.320 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/13 09:32:17 falling back to safe trimming due to type errors: [/Users/hakim/sdk/gotip/src/os/user/cgo_lookup_unix.go:198:19: int not declared by package C /Users/hakim/sdk/gotip/src/os/user/cgo_lookup_unix.go:201:16: bufferKind(C._SC_GETPW_R_SIZE_MAX) (value of type bufferKind) is not constant /Users/hakim/sdk/gotip/src/os/user/cgo_lookup_unix.go:202:16: bufferKind(C._SC_GETGR_R_SIZE_MAX) (value of type bufferKind) is not constant] or still-missing identifiers: map[]\n\tpackage="os/user"\n"}

[Info - 9:32:17 AM] 2021/10/13 09:32:17 falling back to safe trimming due to type errors: [/Users/hakim/sdk/gotip/src/os/user/cgo_lookup_unix.go:198:19: int not declared by package C /Users/hakim/sdk/gotip/src/os/user/cgo_lookup_unix.go:201:16: bufferKind(C._SC_GETPW_R_SIZE_MAX) (value of type bufferKind) is not constant /Users/hakim/sdk/gotip/src/os/user/cgo_lookup_unix.go:202:16: bufferKind(C._SC_GETGR_R_SIZE_MAX) (value of type bufferKind) is not constant] or still-missing identifiers: map[]
package="os/user"

[Trace - 09:32:17.442 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/13 09:32:17 discovered missing identifiers: map[yaml_style_t:true]\n\tpackage="gopkg.in/yaml.v2"\n"}

[Info - 9:32:17 AM] 2021/10/13 09:32:17 discovered missing identifiers: map[yaml_style_t:true]
package="gopkg.in/yaml.v2"

[Trace - 09:32:17.463 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/13 09:32:17 discovered missing identifiers: map[options:true]\n\tpackage="vendor/golang.org/x/text/unicode/bidi"\n"}

[Info - 9:32:17 AM] 2021/10/13 09:32:17 discovered missing identifiers: map[options:true]
package="vendor/golang.org/x/text/unicode/bidi"

[Trace - 09:32:17.742 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/13 09:32:17 discovered missing identifiers: map[debugMethod:true]\n\tpackage="net/rpc"\n"}

[Info - 9:32:17 AM] 2021/10/13 09:32:17 discovered missing identifiers: map[debugMethod:true]
package="net/rpc"

[Trace - 09:32:17.948 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/13 09:32:17 falling back to safe trimming due to type errors: [/Users/hakim/sdk/gotip/src/internal/buildcfg/exp.go:24:38: 2-valued (func() (goexperiment.Flags, goexperiment.Flags) literal)() (value of type (goexperiment.Flags, goexperiment.Flags)) where single value is expected] or still-missing identifiers: map[]\n\tpackage="internal/buildcfg"\n"}

[Info - 9:32:17 AM] 2021/10/13 09:32:17 falling back to safe trimming due to type errors: [/Users/hakim/sdk/gotip/src/internal/buildcfg/exp.go:24:38: 2-valued (func() (goexperiment.Flags, goexperiment.Flags) literal)() (value of type (goexperiment.Flags, goexperiment.Flags)) where single value is expected] or still-missing identifiers: map[]
package="internal/buildcfg"

[Trace - 09:32:17.980 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/13 09:32:17 discovered missing identifiers: map[term:true]\n\tpackage="go/types"\n"}

[Info - 9:32:17 AM] 2021/10/13 09:32:17 discovered missing identifiers: map[term:true]
package="go/types"

[Trace - 09:32:23.649 AM] Sending request 'workspace/symbol - (1)'.
Params: {"query":"trace"}

[Trace - 09:32:24.422 AM] Received response 'workspace/symbol - (1)' in 773ms.
Result: [{"name":"trace","kind":12,"location":{"uri":"file:///Users/hakim/projects/delve/vendor/gopkg.in/yaml.v2/scannerc.go","range":{"start":{"line":616,"character":5},"end":{"line":616,"character":10}}},"containerName":"gopkg.in/yaml.v2"},{"name":"Trace","kind":12,"location":{"uri":"file:///Users/hakim/projects/delve/vendor/github.com/sirupsen/logrus/exported.go","range":{"start":{"line":92,"character":5},"end":{"line":92,"character":10}}},"containerName":"github.com/sirupsen/logrus"},{"name":"Tracef","kind":12,
...
"location":{"name":"Debugger.GetBufferedTracepoints","kind":6,"location":{"uri":"file:///Users/hakim/projects/delve/service/debugger/debugger.go","range":{"start":{"line":2142,"character":19},"end":{"line":2142,"character":41}}},"containerName":"github.com/go-delve/delve/service/debugger"},{"name":"Capabilities.SupportsDelayedStackTraceLoading","kind":8,"location":{"uri":"file:///Users/hakim/projects/delve/vendor/github.com/google/go-dap/schematypes.go","range":{"start":{"line":1633,"character":1},"end":{"line":1633,"character":33}}},"containerName":"github.com/google/go-dap"}]

</details>

(I also noticed `globPattern` in `client/registerCapabilities` request includes the `vendor` directory but not sure if that's an intended behavior).


@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 Oct 13, 2021
@gopherbot gopherbot added this to the Unreleased milestone Oct 13, 2021
@hyangah
Copy link
Contributor Author

hyangah commented Oct 13, 2021

Related: VS Code has search.exclude which I think vscode-go needs to do necessary plumbing assuming gopls won't process vscode's search.exclude once gopls provides an option to specify this behavior.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/on-deck Oct 14, 2021
@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 14, 2021
@pjweinb
Copy link

pjweinb commented Oct 21, 2021

Does there need to be a separate option, or could 'directoryFilters' be used for workspace/symbol too?

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/359514 mentions this issue: /internal/lsp/source: apply directory filters to workspace symbols

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. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. 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