-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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 go.mod files #31999
Comments
Noting a specific comment that in #35820 we report that changes to |
Change https://golang.org/cl/210557 mentions this issue: |
Change https://golang.org/cl/210757 mentions this issue: |
When the go.mod file changes, we should invalidate all the files that are contained in the package for the mod file. This will allow the files to recheck their packages in case new packages were added in the go.mod file. This still does not fix issue where changes to go.mod files do not trigger recalculation of diagnostics. Updates golang/go#31999 Change-Id: I6d8f1531f5c28ed2dca7fb8ad4ee0317fada787b Reviewed-on: https://go-review.googlesource.com/c/tools/+/210557 Run-TryBot: Rohan Challa <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
When we are processing a go.mod file, we are calling go/packages.load when we should not be. It will always return 0 packages since it is not a .go file. This CL adds branching inside each internal/lsp protocol function and also adds a check in snapshot.PackageHandles for the file type and returns an error. This will prevent `go list` from running on go.mod files for now. Updates golang/go#31999 Change-Id: Ic6d0e9b7c81e1f404342b98e10b9c5387adde2ee Reviewed-on: https://go-review.googlesource.com/c/tools/+/210757 Reviewed-by: Rebecca Stambler <[email protected]> Run-TryBot: Rohan Challa <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
Change https://golang.org/cl/211303 mentions this issue: |
…od files This is the first step to surfacing potential fixes and suggestions to a user's go.mod file. Specifically, it will show a warning if you have a dependency that is not used, or if a dependency is declared as indirect when it should be direct and vice versa. This CL adds functionality for version of Go that are >= 1.14. Updates golang/go#31999 Change-Id: Id60fa0ee201dcd843f62e2659dda8e795bd671db Reviewed-on: https://go-review.googlesource.com/c/tools/+/211937 Run-TryBot: Rohan Challa <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
This change will surface errors that come from the mod package. It will handle incorrect usages, invalid directives, and other errors that occur when parsing go.mod files. Updates golang/go#31999 Change-Id: Icd817c02a4b656b2a71914ee60be4dbe2bea062d Reviewed-on: https://go-review.googlesource.com/c/tools/+/213779 Run-TryBot: Rohan Challa <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
Change https://golang.org/cl/214699 mentions this issue: |
This change adds a protocol.ColumnMapper when parsing go.mod files. This will prevent us from having to worry about line and column offsets, specifically when converting from the x/mod/modfile position to a span.Span. Updates golang/go#31999 Change-Id: Iacdfb42d61dfea9b5f70325cf5a87c9575f8f345 Reviewed-on: https://go-review.googlesource.com/c/tools/+/214699 Run-TryBot: Rohan Challa <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
This change adds quickfixes for unused dependencies and dependencies that should not be marked as indirect. It also updates the positions for the diagnostics to make more sense relative to the warning message. There is a testing harness now for suggested fixes. Updates golang/go#31999 Change-Id: I0db3382bf892fcc2d9ab3b633020d9167a0ad09b Reviewed-on: https://go-review.googlesource.com/c/tools/+/213917 Run-TryBot: Rohan Challa <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
Change https://golang.org/cl/214700 mentions this issue: |
Change https://golang.org/cl/215021 mentions this issue: |
This change creates the infrastructure for caching diagnostics. Right now it uses a naive key of the entire snapshot which does not really add any benefit from using the cache. It also moves some code from inside the internal/lsp/mod to internal/lsp/cache. Updates golang/go#31999 Change-Id: I599ad281baa062448d33ca0ea88ae6e09e10d73e Reviewed-on: https://go-review.googlesource.com/c/tools/+/215021 Run-TryBot: Rohan Challa <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
This change sets up the infrastructure to surface the dependencies that are missing in a go.mod file. In a follow up CL, we will use these to add diagnostics to the imports of .go files telling the user to add the dependency to their go.mod file. Updates golang/go#31999 Change-Id: I697df0d7c6eabfdc2f0c75cb36aa35794647fd13 Reviewed-on: https://go-review.googlesource.com/c/tools/+/214700 Reviewed-by: Rebecca Stambler <[email protected]> Run-TryBot: Rohan Challa <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
Change https://golang.org/cl/216277 mentions this issue: |
This change adds diagnostics to imports in .go files that are missing the dependency in the go.mod file. The quick fix that adds the appropriate require statement is coming in a follow up CL. Updates golang/go#31999 Change-Id: I314cdbe8e3dd27da744ca0391e7a6e5dc1ebaa77 Reviewed-on: https://go-review.googlesource.com/c/tools/+/216277 Run-TryBot: Rohan Challa <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
Change https://golang.org/cl/215898 mentions this issue: |
This change adds quick fixes for diagnostics in .go files, specifically for diagnostics that deal with imported packages that are not declared in the go.mod file. These quick fixes will automatically add the dependency in the go.mod file and format the file if there are any issues. Updates golang/go#31999 Change-Id: Iab151ce96194fae4b1995859aec416c5473da6e3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/215898 Run-TryBot: Rohan Challa <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
@ridersofrohan: Do you think we can close this issue? |
I think we can 😃 |
I'll let you do the honors 🎉 |
@stamblerre Was automatic detection of the local module ever implemented, both this and the referenced issue are closed. P.S. That's kind of a missing thing in the stock goimports, most editors just run it without flags and you have to specifically customize the editor configuration to pass the flag which is obviously different for different projects, it doesn't have a config file or detection logic for it, which is annoying. |
@segevfiner: This issue refers to adding support for various features for As for |
I was specifically complaining about standalone goimports not supporting automatic detection of the local import prefix, requiring to supply I think the issue you linked is about figuring out module roots independent of editor workspace folder roots? |
Context: Beginning of #31712.
Some other features that fall under the umbrella of this issue:
textDocument/documentLink
taking the user to the exact version of their dependency (x/tools/gopls: support pkg.go.dev in textDocument/documentLink #35563).The text was updated successfully, but these errors were encountered: