-
-
Notifications
You must be signed in to change notification settings - Fork 370
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
Use custom CodeActionKind
s to support client-side filtering
#1458
Comments
It also occurred to me that the "Apply all hints" action is rather odd: arguably this should be something the client could do generically for a particular code action kind (if we put hlints in |
VScode can apply all the code actions of the kinds that you select (in configuration), on save. It would be great if we enriched our code actions with kind metadata so that we could, for example, insert all the missing imports on save. |
@isovector for the wingman stuff, the following kinds would probably be useful
|
I would suggest nesting them somewhat, maybe something like |
Wow, this is a great improvement in wingman. I'd suggest we also add kinds to the import code actions, so that people can only see the imports for their favorite styles. |
@michaelpj that is a really great idea, many thanks for the suggestion, will do for hlint asap |
Could we made up such document in this pr, adding the code actions with kind informed and which have to be added? Taking as base the starting point in #1570 (comment) by @michaelpj |
TODOS:
|
@michaelpj I started looking over code action kinds and their usages. Here my current findings. Code Action KindsDefined in https://hackage.haskell.org/package/lsp-types-1.5.0.0/docs/Language-LSP-Types.html
|
J.InR $ J.CodeAction title (Just J.CodeActionQuickFix) (Just (J.List [])) Nothing Nothing (Just edit) Nothing Nothing |
or disabling an hlint rule for the whole file
, Just (mkCodeAction suppressHintTitle diagnostic (Just suppressHintWorkspaceEdit) Nothing) |
CodeActionSourceOrganizeImports
Could be interesting for "remove (all) unused imports" (ghcide)
CodeActionUnknown
This is currently in use to express details, but if or how the given information is leveraged.
"quickfix.import.refine"
"quickfix.literals.style"
"refactor.wingman.<x>"
Great, thanks!
Honestly, the intended meaning of these kinds is very unclear :/ I wonder if we can look at what other people do to figure out a sensible rubric? For pragmas, I think it makes sense to keep them as a quickfix since it's an action that appears in response to a diagnostic, i.e. it fixes a compilation error.
Maybe? Apply all hints might also fit!
I think that's the correct way to do it. The If anything, I think we should use this more, and that was what the ticket was originally about. If we can group the code actions we provide nicely using hierarchical kinds, then on the client side it's relatively easy for someone to have e.g. a keybinding to trigger a specific code action or subgroup of code actions (e.g. people have asked for this for the wingman code actions quite a few times). |
Thanks, this is very interesting. Judging from the constructor name I assumed
|
I'm revamping
Well, I think it's not 100% clear what "organizing imports" would entail. As you say, we have several actions that do part of that, but tastes differ. I would expect "organize imports" to do some or all of:
Hard to say, really! At the moment we provide a bunch of such actions, and if you triggered them all with |
The
CodeActionKind
enum is actually an open enumeration of strings. There's nothing stopping us from adding our own kinds.The main advantage of this is if we want to do some client-side filtering this is a much nicer thing to use than, say, matching on the action title.
We might also want plugins to tell us about custom kinds they support so that we can return the set that we use in
CodeActionOptions
.Real-world usecase: emacs-lsp/lsp-haskell#112 (comment)
The text was updated successfully, but these errors were encountered: