Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update lsp protocol types #2306

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 178 additions & 8 deletions plugin/core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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. """

Expand Down Expand Up @@ -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
Expand All @@ -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 """

Expand Down Expand Up @@ -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'],
})
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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', {
Expand Down Expand Up @@ -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.
Expand All @@ -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', {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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}. """
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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. """

Expand Down Expand Up @@ -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}. """

Expand Down Expand Up @@ -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
Expand Down
Loading