-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: Add a source code action to regenerate cgo definitions. #73482
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
Comments
This Because I think it would be best if the command have the exact same behavior as |
That would work for me, though my ideal solution is a quick action (the lightbulb) |
The correct name for quick action is quick pick or code action, which I believe could be provided directly from gopls. |
So the request here is to add a code action over any undefined C symbol, to regenerate cgo definitions. I'm not sure. Usually, the semantics for quick fixes is that they should have an (almost) guaranteed fix. In this case, the fix depends on C definitions. We could add a source action; since source actions are meant to apply to the current file, that would make sense. WDYT? |
CC @adonovan I don't think a quick fix is approprate, but either a wrapper command or source action would be reasonable. |
That's fine with me, I added a keybind for the source action command so that will solve my problem (being able to regenerate definitions easily). For my edification, what's the difference between source actions and code actions? Obviously vscode uses a different UI for them but if I were adding functionality to gopls it's not clear to me which I should use. Is the difference simply whether the action is attached to a specific line of code or symbol? |
A Code Action is the umbrella term for "a thing you can do to a selected piece of text"; the CodeAction request returns the set of available actions. According to the protocol spec, the |
Comment updated. Since this is about source code action, I have moved it to gopls milestone. |
Is your feature request related to a problem? Please describe.
I'm always annoyed when I'm writing Go that calls C and I have to scroll up to the top of the file to click
regenerate cgo definitions
whenever I use a C definition I haven't used previously.Describe the solution you'd like
When I type
C.FooBar
andFooBar
is not yet defined I'd like a quick action to appear so I can use [Ctrl]+. to easily regenerate cgo definitions.Describe alternatives you've considered
Adding a command to execute
regenerate cgo definitions
so I can bind that to a key sequence, but that command doesn't exist AFAIK.Additional context

The text was updated successfully, but these errors were encountered: