-
Notifications
You must be signed in to change notification settings - Fork 18k
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: edit the go.mod with go commands whenever possible #38209
Comments
What does LSP flow look like? Will gopls send a save command to the client? |
I think we can just write the file to disk directly. Or, I guess there's also https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#workspace_applyEdit, but I'm not sure if the client will leave the file saved in that case. We want to make sure that the edit to the |
My concern around having It's possible that the client may cancel saving for some reason after Still there could be rare cases where file write access is not available (vscode live if we ever find a way to support it in the future?). |
I agree it's not ideal, but I think it would be a bit strange for the user if they have a "tidied" |
Thinking about this a bit more...the main issue is that we don't necessarily have the "correct" @jayconrod: Is there some way we can update the |
What if we provided a way from inside the editor to run I'm finding that I am doing that instead of using the in-editor support you added for updating What has been beautiful is, I don't need to run |
You could just add missing lines from the temporary Having a way to run |
Yes explicit from within the editor environment. Is adding a command to the context menu for the |
This has been available for some time. You can even configure it to run on save: "[go.mod]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true,
},
} @jayconrod: Thanks for the information. I'll play around with it and see how far I get. |
WHAT!!!!! I don't see that? |
It will only show up if your |
I am removing items from
That option is not showing up at all. However, eventually a save will bring those modules back in. |
However, I need to run a vendor because I use vendoring. This is all hidden :( It would be so much better as an option on the context menu if this is an option Tidy |
We could have it show up like the code lenses for upgrading dependencies, but then it wouldn't tidy on save, so we'd have the same command available in two places. Maybe we can still do that though. Vendoring we haven't really added any special support for. Is there any other behavior you'd like to have with vendoring? If there are more things maybe we can start a separate discussion for that on a new issue. |
I removed those settings because I think they are making things more confusing. If I had wish... The ability to right click on the If that is not possible, the ability to see a squiggly line on the module keyword in I think the goal is to present to the developer these options to tidy and vendor when they need to. Then they don't need to leave the editor to do it. Then gopls can know this operating is being executed explicitly by the developer. |
@jayconrod: Going back to the discussion of keeping the |
@stamblerre If you're talking about direct dependencies, then in general, this is not possible. This may be moot though after #36460 is implemented. All modules needed to build and test packages in the main module will be listed in |
I see, thanks for the clarification. I guess another way of implementing this would be some way to say "given this |
@heschik has suggested that we can do this with |
|
You could also copy |
We do this when we first need to initialize the workspace, but I don't think we can pay the cost of running this every time we want to update the Edit: I guess we do this with
The issue is we want to avoid |
After some more discussion offline, we've concluded that it's too expensive to run these
|
An alternative to textual edits of the |
Change https://golang.org/cl/265981 mentions this issue: |
Missed one, the |
Change https://golang.org/cl/267682 mentions this issue: |
We maintain a temporary
go.sum
file that is updated along with the temporarygo.mod
, but we never write it out. We should update the project's go.sum file whenever thego.mod
file is saved./cc @ridersofrohan to confirm that this approach sounds reasonable
/cc @ardan-bkennedy
The text was updated successfully, but these errors were encountered: