Skip to content

Commit e4af9f6

Browse files
committed
Reorgonise extensions docs
1 parent d1ff014 commit e4af9f6

File tree

1 file changed

+50
-48
lines changed

1 file changed

+50
-48
lines changed

docs/dev/lsp-extensions.md

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
This document describes LSP extensions used by rust-analyzer.
44
It's a best effort document, when in doubt, consult the source (and send a PR with clarification ;-) ).
55
We aim to upstream all non Rust-specific extensions to the protocol, but this is not a top priority.
6-
All capabilities are enabled via `experimental` field of `ClientCapabilities`.
6+
All capabilities are enabled via `experimental` field of `ClientCapabilities` or `ServerCapabilities`.
7+
Requests which we hope to upstream live under `experimental/` namespace.
8+
Requests, which are likely to always remain specific to `rust-analyzer` are under `rust-analyzer/` namespace.
79

810
## Snippet `TextEdit`
911

@@ -38,6 +40,53 @@ At the moment, rust-analyzer guarantees that only a single edit will have `Inser
3840
* Where exactly are `SnippetTextEdit`s allowed (only in code actions at the moment)?
3941
* Can snippets span multiple files (so far, no)?
4042

43+
## `CodeAction` Groups
44+
45+
**Issue:** https://github.com/microsoft/language-server-protocol/issues/994
46+
47+
**Client Capability:** `{ "codeActionGroup": boolean }`
48+
49+
If this capability is set, `CodeAction` returned from the server contain an additional field, `group`:
50+
51+
```typescript
52+
interface CodeAction {
53+
title: string;
54+
group?: string;
55+
...
56+
}
57+
```
58+
59+
All code-actions with the same `group` should be grouped under single (extendable) entry in lightbulb menu.
60+
The set of actions `[ { title: "foo" }, { group: "frobnicate", title: "bar" }, { group: "frobnicate", title: "baz" }]` should be rendered as
61+
62+
```
63+
💡
64+
+-------------+
65+
| foo |
66+
+-------------+-----+
67+
| frobnicate >| bar |
68+
+-------------+-----+
69+
| baz |
70+
+-----+
71+
```
72+
73+
Alternatively, selecting `frobnicate` could present a user with an additional menu to choose between `bar` and `baz`.
74+
75+
### Example
76+
77+
```rust
78+
fn main() {
79+
let x: Entry/*cursor here*/ = todo!();
80+
}
81+
```
82+
83+
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.
84+
85+
### Unresolved Questions
86+
87+
* Is a fixed two-level structure enough?
88+
* Should we devise a general way to encode custom interaction protocols for GUI refactorings?
89+
4190
## Join Lines
4291

4392
**Issue:** https://github.com/microsoft/language-server-protocol/issues/992
@@ -123,50 +172,3 @@ SSR with query `foo($a:expr, $b:expr) ==>> ($a).foo($b)` will transform, eg `foo
123172

124173
* Probably needs search without replace mode
125174
* Needs a way to limit the scope to certain files.
126-
127-
## `CodeAction` Groups
128-
129-
**Issue:** https://github.com/microsoft/language-server-protocol/issues/994
130-
131-
**Client Capability:** `{ "codeActionGroup": boolean }`
132-
133-
If this capability is set, `CodeAction` returned from the server contain an additional field, `group`:
134-
135-
```typescript
136-
interface CodeAction {
137-
title: string;
138-
group?: string;
139-
...
140-
}
141-
```
142-
143-
All code-actions with the same `group` should be grouped under single (extendable) entry in lightbulb menu.
144-
The set of actions `[ { title: "foo" }, { group: "frobnicate", title: "bar" }, { group: "frobnicate", title: "baz" }]` should be rendered as
145-
146-
```
147-
💡
148-
+-------------+
149-
| foo |
150-
+-------------+-----+
151-
| frobnicate >| bar |
152-
+-------------+-----+
153-
| baz |
154-
+-----+
155-
```
156-
157-
Alternatively, selecting `frobnicate` could present a user with an additional menu to choose between `bar` and `baz`.
158-
159-
### Example
160-
161-
```rust
162-
fn main() {
163-
let x: Entry/*cursor here*/ = todo!();
164-
}
165-
```
166-
167-
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.
168-
169-
### Unresolved Questions
170-
171-
* Is a fixed two-level structure enough?
172-
* Should we devise a general way to encode custom interaction protocols for GUI refactorings?

0 commit comments

Comments
 (0)