From a752853350639a915178ea900a51f3c45443795e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 17 May 2020 21:24:33 +0200 Subject: Add snippetTextEdit protocol extension --- docs/dev/lsp-extensions.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docs/dev/lsp-extensions.md (limited to 'docs/dev/lsp-extensions.md') 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 @@ +# 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`. -- cgit v1.2.3