about summary refs log tree commit diff
path: root/docs/dev
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-05-22 15:33:12 +0000
committerGitHub <noreply@github.com>2020-05-22 15:33:12 +0000
commit2a36a2a3cc016de61a5df3165037ed689f36c423 (patch)
treebc08c40bd490c35a76bfd6849b6c372f0ab8311a /docs/dev
parent0fb71349156619e26a15ae21d7730eb9ce020446 (diff)
parent2075e77ee5784e72396c64c9ca059763508219ff (diff)
downloadrust-2a36a2a3cc016de61a5df3165037ed689f36c423.tar.gz
rust-2a36a2a3cc016de61a5df3165037ed689f36c423.zip
Merge #4569
4569: CodeAction groups r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Diffstat (limited to 'docs/dev')
-rw-r--r--docs/dev/lsp-extensions.md49
1 files changed, 47 insertions, 2 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index 7c45aef4c1a..d90875f8bd2 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -5,7 +5,7 @@ It's a best effort document, when in doubt, consult the source (and send a PR wi
 We aim to upstream all non Rust-specific extensions to the protocol, but this is not a top priority.
 All capabilities are enabled via `experimental` field of `ClientCapabilities`.
 
-## `SnippetTextEdit`
+## Snippet `TextEdit`
 
 **Client Capability:** `{ "snippetTextEdit": boolean }`
 
@@ -36,7 +36,7 @@ At the moment, rust-analyzer guarantees that only a single edit will have `Inser
 * Where exactly are `SnippetTextEdit`s allowed (only in code actions at the moment)?
 * Can snippets span multiple files (so far, no)?
 
-## `joinLines`
+## Join Lines
 
 **Server Capability:** `{ "joinLines": boolean }`
 
@@ -119,3 +119,48 @@ SSR with query `foo($a:expr, $b:expr) ==>> ($a).foo($b)` will transform, eg `foo
 
 * Probably needs search without replace mode
 * Needs a way to limit the scope to certain files.
+
+## `CodeAction` Groups
+
+**Client Capability:** `{ "codeActionGroup": boolean }`
+
+If this capability is set, `CodeAction` returned from the server contain an additional field, `group`:
+
+```typescript
+interface CodeAction {
+	title: string;
+    group?: string;
+    ...
+}
+```
+
+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 as
+
+```
+💡
+  +-------------+
+  | foo         |
+  +-------------+-----+
+  | frobnicate >| bar |
+  +-------------+-----+
+                | baz |
+                +-----+
+```
+
+Alternatively, selecting `frobnicate` could present a user with an additional menu to choose between `bar` and `baz`.
+
+### Example
+
+```rust
+fn main() {
+    let x: Entry/*cursor here*/ = todo!();
+}
+```
+
+Invoking code action at this position will yield two code actions for importing `Entry` from either `collections::HashMap` or `collection::BTreeMap`, grouped under a single "import" group.
+
+### Unresolved Questions
+
+* Is a fixed two-level structure enough?
+* Should we devise a general way to encode custom interaction protocols for GUI refactorings?