From befdc11cf187a9c50d94a108fa7c1eedfde00fa4 Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Wed, 15 Feb 2023 17:12:47 +0100 Subject: [PATCH 1/5] Add textDocument/inlineCompletion --- _data/linkableTypes.yml | 22 +- .../lsp/3.18/general/initialize.md | 14 ++ .../lsp/3.18/language/inlineCompletion.md | 233 ++++++++++++++++++ .../lsp/3.18/metaModel/metaModel.json | 194 ++++++++++++++- _specifications/lsp/3.18/specification.md | 1 + 5 files changed, 462 insertions(+), 2 deletions(-) create mode 100644 _specifications/lsp/3.18/language/inlineCompletion.md diff --git a/_data/linkableTypes.yml b/_data/linkableTypes.yml index 2505dc406..af652e182 100644 --- a/_data/linkableTypes.yml +++ b/_data/linkableTypes.yml @@ -863,4 +863,24 @@ - type: 'WorkspaceDocumentDiagnosticReport' link: '#workspaceDocumentDiagnosticReport' - type: 'WorkspaceDiagnosticReportPartialResult' - link: '#workspaceDiagnosticReportPartialResult' \ No newline at end of file + link: '#workspaceDiagnosticReportPartialResult' + - type: 'textDocument/inlineCompletion' + link: '#textDocument_inlineCompletion' + - type: 'InlineCompletionClientCapabilities' + link: '#inlineCompletionClientCapabilities' + - type: 'InlineCompletionOptions' + link: '#inlineCompletionOptions' + - type: 'InlineCompletionRegistrationOptions' + link: '#inlineCompletionRegistrationOptions' + - type: 'InlineCompletionParams' + link: '#inlineCompletionParams' + - type: 'InlineCompletionContext' + link: '#inlineCompletionContext' + - type: 'InlineCompletionTriggerKind' + link: '#inlineCompletionTriggerKind' + - type: 'SelectedCompletionInfo' + link: '#selectedCompletionInfo' + - type: 'InlineCompletionList' + link: '#inlineCompletionList' + - type: 'InlineCompletionItem' + link: '#inlineCompletionItem' \ No newline at end of file diff --git a/_specifications/lsp/3.18/general/initialize.md b/_specifications/lsp/3.18/general/initialize.md index 70f998b69..c633c0e89 100644 --- a/_specifications/lsp/3.18/general/initialize.md +++ b/_specifications/lsp/3.18/general/initialize.md @@ -288,6 +288,13 @@ export interface TextDocumentClientCapabilities { * @since 3.17.0 */ diagnostic?: DiagnosticClientCapabilities; + + /** + * Capabilities specific to the `textDocument/inlineCompletion` request. + * + * @since 3.18.0 + */ + inlineCompletion?: InlineCompletionClientCapabilities; } ``` @@ -870,6 +877,13 @@ interface ServerCapabilities { */ workspaceSymbolProvider?: boolean | WorkspaceSymbolOptions; + /** + * The server provides inline completions. + * + * @since 3.18.0 + */ + inlineCompletionProvider?: boolean | InlineCompletionOptions; + /** * Workspace specific server capabilities */ diff --git a/_specifications/lsp/3.18/language/inlineCompletion.md b/_specifications/lsp/3.18/language/inlineCompletion.md new file mode 100644 index 000000000..07aaa9a1e --- /dev/null +++ b/_specifications/lsp/3.18/language/inlineCompletion.md @@ -0,0 +1,233 @@ +#### Inline Completion Request (:leftwards_arrow_with_hook:) + +> *Since version 3.18.0* + +The inline completion request is sent from the client to the server to compute inline completions for a given text document either explicitly by a user gesture or implicitly when typing. + +_Client Capability_: +* property name (optional): `textDocument.inlineCompletion` +* property type: `InlineCompletionClientCapabilities` defined as follows: + +
+ +```typescript +/** + * Client capabilities specific to inline completions. + * + * @since 3.18.0 + */ +export interface InlineCompletionClientCapabilities { + /** + * Whether implementation supports dynamic registration for inline + * completion providers. + */ + dynamicRegistration?: boolean; +} +``` + +_Server Capability_: +* property name (optional): `inlineCompletionProvider` +* property type: `InlineCompletionOptions` defined as follows: + +
+ +```typescript +/** + * Inline completion options used during static registration. + * + * @since 3.18.0 + */ +export interface InlineCompletionOptions extends WorkDoneProgressOptions { +} +``` + +_Registration Options_: `InlineCompletionRegistrationOptions` defined as follows: + +
+ +```typescript +/** + * Inline completion options used during static or dynamic registration. + * + * @since 3.18.0 + */ +export interface InlineCompletionRegistrationOptions extends + InlineCompletionOptions, TextDocumentRegistrationOptions, + StaticRegistrationOptions { +} +``` + +_Request_: +* method: `textDocument/inlineCompletion` +* params: `InlineCompletionParams` defined as follows: + +
+ +```typescript +/** + * A parameter literal used in inline completion requests. + * + * @since 3.18.0 + */ +export interface InlineCompletionParams extends TextDocumentPositionParams, + WorkDoneProgressParams { + /** + * Additional information about the context in which inline completions + * were requested. + */ + context: InlineCompletionContext; +} +``` + +
+ +```typescript +/** + * Provides information about the context in which an inline completion was + * requested. + * + * @since 3.18.0 + */ +export interface InlineCompletionContext { + /** + * Describes how the inline completion was triggered. + */ + triggerKind: InlineCompletionTriggerKind; + + /** + * Provides information about the currently selected item in the + * autocomplete widget if it is visible. + * + * If set, provided inline completions must extend the text of the + * selected item and use the same range, otherwise they are not shown as + * preview. + * As an example, if the document text is `console.` and the selected item + * is `.log` replacing the `.` in the document, the inline completion must + * also replace `.` and start with `.log`, for example `.log()`. + * + * Inline completion providers are requested again whenever the selected + * item changes. + */ + selectedCompletionInfo?: SelectedCompletionInfo; +} +``` + +
+ +```typescript +/** + * Describes how an {@link InlineCompletionItemProvider inline completion + * provider} was triggered. + * + * @since 3.18.0 + */ +export namespace InlineCompletionTriggerKind { + /** + * Completion was triggered explicitly by a user gesture. + * Return multiple completion items to enable cycling through them. + */ + export const Invoke: 0 = 0; + + /** + * Completion was triggered automatically while editing. + * It is sufficient to return a single completion item in this case. + */ + export const Automatic: 1 = 1; +} + +export type InlineCompletionTriggerKind = 0 | 1; +``` + +
+ +```typescript +/** + * Describes the currently selected completion item. + * + * @since 3.18.0 + */ +export interface SelectedCompletionInfo { + /** + * The range that will be replaced if this completion item is accepted. + */ + range: Range; + + /** + * The text the range will be replaced with if this completion is + * accepted. + */ + text: string; +} +``` + +_Response_: +* result: `InlineCompletionItem[]` \| `InlineCompletionList` \| `null` defined as follows: + +
+ +```typescript +/** + * Represents a collection of {@link InlineCompletionItem inline completion + * items} to be presented in the editor. + * + * @since 3.18.0 + */ +export interface InlineCompletionList { + /** + * The inline completion items. + */ + items: InlineCompletionItem[]; +} +``` + +
+ +```typescript +/** + * An inline completion item represents a text snippet that is proposed inline + * to complete text that is being typed. + * + * @since 3.18.0 + */ +export interface InlineCompletionItem { + /** + * The text to replace the range with. Must be set. + * Is used both for the preview and the accept operation. + */ + insertText: string; + + /** + * A text that is used to decide if this inline completion should be + * shown. When `falsy` the {@link InlineCompletionItem.insertText} is + * used. + * + * An inline completion is shown if the text to replace is a prefix of the + * filter text. + */ + filterText?: string; + + /** + * The range to replace. + * Must begin and end on the same line. + * + * Prefer replacements over insertions to provide a better experience when + * the user deletes typed text. + */ + range?: Range; + + /** + * An optional {@link Command} that is executed *after* inserting this + * completion. + */ + command?: Command; + + /** + * The format of the insert text. The format applies to the `insertText`. + * If omitted defaults to `InsertTextFormat.PlainText`. + */ + insertTextFormat?: InsertTextFormat; +} +``` + + +* error: code and message set in case an exception happens during the inline completions request. diff --git a/_specifications/lsp/3.18/metaModel/metaModel.json b/_specifications/lsp/3.18/metaModel/metaModel.json index 4903cf061..cb5be8eb4 100644 --- a/_specifications/lsp/3.18/metaModel/metaModel.json +++ b/_specifications/lsp/3.18/metaModel/metaModel.json @@ -1,6 +1,6 @@ { "metaData": { - "version": "3.17.0" + "version": "3.18.0" }, "requests": [ { @@ -846,6 +846,40 @@ "documentation": "A request to provide inline values in a document. The request's parameter is of\ntype {@link InlineValueParams}, the response is of type\n{@link InlineValue InlineValue[]} or a Thenable that resolves to such.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "method": "textDocument/inlineCompletion", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + { + "kind": "reference", + "name": "InlineCompletionList" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "InlineCompletionParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "InlineCompletionRegistrationOptions" + }, + "documentation": "The inline completion request is sent from the client to the server to compute inline completions for a given text document either explicitly by a user gesture or implicitly when typing.", + "since": "3.18.0" + }, { "method": "workspace/inlineValue/refresh", "result": { @@ -8438,6 +8472,25 @@ }, "optional": true, "documentation": "Experimental server capabilities." + }, + { + "name": "InlineCompletionProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "InlineCompletionOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides inline completions.", + "since": "3.18.0" } ], "documentation": "Defines the capabilities provided by a language\nserver." @@ -10606,6 +10659,16 @@ "optional": true, "documentation": "Capabilities specific to the diagnostic pull model.\n\n@since 3.17.0", "since": "3.17.0" + }, + { + "name": "inlineCompletion", + "type": { + "kind": "reference", + "name": "InlineCompletionClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/inlineCompletion` request.", + "since": "3.18.0" } ], "documentation": "Text document specific client capabilities." @@ -12557,6 +12620,114 @@ ], "documentation": "Client capabilities specific to the used markdown parser.\n\n@since 3.16.0", "since": "3.16.0" + }, + { + "name": "InlineCompletionParams", + "properties": [ + { + "name": "context", + "type": { + "kind": "reference", + "name": "InlineCompletionContext" + }, + "documentation": "Additional information about the context in which inline completions were requested." + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "Inline completion parameters", + "since": "3.18.0" + }, + { + "name": "InlineCompletionContext", + "properties": [ + { + "name": "triggerKind", + "type": { + "kind": "reference", + "name": "InlineCompletionTriggerKind" + }, + "documentation": "Describes how the inline completion was triggered." + }, + { + "name": "selectedCompletionInfo", + "type": { + "kind": "reference", + "name": "SelectedCompletionInfo" + }, + "optional": true, + "documentation": "Provides information about the currently selected item in the autocomplete widget if it is visible." + } + ], + "documentation": "Provides information about the context in which an inline completion was requested.", + "since": "3.18.0" + }, + { + "name": "SelectedCompletionInfo", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range that will be replaced if this completion item is accepted." + }, + { + "name": "text", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The text the range will be replaced with if this completion is accepted." + } + ], + "documentation": "Describes the currently selected completion item.", + "since": "3.18.0" + }, + { + "name": "InlineCompletionRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "InlineCompletionOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Inline completion options used during static or dynamic registration.", + "since": "3.18.0" + }, + { + "name": "InlineCompletionOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Inline completion options used during static registration.", + "since": "3.18.0" } ], "enumerations": [ @@ -13745,6 +13916,27 @@ "value": "relative" } ] + }, + { + "name": "InlineCompletionTriggerKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Invoke", + "value": 0, + "documentation": "Completion was triggered explicitly by a user gesture." + }, + { + "name": "Automatic", + "value": 1, + "documentation": "Completion was triggered automatically while editing." + } + ], + "documentation": "Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.", + "since": "3.18.0" } ], "typeAliases": [ diff --git a/_specifications/lsp/3.18/specification.md b/_specifications/lsp/3.18/specification.md index 78a20767c..44840408d 100644 --- a/_specifications/lsp/3.18/specification.md +++ b/_specifications/lsp/3.18/specification.md @@ -655,6 +655,7 @@ Language Features provide the actual smarts in the language server protocol. The {% include_relative language/onTypeFormatting.md %} {% include_relative language/rename.md %} {% include_relative language/linkedEditingRange.md %} +{% include_relative language/inlineCompletion.md %} ### Workspace Features From 701d60f68882fb50cc3f5327c5ab0f874bef7d39 Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Wed, 15 Feb 2023 18:28:50 +0100 Subject: [PATCH 2/5] Define return types in metaModel.json --- .../lsp/3.18/metaModel/metaModel.json | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/_specifications/lsp/3.18/metaModel/metaModel.json b/_specifications/lsp/3.18/metaModel/metaModel.json index cb5be8eb4..7b8e05107 100644 --- a/_specifications/lsp/3.18/metaModel/metaModel.json +++ b/_specifications/lsp/3.18/metaModel/metaModel.json @@ -12728,6 +12728,75 @@ ], "documentation": "Inline completion options used during static registration.", "since": "3.18.0" + }, + { + "name": "InlineCompletionItem", + "properties": [ + { + "name": "insertText", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The text to replace the range with. Must be set." + }, + { + "name": "filterText", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "optional": true, + "documentation": "The range to replace. Must begin and end on the same line." + }, + { + "name": "command", + "type": { + "kind": "reference", + "name": "Command" + }, + "optional": true, + "documentation": "An optional {@link Command} that is executed *after* inserting this completion." + }, + { + "name": "insertTextFormat", + "type": { + "kind": "reference", + "name": "InsertTextFormat" + }, + "optional": true, + "documentation": "The format of the insert text. The format applies to the `insertText`. If omitted defaults to `InsertTextFormat.PlainText`." + } + ], + "documentation": "An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.", + "since": "3.18.0" + }, + { + "name": "InlineCompletionList", + "properties": [ + { + "name": "items", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + "documentation": "The inline completion items" + } + ], + "documentation": "Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor.", + "since": "3.18.0" } ], "enumerations": [ From b0f05c3d3e1e71b2ea0bf70b7ee69aed731c3720 Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Fri, 17 Feb 2023 19:03:08 +0100 Subject: [PATCH 3/5] Copy generated metaModel.json from node pull/1190 --- .../lsp/3.18/metaModel/metaModel.json | 570 +++++++++--------- 1 file changed, 296 insertions(+), 274 deletions(-) diff --git a/_specifications/lsp/3.18/metaModel/metaModel.json b/_specifications/lsp/3.18/metaModel/metaModel.json index 7b8e05107..526c07099 100644 --- a/_specifications/lsp/3.18/metaModel/metaModel.json +++ b/_specifications/lsp/3.18/metaModel/metaModel.json @@ -846,40 +846,6 @@ "documentation": "A request to provide inline values in a document. The request's parameter is of\ntype {@link InlineValueParams}, the response is of type\n{@link InlineValue InlineValue[]} or a Thenable that resolves to such.\n\n@since 3.17.0", "since": "3.17.0" }, - { - "method": "textDocument/inlineCompletion", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlineCompletionItem" - } - }, - { - "kind": "reference", - "name": "InlineCompletionList" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "InlineCompletionParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "InlineCompletionRegistrationOptions" - }, - "documentation": "The inline completion request is sent from the client to the server to compute inline completions for a given text document either explicitly by a user gesture or implicitly when typing.", - "since": "3.18.0" - }, { "method": "workspace/inlineValue/refresh", "result": { @@ -1009,6 +975,47 @@ "documentation": "The diagnostic refresh request definition.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "method": "textDocument/inlineCompletion", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "InlineCompletionList" + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "InlineCompletionParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "InlineCompletionRegistrationOptions" + }, + "documentation": "A request to provide inline completions in a document. The request's parameter is of\ntype {@link InlineCompletionParams}, the response is of type\n{@link InlineCompletion InlineCompletion[]} or a Thenable that resolves to such.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "method": "client/registerCapability", "result": { @@ -4069,6 +4076,123 @@ "documentation": "The params sent in a close notebook document notification.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "name": "InlineCompletionParams", + "properties": [ + { + "name": "context", + "type": { + "kind": "reference", + "name": "InlineCompletionContext" + }, + "documentation": "Additional information about the context in which inline completions were\nrequested." + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "A parameter literal used in inline completion requests.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "InlineCompletionList", + "properties": [ + { + "name": "items", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + "documentation": "The inline completion items" + } + ], + "documentation": "Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor." + }, + { + "name": "InlineCompletionItem", + "properties": [ + { + "name": "insertText", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The text to replace the range with. Must be set." + }, + { + "name": "insertTextFormat", + "type": { + "kind": "reference", + "name": "InsertTextFormat" + }, + "optional": true, + "documentation": "The format of the insert text. The format applies to the `insertText`. If omitted defaults to `InsertTextFormat.PlainText`." + }, + { + "name": "filterText", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "optional": true, + "documentation": "The range to replace. Must begin and end on the same line." + }, + { + "name": "command", + "type": { + "kind": "reference", + "name": "Command" + }, + "optional": true, + "documentation": "An optional {@link Command} that is executed *after* inserting this completion." + } + ], + "documentation": "An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "InlineCompletionRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "InlineCompletionOptions" + }, + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Inline completion options used during static or dynamic registration.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "name": "RegistrationParams", "properties": [ @@ -7628,6 +7752,42 @@ "documentation": "A literal to identify a notebook document in the client.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "name": "InlineCompletionContext", + "properties": [ + { + "name": "triggerKind", + "type": { + "kind": "reference", + "name": "InlineCompletionTriggerKind" + }, + "documentation": "Describes how the inline completion was triggered." + }, + { + "name": "selectedCompletionInfo", + "type": { + "kind": "reference", + "name": "SelectedCompletionInfo" + }, + "optional": true, + "documentation": "Provides information about the currently selected item in the autocomplete widget if it is visible." + } + ], + "documentation": "Provides information about the context in which an inline completion was requested.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "InlineCompletionOptions", + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "properties": [], + "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "name": "Registration", "properties": [ @@ -8432,6 +8592,25 @@ "documentation": "The server has support for pull model diagnostics.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "name": "inlineCompletionProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "InlineCompletionOptions" + } + ] + }, + "optional": true, + "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "name": "workspace", "type": { @@ -8472,25 +8651,6 @@ }, "optional": true, "documentation": "Experimental server capabilities." - }, - { - "name": "InlineCompletionProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "InlineCompletionOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides inline completions.", - "since": "3.18.0" } ], "documentation": "Defines the capabilities provided by a language\nserver." @@ -9725,10 +9885,33 @@ "since": "3.17.0" }, { - "name": "ClientCapabilities", + "name": "SelectedCompletionInfo", "properties": [ { - "name": "workspace", + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range that will be replaced if this completion item is accepted." + }, + { + "name": "text", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The text the range will be replaced with if this completion is accepted." + } + ], + "documentation": "Describes the currently selected completion item.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientCapabilities", + "properties": [ + { + "name": "workspace", "type": { "kind": "reference", "name": "WorkspaceClientCapabilities" @@ -10667,7 +10850,7 @@ "name": "InlineCompletionClientCapabilities" }, "optional": true, - "documentation": "Capabilities specific to the `textDocument/inlineCompletion` request.", + "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0", "since": "3.18.0" } ], @@ -12493,6 +12676,22 @@ "documentation": "Client capabilities specific to diagnostic pull requests.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "name": "InlineCompletionClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration for inline completion providers." + } + ], + "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "name": "NotebookDocumentSyncClientCapabilities", "properties": [ @@ -12620,183 +12819,6 @@ ], "documentation": "Client capabilities specific to the used markdown parser.\n\n@since 3.16.0", "since": "3.16.0" - }, - { - "name": "InlineCompletionParams", - "properties": [ - { - "name": "context", - "type": { - "kind": "reference", - "name": "InlineCompletionContext" - }, - "documentation": "Additional information about the context in which inline completions were requested." - } - ], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "Inline completion parameters", - "since": "3.18.0" - }, - { - "name": "InlineCompletionContext", - "properties": [ - { - "name": "triggerKind", - "type": { - "kind": "reference", - "name": "InlineCompletionTriggerKind" - }, - "documentation": "Describes how the inline completion was triggered." - }, - { - "name": "selectedCompletionInfo", - "type": { - "kind": "reference", - "name": "SelectedCompletionInfo" - }, - "optional": true, - "documentation": "Provides information about the currently selected item in the autocomplete widget if it is visible." - } - ], - "documentation": "Provides information about the context in which an inline completion was requested.", - "since": "3.18.0" - }, - { - "name": "SelectedCompletionInfo", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range that will be replaced if this completion item is accepted." - }, - { - "name": "text", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The text the range will be replaced with if this completion is accepted." - } - ], - "documentation": "Describes the currently selected completion item.", - "since": "3.18.0" - }, - { - "name": "InlineCompletionRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "InlineCompletionOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ], - "documentation": "Inline completion options used during static or dynamic registration.", - "since": "3.18.0" - }, - { - "name": "InlineCompletionOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Inline completion options used during static registration.", - "since": "3.18.0" - }, - { - "name": "InlineCompletionItem", - "properties": [ - { - "name": "insertText", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The text to replace the range with. Must be set." - }, - { - "name": "filterText", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used." - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "optional": true, - "documentation": "The range to replace. Must begin and end on the same line." - }, - { - "name": "command", - "type": { - "kind": "reference", - "name": "Command" - }, - "optional": true, - "documentation": "An optional {@link Command} that is executed *after* inserting this completion." - }, - { - "name": "insertTextFormat", - "type": { - "kind": "reference", - "name": "InsertTextFormat" - }, - "optional": true, - "documentation": "The format of the insert text. The format applies to the `insertText`. If omitted defaults to `InsertTextFormat.PlainText`." - } - ], - "documentation": "An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.", - "since": "3.18.0" - }, - { - "name": "InlineCompletionList", - "properties": [ - { - "name": "items", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlineCompletionItem" - } - }, - "documentation": "The inline completion items" - } - ], - "documentation": "Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor.", - "since": "3.18.0" } ], "enumerations": [ @@ -13291,6 +13313,26 @@ "documentation": "Inlay hint kinds.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "name": "InsertTextFormat", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "PlainText", + "value": 1, + "documentation": "The primary text to be inserted is treated as a plain string." + }, + { + "name": "Snippet", + "value": 2, + "documentation": "The primary text to be inserted is treated as a snippet.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Placeholders with equal identifiers are linked,\nthat is typing in one will update others too.\n\nSee also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax" + } + ], + "documentation": "Defines whether the insert text in a completion item should be interpreted as\nplain text or a snippet." + }, { "name": "MessageType", "type": { @@ -13497,26 +13539,6 @@ "documentation": "Completion item tags are extra annotations that tweak the rendering of a completion\nitem.\n\n@since 3.15.0", "since": "3.15.0" }, - { - "name": "InsertTextFormat", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "PlainText", - "value": 1, - "documentation": "The primary text to be inserted is treated as a plain string." - }, - { - "name": "Snippet", - "value": 2, - "documentation": "The primary text to be inserted is treated as a snippet.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Placeholders with equal identifiers are linked,\nthat is typing in one will update others too.\n\nSee also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax" - } - ], - "documentation": "Defines whether the insert text in a completion item should be interpreted as\nplain text or a snippet." - }, { "name": "InsertTextMode", "type": { @@ -13664,6 +13686,27 @@ ], "documentation": "Describes the content type that a client supports in various\nresult literals like `Hover`, `ParameterInfo` or `CompletionItem`.\n\nPlease note that `MarkupKinds` must not start with a `$`. This kinds\nare reserved for internal usage." }, + { + "name": "InlineCompletionTriggerKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Invoked", + "value": 0, + "documentation": "Completion was triggered explicitly by a user gesture." + }, + { + "name": "Automatic", + "value": 1, + "documentation": "Completion was triggered automatically while editing." + } + ], + "documentation": "Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "name": "PositionEncodingKind", "type": { @@ -13985,27 +14028,6 @@ "value": "relative" } ] - }, - { - "name": "InlineCompletionTriggerKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Invoke", - "value": 0, - "documentation": "Completion was triggered explicitly by a user gesture." - }, - { - "name": "Automatic", - "value": 1, - "documentation": "Completion was triggered automatically while editing." - } - ], - "documentation": "Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.", - "since": "3.18.0" } ], "typeAliases": [ From c944fa8c6dd3e4678c96b41b6b88566f1924159d Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Wed, 22 Feb 2023 19:08:56 +0100 Subject: [PATCH 4/5] Add feature detail --- .../lsp/3.18/language/inlineCompletion.md | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/_specifications/lsp/3.18/language/inlineCompletion.md b/_specifications/lsp/3.18/language/inlineCompletion.md index 07aaa9a1e..0ada99967 100644 --- a/_specifications/lsp/3.18/language/inlineCompletion.md +++ b/_specifications/lsp/3.18/language/inlineCompletion.md @@ -2,7 +2,25 @@ > *Since version 3.18.0* -The inline completion request is sent from the client to the server to compute inline completions for a given text document either explicitly by a user gesture or implicitly when typing. +The inline completion request is sent from the client to the server to compute +inline completions for a given text document either explicitly by a user gesture +or implicitly when typing. Inline completion items are presented directly in the +editor with the user's text. The portion of the inline completion item's text +that isn't in the document receives a slightly different UI treatment e.g. lower +contrast. With only one item being displayed at a time, the server may use this +feature for visible edits where it is relatively confident the user would like +this edit in particular. The context property also provides allowance for this +feature to work *with* completions presented in the IntelliSense interface. + +When multiple inline completion items are returned, the client may decide +whether the user can cycle through them or if they, along with their +`filterText`, are merely for filtering if the user continues to type without yet +accepting the inline completion item. + +Clients may choose to send information about the user's current completion +selection via context if completions are visible at the same time. In this case, +returned inline completions should extend the text of the provided completion. + _Client Capability_: * property name (optional): `textDocument.inlineCompletion` From a7b9e0375a99fbe684426091aa6459ded5ad96d8 Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Wed, 28 Jun 2023 17:53:04 +0200 Subject: [PATCH 5/5] Update initial .md description --- .../lsp/3.18/language/inlineCompletion.md | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/_specifications/lsp/3.18/language/inlineCompletion.md b/_specifications/lsp/3.18/language/inlineCompletion.md index 0ada99967..f52c98c5c 100644 --- a/_specifications/lsp/3.18/language/inlineCompletion.md +++ b/_specifications/lsp/3.18/language/inlineCompletion.md @@ -2,24 +2,15 @@ > *Since version 3.18.0* -The inline completion request is sent from the client to the server to compute -inline completions for a given text document either explicitly by a user gesture -or implicitly when typing. Inline completion items are presented directly in the -editor with the user's text. The portion of the inline completion item's text -that isn't in the document receives a slightly different UI treatment e.g. lower -contrast. With only one item being displayed at a time, the server may use this -feature for visible edits where it is relatively confident the user would like -this edit in particular. The context property also provides allowance for this -feature to work *with* completions presented in the IntelliSense interface. - -When multiple inline completion items are returned, the client may decide -whether the user can cycle through them or if they, along with their -`filterText`, are merely for filtering if the user continues to type without yet -accepting the inline completion item. - -Clients may choose to send information about the user's current completion -selection via context if completions are visible at the same time. In this case, -returned inline completions should extend the text of the provided completion. +The inline completion request is sent from the client to the server to compute inline completions for a given text document either explicitly by a user gesture or implicitly when typing. + +Inline completion items usually complete bigger portions of text (e.g. whole methods, ...) and in contrast to completions items can complete code that might be syntactically or semantically incorrect. + +Due to this inline completion items are usually not suited to be presented in normal code completion widgets like a list of items. One possible approach can be to present the information inline in the editor with lower contrast. + +When multiple inline completion items are returned, the client may decide whether the user can cycle through them or if they, along with their `filterText`, are merely for filtering if the user continues to type without yet accepting the inline completion item. + +Clients may choose to send information about the user's current completion selection via context if completions are visible at the same time. In this case, returned inline completions should extend the text of the provided completion. _Client Capability_: