diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-19 19:29:46 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-19 19:29:46 +0100 |
commit | 1bc1f28bc58b2dbcf8f8f548c277e2c90e3075cd (patch) | |
tree | 7d059b65919b1b64196cc3fc6830eeb99f2f9af0 /docs/dev | |
parent | 131849f2abd94dc8143f0c5d65e022136f29561a (diff) | |
parent | 3e9bf7ebabdaa8e9a2972af2dd8e8089a3a0341e (diff) |
Merge #4494
4494: Support snippet text edit r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'docs/dev')
-rw-r--r-- | docs/dev/lsp-extensions.md | 34 |
1 files changed, 34 insertions, 0 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`. | ||