- Notifications
You must be signed in to change notification settings - Fork 850
Description
VS Code Go uses gopls for most of the language features, but there are a few features that still require 3rd party tools. We propose to migrate those features to gopls, reduce dependency on third party tools further, and improve security, reliability, usability and maintainability of the plugin.
This is a uber-issue to keep track of the progress and track glue work. Contribution/help is welcome!
Recently @marwan-at-work replaced use of gopkgs for the go.import.add command with custom commands implemented inside gopls. See the followings as inspiration:
- gopls: custom command implementation
- vscode-go: switching between gopls & gopkgs
https://github.com/golang/vscode-go/blob/master/src/goToolsInformation.ts has the full list of tools that can be used by the plugin.
-
gopkgs: tools: replace use of 'gopkgs' with 'go list all' #258
- Function: implements go.browse.packages
- gopkgs is used to retrieve all known packages and create a QuickPick list, from which the user can select a package to browse.
gopkgs -format '{{.Name}};{{.ImportPath}};{{.Dir}}'
- Proposal: use gopls's
gopls.list_known_packages
-
go-outline: tools: replace
go-outlinewithgopls#1020- Function: implements GoDocumentSymbolProvider used by the followings
- References codelens (used to place the codelens to each function) - this can be replaced with gopls's DocumentSymbol
- go.generate.tests (used to find the current function name at cursor) - this can be replaced with gopls's DocummentSymbol
- Run Test / Debug Test codelens (getTestFunctions, getBenchmarkFunctions, getCodeLensForPackage)
- Codelenses for standard tests can be replaced with gopls
- Handling 3rd-party test framework needs gopls’s document symbol + list of imports (go list)
- Proposal:
- Step 1: Replace
GoDocumentSymbolProviderimplementation with a modified gopls documentSymbol, by amending the list of imports, and leave all the code untouched until gopls implements all the code lenses and go.generate.tests natively (x/tools/gopls: supply imported package names in documentSymbol results go#40514 (comment)) - Step 2: Implement codelens and
go.generate.testsfrom gopls natively and get rid ofGoDocumentSymbolProvider.
- Step 1: Replace
- Note: minimize conflicts with the outstanding TestAPI work.
- Function: implements GoDocumentSymbolProvider used by the followings
-
guru: x/tools/gopls: add codelens to show number of references to each symbol go#40862
- Function: implements References codelens
- Proposal: implement reference code lens from gopls
- NOTE: we are removing the current guru-based feature in Remove the broken
referencescodelens #2509
-
gomodifytags: tools: merge
gomodifytagsfunctionality intogoplsand usegopls#2002- Function: modify tags on structs (go.add.tags, go.remove.tags commands)
- Proposal:
- Option 1: do nothing and keep using fatih’s
gomodifytags. - Option 2: implement from gopls
- check if there is any reusable code if gomodifytags is refactored and discuss with fatih if so
- Option 1: do nothing and keep using fatih’s
-
goplay
- Function: publish the code in the current editor to the Go playground (
go.playgroundcommand) - Proposal: implement from the extension or gopls. We can also consider adding the playground’s new go.mod file support.
- Function: publish the code in the current editor to the Go playground (
-
impl: x/tools/gopls: generate method stubs for a given interface go#37537
- Function: generate stubs for interfaces. (
go.impl.cursorcommand) - Actual Implementation: alternative implemented using code action
*Proposal: implement from gopls - two new commandsgopls.list_known_interfaces- Similar to workspace symbol, but returns only interfaces (see Add Package/Interface Dropdowns to Generate Interface Stubs Command #1547 (comment)).
- Q: ranking based on locality?
- Similar to workspace symbol, but returns only interfaces (see Add Package/Interface Dropdowns to Generate Interface Stubs Command #1547 (comment)).
gopls.generate_interface_stubs- Input: current cursor, document URI, interface name, optional receiver type name
- Output: text edit (snippet)
- Function: generate stubs for interfaces. (
-
gotests: tools: migrate test generation features to
gopls#1594- Function: Generate unit tests (go.test.generate.package, go.test.generate.file, go.test.generate.function commands)
- Proposal:
- Implement from gopls (note: gopls can import the gotests package)
gopls.generate_tests- Input: package directory, optional function name, …
- Output: text edit
- Note: make sure to handle
go.generateTestsFlagsand env vars (GOTEST_TEMPLATE_DIR,GOTEST_TEMPLATE)
- Refactor/standardize the logic that determines whether gopls is active and gopls implements the feature.
- Update
isImportant,replacedByGoplsinfo in the tools list