Open matklad opened 4 years ago
What's the motivation for this over just having frobicate Bar
and frobnicate Baz
as options?
Just having two options wouldn't be too bad, and that's what clients not supporting groups get!
However, grouping has two benefits:
I almost feel like this could be solved using some clever display logic around the hierarchical nature of CodeActionKind
.
@kjeremy good point. VS Code for example allows triggering Source and Refactor actions via a separate menu action.
However making this explicit most of the time results in better UI in the longer term.
Would the second level be resolved only once the user accesses it?
I propose adding the ability for servers to:
Then a code action command would trigger the server ask the user for an option. This seems more flexible than code action groups.
VS already supports code action group. it would be nice to include this in LSP so that we can use group at least in VS. and ask for group support in vscode.
for example, LSP has streaming support that we use in VS, but vscode doesn't support it yet (except in a few places I believe)
by the way, here is how API looks like in VS - https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.language.intellisense.isuggestedaction?view=visualstudiosdk-2022
basically, each code action can be invoked (executed) or/and can return nested actions.
Another general protocol extension poached from rust-analyzer
CodeAction
GroupsClient Capability:
{ "codeActionGroup": boolean }
If this capability is set,
CodeAction
returned from the server contain an additional field,group
:All code-actions with the same
group
should be grouped under single (extendable) entry in lightbulb menu. The set of actions[ { title: "foo" }, { group: "frobnicate", title: "bar" }, { group: "frobnicate", title: "baz" }]
should be rendered asAlternatively, selecting
frobnicate
could present a user with an additional menu to choose betweenbar
andbaz
.Example
Invoking code action at this position will yield two code actions for importing
Entry
from eithercollections::HashMap
orcollection::BTreeMap
, grouped under a single "import" group.Unresolved Questions
IntelliJ variation: