From 87830ced57e15b5b3ef0f7a5972ac2f78af2683c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= Date: Thu, 3 Aug 2023 21:43:08 +0200 Subject: [PATCH] update lsp protocol types (#2306) --- plugin/core/protocol.py | 186 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 178 insertions(+), 8 deletions(-) diff --git a/plugin/core/protocol.py b/plugin/core/protocol.py index 56c9b5aae..86323692e 100644 --- a/plugin/core/protocol.py +++ b/plugin/core/protocol.py @@ -401,12 +401,23 @@ class MarkupKind(Enum): """ Markdown is supported as a content format """ +class InlineCompletionTriggerKind(IntEnum): + """ Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered. + + @since 3.18.0 + @proposed """ + Invoked = 0 + """ Completion was triggered explicitly by a user gesture. """ + Automatic = 1 + """ Completion was triggered automatically while editing. """ + + class PositionEncodingKind(Enum): """ A set of predefined position encoding kinds. @since 3.17.0 """ UTF8 = 'utf-8' - """ Character offsets count UTF-8 code units. """ + """ Character offsets count UTF-8 code units (e.g. bytes). """ UTF16 = 'utf-16' """ Character offsets count UTF-16 code units. @@ -415,7 +426,7 @@ class PositionEncodingKind(Enum): UTF32 = 'utf-32' """ Character offsets count UTF-32 code units. - Implementation note: these are the same as Unicode code points, + Implementation note: these are the same as Unicode codepoints, so this `PositionEncodingKind` may also be used for an encoding-agnostic representation of character offsets. """ @@ -1168,10 +1179,10 @@ class TokenFormat(Enum): ShowDocumentParams = TypedDict('ShowDocumentParams', { - # The document uri to show. + # The uri to show. 'uri': 'URI', # Indicates to show the resource in an external program. - # To show for example `https://code.visualstudio.com/` + # To show, for example, `https://code.visualstudio.com/` # in the default WEB browser set `external` to `true`. 'external': NotRequired[bool], # An optional property to indicate whether the editor @@ -1185,7 +1196,7 @@ class TokenFormat(Enum): # file. 'selection': NotRequired['Range'], }) -""" Params to show a document. +""" Params to show a resource in the UI. @since 3.16.0 """ @@ -1671,6 +1682,63 @@ class TokenFormat(Enum): @since 3.17.0 """ +InlineCompletionParams = TypedDict('InlineCompletionParams', { + # Additional information about the context in which inline completions were + # requested. + 'context': 'InlineCompletionContext', + # The text document. + 'textDocument': 'TextDocumentIdentifier', + # The position inside the text document. + 'position': 'Position', + # An optional token that a server can use to report work done progress. + 'workDoneToken': NotRequired['ProgressToken'], +}) +""" A parameter literal used in inline completion requests. + +@since 3.18.0 +@proposed """ + + +InlineCompletionList = TypedDict('InlineCompletionList', { + # The inline completion items + 'items': List['InlineCompletionItem'], +}) +""" Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor. + +@since 3.18.0 +@proposed """ + + +InlineCompletionItem = TypedDict('InlineCompletionItem', { + # The text to replace the range with. Must be set. + 'insertText': Union[str, 'StringValue'], + # A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used. + 'filterText': NotRequired[str], + # The range to replace. Must begin and end on the same line. + 'range': NotRequired['Range'], + # An optional {@link Command} that is executed *after* inserting this completion. + 'command': NotRequired['Command'], +}) +""" An inline completion item represents a text snippet that is proposed inline to complete text that is being typed. + +@since 3.18.0 +@proposed """ + + +InlineCompletionRegistrationOptions = TypedDict('InlineCompletionRegistrationOptions', { + # A document selector to identify the scope of the registration. If set to null + # the document selector provided on the client side will be used. + 'documentSelector': Union['DocumentSelector', None], + # The id used to register the request. The id can be used to deregister + # the request again. See also Registration#id. + 'id': NotRequired[str], +}) +""" Inline completion options used during static or dynamic registration. + +@since 3.18.0 +@proposed """ + + RegistrationParams = TypedDict('RegistrationParams', { 'registrations': List['Registration'], }) @@ -2581,7 +2649,7 @@ class TokenFormat(Enum): # The range this link applies to. 'range': 'Range', # The uri this link points to. If missing a resolve request is sent later. - 'target': NotRequired[str], + 'target': NotRequired['URI'], # The tooltip text when you hover over this link. # # If a tooltip is provided, is will be displayed in a string that includes instructions on how to @@ -2644,10 +2712,31 @@ class TokenFormat(Enum): # A document selector to identify the scope of the registration. If set to null # the document selector provided on the client side will be used. 'documentSelector': Union['DocumentSelector', None], + # Whether the server supports formatting multiple ranges at once. + # + # @since 3.18.0 + # @proposed + 'rangesSupport': NotRequired[bool], }) """ Registration options for a {@link DocumentRangeFormattingRequest}. """ +DocumentRangesFormattingParams = TypedDict('DocumentRangesFormattingParams', { + # The document to format. + 'textDocument': 'TextDocumentIdentifier', + # The ranges to format + 'ranges': List['Range'], + # The format options + 'options': 'FormattingOptions', + # An optional token that a server can use to report work done progress. + 'workDoneToken': NotRequired['ProgressToken'], +}) +""" The parameters of a {@link DocumentRangesFormattingRequest}. + +@since 3.18.0 +@proposed """ + + DocumentOnTypeFormattingParams = TypedDict('DocumentOnTypeFormattingParams', { # The document to format. 'textDocument': 'TextDocumentIdentifier', @@ -2741,7 +2830,7 @@ class TokenFormat(Enum): # The edits to apply. 'edit': 'WorkspaceEdit', }) -""" The parameters passed via a apply workspace edit request. """ +""" The parameters passed via an apply workspace edit request. """ ApplyWorkspaceEditResult = TypedDict('ApplyWorkspaceEditResult', { @@ -3502,6 +3591,45 @@ class TokenFormat(Enum): @since 3.17.0 """ +InlineCompletionContext = TypedDict('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. + 'selectedCompletionInfo': NotRequired['SelectedCompletionInfo'], +}) +""" Provides information about the context in which an inline completion was requested. + +@since 3.18.0 +@proposed """ + + +StringValue = TypedDict('StringValue', { + # The kind of string value. + 'kind': Literal['snippet'], + # The snippet string. + 'value': str, +}) +""" A string value used as a snippet is a template which allows to insert text +and to control the editor cursor when insertion happens. + +A snippet can define tab stops and placeholders with `$1`, `$2` +and `${3:foo}`. `$0` defines the final tab stop, it defaults to +the end of the snippet. Variables are defined with `$name` and +`${name:default value}`. + +@since 3.18.0 +@proposed """ + + +InlineCompletionOptions = TypedDict('InlineCompletionOptions', { + 'workDoneProgress': NotRequired[bool], +}) +""" Inline completion options used during static registration. + +@since 3.18.0 +@proposed """ + + Registration = TypedDict('Registration', { # The id used to register the request. The id can be used to deregister # the request again. @@ -3511,7 +3639,7 @@ class TokenFormat(Enum): # Options necessary for the registration. 'registerOptions': NotRequired['LSPAny'], }) -""" General parameters to to register for an notification or to register a provider. """ +""" General parameters to register for a notification or to register a provider. """ Unregistration = TypedDict('Unregistration', { @@ -3635,6 +3763,11 @@ class TokenFormat(Enum): # # @since 3.17.0 'diagnosticProvider': NotRequired[Union['DiagnosticOptions', 'DiagnosticRegistrationOptions']], + # Inline completion options used during static registration. + # + # @since 3.18.0 + # @proposed + 'inlineCompletionProvider': NotRequired[Union[bool, 'InlineCompletionOptions']], # Workspace specific server capabilities. 'workspace': NotRequired['__ServerCapabilities_workspace_Type_1'], # Experimental server capabilities. @@ -3997,6 +4130,11 @@ class TokenFormat(Enum): DocumentRangeFormattingOptions = TypedDict('DocumentRangeFormattingOptions', { + # Whether the server supports formatting multiple ranges at once. + # + # @since 3.18.0 + # @proposed + 'rangesSupport': NotRequired[bool], 'workDoneProgress': NotRequired[bool], }) """ Provider options for a {@link DocumentRangeFormattingRequest}. """ @@ -4203,6 +4341,18 @@ class TokenFormat(Enum): @since 3.17.0 """ +SelectedCompletionInfo = TypedDict('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': str, +}) +""" Describes the currently selected completion item. + +@since 3.18.0 +@proposed """ + + ClientCapabilities = TypedDict('ClientCapabilities', { # Workspace specific client capabilities. 'workspace': NotRequired['WorkspaceClientCapabilities'], @@ -4535,6 +4685,11 @@ class TokenFormat(Enum): # # @since 3.17.0 'diagnostic': NotRequired['DiagnosticClientCapabilities'], + # Client capabilities specific to inline completions. + # + # @since 3.18.0 + # @proposed + 'inlineCompletion': NotRequired['InlineCompletionClientCapabilities'], }) """ Text document specific client capabilities. """ @@ -5023,6 +5178,11 @@ class TokenFormat(Enum): DocumentRangeFormattingClientCapabilities = TypedDict('DocumentRangeFormattingClientCapabilities', { # Whether range formatting supports dynamic registration. 'dynamicRegistration': NotRequired[bool], + # Whether the client supports formatting multiple ranges at once. + # + # @since 3.18.0 + # @proposed + 'rangesSupport': NotRequired[bool], }) """ Client capabilities of a {@link DocumentRangeFormattingRequest}. """ @@ -5240,6 +5400,16 @@ class TokenFormat(Enum): @since 3.17.0 """ +InlineCompletionClientCapabilities = TypedDict('InlineCompletionClientCapabilities', { + # Whether implementation supports dynamic registration for inline completion providers. + 'dynamicRegistration': NotRequired[bool], +}) +""" Client capabilities specific to inline completions. + +@since 3.18.0 +@proposed """ + + NotebookDocumentSyncClientCapabilities = TypedDict('NotebookDocumentSyncClientCapabilities', { # Whether implementation supports dynamic registration. If this is # set to `true` the client supports the new