x/tools/gopls: add gopls.package_symbols command #51492
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
gopls version
go env
What did you do?
I'm developing a vim/neovim plugin that need to retrieve the all the tests of the current package. I would also want to list all the methods of the struct under the cursor.
What work around did you consider?
I tried using
DocumentSymbols
query to retrieve all the symbols in the current package, then I filter it down. But this doesn't cover methods or tests defined in another file of the same package.I also tried using the
WorkspaceSymbols
query and use the package name as prefix, but the package name is not the full import, so the symbols returned could be from another package. E.g. I have agithub.com/jackieli-tes/errors.Is
and if I filter workspace symbols by^errors.Is
it returns the std'serrors.Is
What solution do you want to see?
If #37237 is implemented. I believe all of the above problem should be solved.
Alternatively, most of the queries I'd like to have are all package related. So I propose adding and lsp command:
Identifier:
gopls.package_symbols
Query the package symbols of the package a given go file belongs to.
Args:
The
Query
can be an exact match or the same as theWorkspaceSymbols
query syntax: https://github.com/golang/tools/blob/master/gopls/doc/features.md#symbol-queriesResult:
Result should be same as WorkspaceSymbol[]
Editor and settings
I'm using neovim 0.6.1 with coc.nvim. Using the default instruction from editor section
The text was updated successfully, but these errors were encountered: