about summary refs log tree commit diff
path: root/docs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-05-19 18:29:46 +0000
committerGitHub <noreply@github.com>2020-05-19 18:29:46 +0000
commit1bc1f28bc58b2dbcf8f8f548c277e2c90e3075cd (patch)
tree7d059b65919b1b64196cc3fc6830eeb99f2f9af0 /docs
parent131849f2abd94dc8143f0c5d65e022136f29561a (diff)
parent3e9bf7ebabdaa8e9a2972af2dd8e8089a3a0341e (diff)
downloadrust-1bc1f28bc58b2dbcf8f8f548c277e2c90e3075cd.tar.gz
rust-1bc1f28bc58b2dbcf8f8f548c277e2c90e3075cd.zip
Merge #4494
4494: Support snippet text edit r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/dev/lsp-extensions.md34
-rw-r--r--docs/user/assists.md10
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 00000000000..d2ec6c0215b
--- /dev/null
+++ b/docs/dev/lsp-extensions.md
@@ -0,0 +1,34 @@
+# LSP Extensions
+
+This document describes LSP extensions used by rust-analyzer.
+It's a best effort document, when in doubt, consult the source (and send a PR with clarification ;-) ).
+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`
+
+**Capability**
+
+```typescript
+{
+    "snippetTextEdit": boolean
+}
+```
+
+If this capability is set, `WorkspaceEdit`s returned from `codeAction` requests might contain `SnippetTextEdit`s instead of usual `TextEdit`s:
+
+```typescript
+interface SnippetTextEdit extends TextEdit {
+    insertTextFormat?: InsertTextFormat;
+}
+```
+
+```typescript
+export interface TextDocumentEdit {
+	textDocument: VersionedTextDocumentIdentifier;
+	edits: (TextEdit | SnippetTextEdit)[];
+}
+```
+
+When applying such code action, the editor should insert snippet, with tab stops and placeholder.
+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 692fd4f52ba..41c5df5287c 100644
--- a/docs/user/assists.md
+++ b/docs/user/assists.md
@@ -17,7 +17,7 @@ struct S;
 struct S;
 
 impl Debug for S {
-
+    $0
 }
 ```
 
@@ -33,7 +33,7 @@ struct Point {
 }
 
 // AFTER
-#[derive()]
+#[derive($0)]
 struct Point {
     x: u32,
     y: u32,
@@ -105,16 +105,16 @@ Adds a new inherent impl for a type.
 ```rust
 // BEFORE
 struct Ctx<T: Clone> {
-     data: T,┃
+    data: T,┃
 }
 
 // AFTER
 struct Ctx<T: Clone> {
-     data: T,
+    data: T,
 }
 
 impl<T: Clone> Ctx<T> {
-
+    $0
 }
 ```