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: support LSP language features for go.mod files #36501

Closed
stamblerre opened this issue Jan 10, 2020 · 9 comments
Closed

x/tools/gopls: support LSP language features for go.mod files #36501

stamblerre opened this issue Jan 10, 2020 · 9 comments
Labels
FrozenDueToAge 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

@stamblerre
Copy link
Contributor

This is a subset of #31999, but I felt it was useful to break it out. Some features worth considering (please add more here as they come up):

  • textDocument/documentLink: Clicking on a dependency could take you to the discovery site.

/cc @ridersofrohan

@gopherbot gopherbot added this to the Unreleased milestone Jan 10, 2020
@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 Jan 10, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls unplanned Jan 13, 2020
@ridersofrohan ridersofrohan self-assigned this Jan 14, 2020
@stamblerre stamblerre modified the milestones: gopls unplanned, gopls/v1.0.0 Jan 29, 2020
@stamblerre
Copy link
Contributor Author

Following up on some discussions today:

  • go list -m -u can be used to determine possible module upgrades. These can be offered to the user as a code lens, to avoid surfacing a potentially bothersome diagnostic.
  • go/packages runs go list -m, but it doesn't provide any of these modules to the caller. Add an internal only field that gopls can access, much in the same way as we have done for the forTest field in metadata. See golang.org/x/tools/internal/lsp/cache/load.go for how that field set in gopls, and https://pkg.go.dev/golang.org/x/tools/internal/packagesinternal and golang.org/x/tools/go/packages/golist.go for how that field is set.
  • textDocument/hover can be used to surface the output of go mod why on a dependency.

@gopherbot
Copy link

Change https://golang.org/cl/218557 mentions this issue: internal/lsp: add codelens for go.mod dependency upgrades

@gopherbot
Copy link

Change https://golang.org/cl/219079 mentions this issue: internal/lsp: add versions from go.mod to pkg.go.dev links

gopherbot pushed a commit to golang/tools that referenced this issue Feb 14, 2020
This change adds a code lens for go.mod files that will let a user know if a module can be upgraded, once it is clicked gopls will run a command to update that module.

Updates golang/go#36501

Change-Id: Id22b8097ede4972cf73bc029ec927544a71b7150
Reviewed-on: https://go-review.googlesource.com/c/tools/+/218557
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/219938 mentions this issue: internal/lsp: support textDocument/documentLink for .mod extension

gopherbot pushed a commit to golang/tools that referenced this issue Feb 19, 2020
This change appends to the pkg.go.dev link the version of the module that is being used. To get this functionality, go/packages.Package now contains a module field which gets populated from the "go list" call. This module field is then used to get the version of the module that we are linking to.

Updates golang/go#36501

Change-Id: I9668a6da0fd3ec8f4cde017986419c8d28196765
Reviewed-on: https://go-review.googlesource.com/c/tools/+/219079
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/220359 mentions this issue: internal/lsp: support textDocument/hover for .mod extension

gopherbot pushed a commit to golang/tools that referenced this issue Feb 26, 2020
This change implements support for textDocument/documentLink when it comes to go.mod files.

Updates golang/go#36501

Change-Id: Ic0974e3e858dd1c8df54b7d7abee085bbcb6d4ee
Reviewed-on: https://go-review.googlesource.com/c/tools/+/219938
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
gopherbot pushed a commit to golang/tools that referenced this issue Feb 26, 2020
This change implements support for textDocument/hover when it comes to go.mod files.

Updates golang/go#36501

Change-Id: Ie7da0194bb972955b7ab9cf7b9c9972bd9f4b8a9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/220359
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/221108 mentions this issue: internal/lsp: add an upgrade all dependencies codelens

@gopherbot
Copy link

Change https://golang.org/cl/221223 mentions this issue: internal/lsp: support textDocument/formatting for .mod extension

gopherbot pushed a commit to golang/tools that referenced this issue Mar 2, 2020
This change adds an upgrade all dependencies codelens on the go.mod file if there are available upgrades.

Updates golang/go#36501

Change-Id: I86c1ae7e7a6dc01b7f5cd7eb18e5a11d96a3acc1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221108
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
gopherbot pushed a commit to golang/tools that referenced this issue Mar 6, 2020
This change implements support for textDocument/formatting when it comes to go.mod files. It also adds formatting on save ability.

To enable formatting on save for go.mod files, you need to include the following settings inside of your VSCode settings.json:

...
"[go.mod]": {
	"editor.codeActionsOnSave": {
		"source.organizeImports": true,
	},
	"editor.formatOnSave": true,
},
...

Updates golang/go#36501

Change-Id: I60ac14d0e99b2b086fe9a8581770771aafc2173c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221223
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@stamblerre
Copy link
Contributor Author

@ridersofrohan: Can we close this, or are there any more features remaining? The only thing that comes to mind is folding range.

@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.4.0 Mar 12, 2020
@ridersofrohan
Copy link

I think we can close it. I don't know how useful folding range would be considering there are only 4 directives for go.mod files.

@golang golang locked and limited conversation to collaborators Mar 12, 2021
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. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants