Skip to content

x/tools/gopls: option to exclude vendor from suggested symbols or symbols from vendored tools #73493

@hu3bi

Description

@hu3bi

Is your feature request related to a problem? Please describe.

Right now, you can set the following preference only to workspace or all.

"gopls": {
        "ui.navigation.symbolScope": "workspace",
}

symbolScope controls which packages are searched for workspace/symbol requests. When the scope is "workspace", gopls searches only workspace packages. When the scope is "all", gopls searches all loaded packages, including dependencies and the standard library.

workspace: "workspace" matches symbols in workspace packages only.

This can be inconvenient, excluding a vendor directory from symbol indexing also prevents symbols from the standard library from being suggested, which is undesirable behavior.
Especially frustrating in combination with the new go tool directive.
Having the following in the go.mod suggests a lot of symbols from my tools as well.

tool (
	github.com/a-h/templ/cmd/templ
	github.com/air-verse/air
	go.uber.org/nilaway/cmd/nilaway
	golang.org/x/tools/cmd/deadcode
	golang.org/x/tools/cmd/godoc
	golang.org/x/vuln/cmd/govulncheck
	mvdan.cc/gofumpt
)

Describe the solution you'd like
Add a 3rd property, that searches all loaded packages, including dependencies, the standard library but excluding vendor.

Describe alternatives you've considered
Option to pass in an array of properties of what should be matched.

Available properties would have to be determined.

Example:

"gopls": {
        "ui.navigation.symbolScope": [
                 "std-lib",
                 "vendor",
                 "tools",  // ⇐ don't really think anyone would want that
                 "workspace",
                 ...
}

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions