-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: disable code actions from gopls #68783
Comments
cc @adonovan |
Such control is supported directly by the Language Server Protocol: a CodeAction request has a field, I'll leave this issue open to address the question of whether the new defaults are inappropriate for a significant fraction of our users. |
@xtrats which editor and LSP client are you using? In VS Code, these actions are less obtrusive, only appearing in the nested source action menu. It may be that they are more distracting in your editor than in others. |
I'm using neovim v0.10.1 with "neovim/nvim-lspconfig" plugin, using the "glepnir/lspsaga.nvim" and "aznhe21/actions-preview.nvim" plugins to discover and preview code actions. |
One possibility is for us to reduce the number of code actions that gopls offers based on cursor location alone, and instead require the user to select a non-empty region of text (e.g. an identifier or part of one) before offering code actions such as source.doc and source.assembly. I wonder whether there are any established UI conventions we can rely on here. |
Change https://go.dev/cl/604818 mentions this issue: |
This change causes all CodeActions returned by gopls to use a specific leaf type such as refactor.inline.call, instead of a general category such as refactor or refactor.inline. The categories may continue to be specified in the "Only" parameter of a CodeActions request, and they apply hierarchically. This allows clients to be more specific in requesting a particular Code Action. Details of golang/codeaction.go (messy diff): - don't separate "typed" from "syntax only" operations; in practice we always need types. - enabled (func) replaces want (map). It is computed in server.CodeAction and plumbed down. - the "add" helper wraps a Command in a CodeAction and adds it to the result. Also: - use camelCase names, following LSP's source.organizeImports. - document the specific kinds in the user manual and add a release note. - remove the CodeAction title regexp parameter from @codeaction{,err} marker tests since the kind is now sufficiently expressive. Fixes golang/go#40438 Updates golang/go#68791 Updates golang/go#68783 Change-Id: I1898f79d8af441a0376ad5067d05e0621840d987 Reviewed-on: https://go-review.googlesource.com/c/tools/+/604818 Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Change https://go.dev/cl/616837 mentions this issue: |
Maybe code actions fire from visual select should return all kinds? the new commit makes This is the param it sends to gopls, missing
|
That's surprising; the missing "only" and the triggerKind=1 (invoked) should cause the server to return all code actions. I will investigate. |
Ah, sorry, ignore this, I'm running an outdated branch.. |
gopls version
go env
What did you do?
There are two code actions from
gopls
on every single line of the source code, which will drown out the truly useful ones:What did you see happen?
Refer to the previous section.
What did you expect to see?
I would like to be able to disable certain specific code actions of gopls through configuration.
Editor and settings
No response
Logs
No response
The text was updated successfully, but these errors were encountered: