rust/docs/dev/lsp-extensions.md
2020-05-19 20:28:27 +02:00

1.0 KiB

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

{
    "snippetTextEdit": boolean
}

If this capability is set, WorkspaceEdits returned from codeAction requests might contain SnippetTextEdits instead of usual TextEdits:

interface SnippetTextEdit extends TextEdit {
    insertTextFormat?: InsertTextFormat;
}
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.