From 68736ae32c943f2509731b7b9a171dd527e65df6 Mon Sep 17 00:00:00 2001 From: Maria Solano Date: Wed, 31 Jan 2024 15:59:12 -0800 Subject: [PATCH 1/2] Add snippet text edit specs --- _data/linkableTypes.yml | 4 ++- .../lsp/3.18/types/textDocumentEdit.md | 9 +++-- _specifications/lsp/3.18/types/textEdit.md | 34 +++++++++++++++++-- .../lsp/3.18/types/workspaceEdit.md | 8 +++++ 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/_data/linkableTypes.yml b/_data/linkableTypes.yml index 0d8ed857f..3a632b867 100644 --- a/_data/linkableTypes.yml +++ b/_data/linkableTypes.yml @@ -899,4 +899,6 @@ - type: 'InlineCompletionItem' link: '#inlineCompletionItem' - type: 'StringValue' - link: '#stringValue' \ No newline at end of file + link: '#stringValue' + - type: 'SnippetTextEdit' + link: '#snippetTextEdit' \ No newline at end of file diff --git a/_specifications/lsp/3.18/types/textDocumentEdit.md b/_specifications/lsp/3.18/types/textDocumentEdit.md index 34b35c7cb..5e64feb28 100644 --- a/_specifications/lsp/3.18/types/textDocumentEdit.md +++ b/_specifications/lsp/3.18/types/textDocumentEdit.md @@ -1,6 +1,8 @@ #### TextDocumentEdit -> New in version 3.16: support for `AnnotatedTextEdit`. The support is guarded by the client capability `workspace.workspaceEdit.changeAnnotationSupport`. If a client doesn't signal the capability, servers shouldn't send `AnnotatedTextEdit` literals back to the client. +* New in version 3.16: support for `AnnotatedTextEdit`. The support is guarded by the client capability `workspace.workspaceEdit.changeAnnotationSupport`. If a client doesn't signal the capability, servers shouldn't send `AnnotatedTextEdit` literals back to the client. + +* New in version 3.18: support for `SnippetTextEdit`. The support is guarded by the client capability `workspace.workspaceEdit.snippetEditSupport`. If a client doesn't signal the capability, servers shouldn't send `SnippetTextEdit` snippets back to the client. Describes textual changes on a single text document. The text document is referred to as an `OptionalVersionedTextDocumentIdentifier` to allow clients to check the text document version before an edit is applied. A `TextDocumentEdit` describes all changes on a version Si and after they are applied move the document to version Si+1. So, the creator of a `TextDocumentEdit` doesn't need to sort the array of edits or do any kind of ordering. However, the edits must be non overlapping. @@ -16,7 +18,10 @@ export interface TextDocumentEdit { * * @since 3.16.0 - support for AnnotatedTextEdit. This is guarded by the * client capability `workspace.workspaceEdit.changeAnnotationSupport` + * + * @since 3.18.0 - support for SnippetTextEdit. This is guarded by the + * client capability `workspace.workspaceEdit.snippetEditSupport` */ - edits: (TextEdit | AnnotatedTextEdit)[]; + edits: (TextEdit | AnnotatedTextEdit | SnippetTextEdit)[]; } ``` diff --git a/_specifications/lsp/3.18/types/textEdit.md b/_specifications/lsp/3.18/types/textEdit.md index 79032d6a6..4fdfc1fb1 100644 --- a/_specifications/lsp/3.18/types/textEdit.md +++ b/_specifications/lsp/3.18/types/textEdit.md @@ -1,6 +1,8 @@ -#### TextEdit & AnnotatedTextEdit +#### TextEdit, AnnotatedTextEdit & SnippetTextEdit + +- New in version 3.16: Support for `AnnotatedTextEdit`. +- New in version 3.18: Support for `SnippetTextEdit`. -> New in version 3.16: Support for `AnnotatedTextEdit`. A textual edit applicable to a text document. @@ -79,3 +81,31 @@ export interface AnnotatedTextEdit extends TextEdit { annotationId: ChangeAnnotationIdentifier; } ``` + +Since 3.18.0, there is also the concept of a snippet text edit, which supports inserting a snippet instead of plain text. + +
+ +```typescript +/** + * An interactive text edit. + * + * @since 3.18.0 + */ +export interface SnippetTextEdit { + /** + * The range of the text document to be manipulated. + */ + range: Range; + + /** + * The snippet to be inserted. + */ + snippet: StringValue; + + /** + * The actual identifier of the snippet edit. + */ + annotationId?: ChangeAnnotationIdentifier; +} +``` \ No newline at end of file diff --git a/_specifications/lsp/3.18/types/workspaceEdit.md b/_specifications/lsp/3.18/types/workspaceEdit.md index ec1d87155..338c4d7cd 100644 --- a/_specifications/lsp/3.18/types/workspaceEdit.md +++ b/_specifications/lsp/3.18/types/workspaceEdit.md @@ -113,6 +113,14 @@ export interface WorkspaceEditClientCapabilities { * @proposed */ metadataSupport?: boolean; + + /** + * Whether the client supports snippets as text edits. + * + * @since 3.18.0 + * @proposed + */ + snippetEditSupport?: boolean; } ``` From b4c489f51f37269db4fc753766164154447176fa Mon Sep 17 00:00:00 2001 From: Maria Solano Date: Thu, 15 Feb 2024 11:13:11 -0800 Subject: [PATCH 2/2] add remarks --- _specifications/lsp/3.18/types/textEdit.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_specifications/lsp/3.18/types/textEdit.md b/_specifications/lsp/3.18/types/textEdit.md index 4fdfc1fb1..e01ead6b1 100644 --- a/_specifications/lsp/3.18/types/textEdit.md +++ b/_specifications/lsp/3.18/types/textEdit.md @@ -84,6 +84,10 @@ export interface AnnotatedTextEdit extends TextEdit { Since 3.18.0, there is also the concept of a snippet text edit, which supports inserting a snippet instead of plain text. +Some important remarks: +- For each file, only one snippet can specify a cursor position. In case there are multiple snippets defining a cursor position for a given URI, it is up to the client to decide the end position of the cursor. +- In case the snippet text edit corresponds to a file that is not currently open in the editor, the client should downgrade the snippet to a non-interactive normal text edit and apply it to the file. This ensures that a workspace edit doesn't open arbitrary files. +
```typescript