Navigation Menu

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: Find values by name without prefixing with the package name #58291

Open
dppascual opened this issue Feb 3, 2023 · 2 comments
Open
Labels
FeatureRequest 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

@dppascual
Copy link

gopls version

golang.org/x/tools/gopls v0.11.0
    golang.org/x/tools/gopls@v0.11.0 h1:/nvKHdTtePQmrv9XN3gIUN9MOdUrKzO/dcqgbG6x8EY=

go env

GO111MODULE="on"
GOARCH="amd64"
GOBIN="/Users/dppascual/go/bin"
GOCACHE="/Users/dppascual/Library/Caches/go-build"
GOENV="/Users/dppascual/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/dppascual/go/pkg/mod"
GONOPROXY="*.bbva.com,*.igrupobbva"
GONOSUMDB="*.bbva.com,*.igrupobbva"
GOOS="darwin"
GOPATH="/Users/dppascual/go"
GOPRIVATE="*.bbva.com,*.igrupobbva"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zg/tz2xtl3138bfl888yv2gc_600000gn/T/go-build3334315292=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Feature request

It would be nice, if gopls would support this Goland feature: You can easily find a value by its name without importing the package or prefixing with the package name. It allows you to identify, at a first sight, the value you are looking for, especially when you don't remember the package to which it belongs to.

Screenshot 2023-02-03 at 13 20 08

This functionality can be accomplished by searching for a symbol with the usage of the method workspace/symbol, and, once the required value is found and its corresponding package is identified, we are able to back to the editor and typing the package followed by the required value. However, this process is a little bit cumbersome and also we have a lack of documentation that the autocompletion system provides (if enabled) when we go down through all completion candidates.

What did you expect to see?

All fuzzy matches of exported functions or types from packages in the current workspace and std library.

What did you see instead?

gopls does not report any suggestion if I start typing the package's exported functions or types before importing the package or prefixing with the package name.

Editor and settings

Editor:

 nvim --version
NVIM v0.8.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.8.2/share/nvim"

Run :checkhealth for more info

gopls:

  gopls = {
    gopls = {
      -- buildFlags = { "-tags=debug" },
      -- ["local"] = "github.com/sourcegraph/sourcegraph",
      analyses = {
        unusedparams = true,
      },
      staticcheck = true,
      experimentalPostfixCompletions = true,
      hints = {
        parameterNames = true,
        assignVariableTypes = true,
        constantValues = true,
        rangeVariableTypes = true,
        compositeLiteralTypes = true,
        compositeLiteralFields = true,
        functionTypeParameters = true,
      },
    },
  },
@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 Feb 3, 2023
@gopherbot gopherbot added this to the Unreleased milestone Feb 3, 2023
@suzmue suzmue modified the milestones: Unreleased, gopls/later Feb 6, 2023
@suzmue
Copy link
Contributor

suzmue commented Feb 9, 2023

cc @findleyr

@muirdm
Copy link

muirdm commented Apr 15, 2023

This would be really cool. It would greatly increase the search space for completions, so we would probably need some performance work and/or search index to keep completion latency down in big modules.

@findleyr When all the pending architectural changes are done, will completion have access to typed exports for all packages in the workspace? Could we maintain a search index compatible with the fuzzy matcher semantics?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest 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