diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/dev/lsp-extensions.md | 34 | ||||
-rw-r--r-- | docs/user/assists.md | 10 |
2 files changed, 39 insertions, 5 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md new file mode 100644 index 000000000..d2ec6c021 --- /dev/null +++ b/docs/dev/lsp-extensions.md | |||
@@ -0,0 +1,34 @@ | |||
1 | # LSP Extensions | ||
2 | |||
3 | This document describes LSP extensions used by rust-analyzer. | ||
4 | It's a best effort document, when in doubt, consult the source (and send a PR with clarification ;-) ). | ||
5 | 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`. | ||
7 | |||
8 | ## `SnippetTextEdit` | ||
9 | |||
10 | **Capability** | ||
11 | |||
12 | ```typescript | ||
13 | { | ||
14 | "snippetTextEdit": boolean | ||
15 | } | ||
16 | ``` | ||
17 | |||
18 | If this capability is set, `WorkspaceEdit`s returned from `codeAction` requests might contain `SnippetTextEdit`s instead of usual `TextEdit`s: | ||
19 | |||
20 | ```typescript | ||
21 | interface SnippetTextEdit extends TextEdit { | ||
22 | insertTextFormat?: InsertTextFormat; | ||
23 | } | ||
24 | ``` | ||
25 | |||
26 | ```typescript | ||
27 | export interface TextDocumentEdit { | ||
28 | textDocument: VersionedTextDocumentIdentifier; | ||
29 | edits: (TextEdit | SnippetTextEdit)[]; | ||
30 | } | ||
31 | ``` | ||
32 | |||
33 | When applying such code action, the editor should insert snippet, with tab stops and placeholder. | ||
34 | At the moment, rust-analyzer guarantees that only a single edit will have `InsertTextFormat.Snippet`. | ||
diff --git a/docs/user/assists.md b/docs/user/assists.md index 692fd4f52..41c5df528 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md | |||
@@ -17,7 +17,7 @@ struct S; | |||
17 | struct S; | 17 | struct S; |
18 | 18 | ||
19 | impl Debug for S { | 19 | impl Debug for S { |
20 | 20 | $0 | |
21 | } | 21 | } |
22 | ``` | 22 | ``` |
23 | 23 | ||
@@ -33,7 +33,7 @@ struct Point { | |||
33 | } | 33 | } |
34 | 34 | ||
35 | // AFTER | 35 | // AFTER |
36 | #[derive()] | 36 | #[derive($0)] |
37 | struct Point { | 37 | struct Point { |
38 | x: u32, | 38 | x: u32, |
39 | y: u32, | 39 | y: u32, |
@@ -105,16 +105,16 @@ Adds a new inherent impl for a type. | |||
105 | ```rust | 105 | ```rust |
106 | // BEFORE | 106 | // BEFORE |
107 | struct Ctx<T: Clone> { | 107 | struct Ctx<T: Clone> { |
108 | data: T,┃ | 108 | data: T,┃ |
109 | } | 109 | } |
110 | 110 | ||
111 | // AFTER | 111 | // AFTER |
112 | struct Ctx<T: Clone> { | 112 | struct Ctx<T: Clone> { |
113 | data: T, | 113 | data: T, |
114 | } | 114 | } |
115 | 115 | ||
116 | impl<T: Clone> Ctx<T> { | 116 | impl<T: Clone> Ctx<T> { |
117 | 117 | $0 | |
118 | } | 118 | } |
119 | ``` | 119 | ``` |
120 | 120 | ||