aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-05-21 19:05:58 +0100
committerGitHub <[email protected]>2020-05-21 19:05:58 +0100
commit59732df8d40dfadc6dcf5951265416576399712a (patch)
tree5accb5fce10496334b49ed5a823d321572b375b4 /docs
parentba6cf638fbf3d0a025e804f2d354d91abc8afd28 (diff)
parent5b5ebec440841ee98a0aa70b71a135d94f5ca077 (diff)
Merge #4557
4557: Formalize JoinLines protocol extension r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'docs')
-rw-r--r--docs/dev/lsp-extensions.md66
1 files changed, 59 insertions, 7 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index d2ec6c021..0e3a0af1c 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -7,13 +7,7 @@ All capabilities are enabled via `experimental` field of `ClientCapabilities`.
7 7
8## `SnippetTextEdit` 8## `SnippetTextEdit`
9 9
10**Capability** 10**Client Capability:** `{ "snippetTextEdit": boolean }`
11
12```typescript
13{
14 "snippetTextEdit": boolean
15}
16```
17 11
18If this capability is set, `WorkspaceEdit`s returned from `codeAction` requests might contain `SnippetTextEdit`s instead of usual `TextEdit`s: 12If this capability is set, `WorkspaceEdit`s returned from `codeAction` requests might contain `SnippetTextEdit`s instead of usual `TextEdit`s:
19 13
@@ -32,3 +26,61 @@ export interface TextDocumentEdit {
32 26
33When applying such code action, the editor should insert snippet, with tab stops and placeholder. 27When applying such code action, the editor should insert snippet, with tab stops and placeholder.
34At the moment, rust-analyzer guarantees that only a single edit will have `InsertTextFormat.Snippet`. 28At the moment, rust-analyzer guarantees that only a single edit will have `InsertTextFormat.Snippet`.
29
30### Example
31
32"Add `derive`" code action transforms `struct S;` into `#[derive($0)] struct S;`
33
34### Unresolved Questions
35
36* Where exactly are `SnippetTextEdit`s allowed (only in code actions at the moment)?
37* Can snippets span multiple files (so far, no)?
38
39## `joinLines`
40
41**Server Capability:** `{ "joinLines": boolean }`
42
43This request is send from client to server to handle "Join Lines" editor action.
44
45**Method:** `experimental/JoinLines`
46
47**Request:**
48
49```typescript
50interface JoinLinesParams {
51 textDocument: TextDocumentIdentifier,
52 /// Currently active selections/cursor offsets.
53 /// This is an array to support multiple cursors.
54 ranges: Range[],
55}
56```
57
58**Response:**
59
60```typescript
61TextEdit[]
62```
63
64### Example
65
66```rust
67fn main() {
68 /*cursor here*/let x = {
69 92
70 };
71}
72```
73
74`experimental/joinLines` yields (curly braces are automagiacally removed)
75
76```rust
77fn main() {
78 let x = 92;
79}
80```
81
82### Unresolved Question
83
84* What is the position of the cursor after `joinLines`?
85 Currently this is left to editor's discretion, but it might be useful to specify on the server via snippets.
86 However, it then becomes unclear how it works with multi cursor.