Skip to content

Commit bed251d

Browse files
Update LSP types (#2593)
1 parent ecf23ee commit bed251d

File tree

1 file changed

+155
-8
lines changed

1 file changed

+155
-8
lines changed

plugin/core/protocol.py

Lines changed: 155 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,14 @@ class CodeActionKind(StrEnum):
408408
@since 3.18.0 """
409409

410410

411+
class CodeActionTag(IntEnum):
412+
""" Code action tags are extra annotations that tweak the behavior of a code action.
413+
414+
@since 3.18.0 - proposed """
415+
LLMGenerated = 1
416+
""" Marks the code action as LLM-generated. """
417+
418+
411419
class TraceValue(StrEnum):
412420
Off = 'off'
413421
""" Turn tracing off. """
@@ -431,8 +439,7 @@ class MarkupKind(StrEnum):
431439

432440
class LanguageKind(StrEnum):
433441
""" Predefined Language kinds
434-
@since 3.18.0
435-
@proposed """
442+
@since 3.18.0 """
436443
ABAP = 'abap'
437444
WindowsBat = 'bat'
438445
BibTeX = 'bibtex'
@@ -590,6 +597,21 @@ class CompletionTriggerKind(IntEnum):
590597
""" Completion was re-triggered as current completion list is incomplete """
591598

592599

600+
class ApplyKind(IntFlag):
601+
""" Defines how values from a set of defaults and an individual item will be
602+
merged.
603+
604+
@since 3.18.0 """
605+
Replace = 1
606+
""" The value from the individual item (if provided and not `null`) will be
607+
used instead of the default. """
608+
Merge = 2
609+
""" The value from the item will be merged with the default.
610+
611+
The specific rules for mergeing values are defined against each field
612+
that supports merging. """
613+
614+
593615
class SignatureHelpTriggerKind(IntEnum):
594616
""" How a signature help was triggered.
595617
@@ -768,7 +790,7 @@ class TokenFormat(StrEnum):
768790
""" A document filter describes a top level text document or
769791
a notebook cell document.
770792
771-
@since 3.17.0 - proposed support for NotebookCellTextDocumentFilter. """
793+
@since 3.17.0 - support for NotebookCellTextDocumentFilter. """
772794

773795
LSPObject = Dict[str, 'LSPAny']
774796
""" LSP object definition.
@@ -2197,13 +2219,33 @@ class CompletionList(TypedDict):
21972219
be used if a completion item itself doesn't specify the value.
21982220
21992221
If a completion list specifies a default value and a completion item
2200-
also specifies a corresponding value the one from the item is used.
2222+
also specifies a corresponding value, the rules for combining these are
2223+
defined by `applyKinds` (if the client supports it), defaulting to
2224+
ApplyKind.Replace.
22012225
22022226
Servers are only allowed to return default values if the client
22032227
signals support for this via the `completionList.itemDefaults`
22042228
capability.
22052229
22062230
@since 3.17.0 """
2231+
applyKind: NotRequired['CompletionItemApplyKinds']
2232+
""" Specifies how fields from a completion item should be combined with those
2233+
from `completionList.itemDefaults`.
2234+
2235+
If unspecified, all fields will be treated as ApplyKind.Replace.
2236+
2237+
If a field's value is ApplyKind.Replace, the value from a completion item
2238+
(if provided and not `null`) will always be used instead of the value
2239+
from `completionItem.itemDefaults`.
2240+
2241+
If a field's value is ApplyKind.Merge, the values will be merged using
2242+
the rules defined against each field below.
2243+
2244+
Servers are only allowed to return `applyKind` if the client
2245+
signals support for this via the `completionList.applyKindSupport`
2246+
capability.
2247+
2248+
@since 3.18.0 """
22072249
items: List['CompletionItem']
22082250
""" The completion items. """
22092251

@@ -2572,6 +2614,10 @@ class CodeAction(TypedDict):
25722614
a `textDocument/codeAction` and a `codeAction/resolve` request.
25732615
25742616
@since 3.16.0 """
2617+
tags: NotRequired[List['CodeActionTag']]
2618+
""" Tags for this code action.
2619+
2620+
@since 3.18.0 - proposed """
25752621

25762622

25772623
class CodeActionRegistrationOptions(TypedDict):
@@ -3913,7 +3959,9 @@ class CompletionItemDefaults(TypedDict):
39133959
be used if a completion item itself doesn't specify the value.
39143960
39153961
If a completion list specifies a default value and a completion item
3916-
also specifies a corresponding value the one from the item is used.
3962+
also specifies a corresponding value, the rules for combining these are
3963+
defined by `applyKinds` (if the client supports it), defaulting to
3964+
ApplyKind.Replace.
39173965
39183966
Servers are only allowed to return default values if the client
39193967
signals support for this via the `completionList.itemDefaults`
@@ -3942,6 +3990,65 @@ class CompletionItemDefaults(TypedDict):
39423990
@since 3.17.0 """
39433991

39443992

3993+
class CompletionItemApplyKinds(TypedDict):
3994+
""" Specifies how fields from a completion item should be combined with those
3995+
from `completionList.itemDefaults`.
3996+
3997+
If unspecified, all fields will be treated as ApplyKind.Replace.
3998+
3999+
If a field's value is ApplyKind.Replace, the value from a completion item (if
4000+
provided and not `null`) will always be used instead of the value from
4001+
`completionItem.itemDefaults`.
4002+
4003+
If a field's value is ApplyKind.Merge, the values will be merged using the rules
4004+
defined against each field below.
4005+
4006+
Servers are only allowed to return `applyKind` if the client
4007+
signals support for this via the `completionList.applyKindSupport`
4008+
capability.
4009+
4010+
@since 3.18.0 """
4011+
commitCharacters: NotRequired['ApplyKind']
4012+
""" Specifies whether commitCharacters on a completion will replace or be
4013+
merged with those in `completionList.itemDefaults.commitCharacters`.
4014+
4015+
If ApplyKind.Replace, the commit characters from the completion item will
4016+
always be used unless not provided, in which case those from
4017+
`completionList.itemDefaults.commitCharacters` will be used. An
4018+
empty list can be used if a completion item does not have any commit
4019+
characters and also should not use those from
4020+
`completionList.itemDefaults.commitCharacters`.
4021+
4022+
If ApplyKind.Merge the commitCharacters for the completion will be the
4023+
union of all values in both `completionList.itemDefaults.commitCharacters`
4024+
and the completion's own `commitCharacters`.
4025+
4026+
@since 3.18.0 """
4027+
data: NotRequired['ApplyKind']
4028+
""" Specifies whether the `data` field on a completion will replace or
4029+
be merged with data from `completionList.itemDefaults.data`.
4030+
4031+
If ApplyKind.Replace, the data from the completion item will be used if
4032+
provided (and not `null`), otherwise
4033+
`completionList.itemDefaults.data` will be used. An empty object can
4034+
be used if a completion item does not have any data but also should
4035+
not use the value from `completionList.itemDefaults.data`.
4036+
4037+
If ApplyKind.Merge, a shallow merge will be performed between
4038+
`completionList.itemDefaults.data` and the completion's own data
4039+
using the following rules:
4040+
4041+
- If a completion's `data` field is not provided (or `null`), the
4042+
entire `data` field from `completionList.itemDefaults.data` will be
4043+
used as-is.
4044+
- If a completion's `data` field is provided, each field will
4045+
overwrite the field of the same name in
4046+
`completionList.itemDefaults.data` but no merging of nested fields
4047+
within that value will occur.
4048+
4049+
@since 3.18.0 """
4050+
4051+
39454052
class CompletionOptions(TypedDict):
39464053
""" Completion options. """
39474054
triggerCharacters: NotRequired[List[str]]
@@ -4771,6 +4878,10 @@ class TextDocumentClientCapabilities(TypedDict):
47714878
""" Text document specific client capabilities. """
47724879
synchronization: NotRequired['TextDocumentSyncClientCapabilities']
47734880
""" Defines which synchronization capabilities the client supports. """
4881+
filters: NotRequired['TextDocumentFilterClientCapabilities']
4882+
""" Defines which filters the client supports.
4883+
4884+
@since 3.18.0 """
47744885
completion: NotRequired['CompletionClientCapabilities']
47754886
""" Capabilities specific to the `textDocument/completion` request. """
47764887
hover: NotRequired['HoverClientCapabilities']
@@ -4991,7 +5102,9 @@ class TextDocumentFilterLanguage(TypedDict):
49915102
pattern: NotRequired['GlobPattern']
49925103
""" A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples.
49935104
4994-
@since 3.18.0 - support for relative patterns. """
5105+
@since 3.18.0 - support for relative patterns. Whether clients support
5106+
relative patterns depends on the client capability
5107+
`textDocuments.filters.relativePatternSupport`. """
49955108

49965109

49975110
class TextDocumentFilterScheme(TypedDict):
@@ -5005,7 +5118,9 @@ class TextDocumentFilterScheme(TypedDict):
50055118
pattern: NotRequired['GlobPattern']
50065119
""" A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples.
50075120
5008-
@since 3.18.0 - support for relative patterns. """
5121+
@since 3.18.0 - support for relative patterns. Whether clients support
5122+
relative patterns depends on the client capability
5123+
`textDocuments.filters.relativePatternSupport`. """
50095124

50105125

50115126
class TextDocumentFilterPattern(TypedDict):
@@ -5019,7 +5134,9 @@ class TextDocumentFilterPattern(TypedDict):
50195134
pattern: 'GlobPattern'
50205135
""" A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples.
50215136
5022-
@since 3.18.0 - support for relative patterns. """
5137+
@since 3.18.0 - support for relative patterns. Whether clients support
5138+
relative patterns depends on the client capability
5139+
`textDocuments.filters.relativePatternSupport`. """
50235140

50245141

50255142
class NotebookDocumentFilterNotebookType(TypedDict):
@@ -5280,6 +5397,13 @@ class TextDocumentSyncClientCapabilities(TypedDict):
52805397
""" The client supports did save notifications. """
52815398

52825399

5400+
class TextDocumentFilterClientCapabilities(TypedDict):
5401+
relativePatternSupport: NotRequired[bool]
5402+
""" The client supports Relative Patterns.
5403+
5404+
@since 3.18.0 """
5405+
5406+
52835407
class CompletionClientCapabilities(TypedDict):
52845408
""" Completion client capabilities """
52855409
dynamicRegistration: NotRequired[bool]
@@ -5449,6 +5573,11 @@ class CodeActionClientCapabilities(TypedDict):
54495573
54505574
@since 3.18.0
54515575
@proposed """
5576+
tagSupport: NotRequired['CodeActionTagOptions']
5577+
""" Client supports the tag property on a code action. Clients
5578+
supporting tags have to handle unknown tags gracefully.
5579+
5580+
@since 3.18.0 - proposed """
54525581

54535582

54545583
class CodeLensClientCapabilities(TypedDict):
@@ -5895,6 +6024,18 @@ class CompletionListCapabilities(TypedDict):
58956024
no properties are supported.
58966025
58976026
@since 3.17.0 """
6027+
applyKindSupport: NotRequired[bool]
6028+
""" Specifies whether the client supports `CompletionList.applyKind` to
6029+
indicate how supported values from `completionList.itemDefaults`
6030+
and `completion` will be combined.
6031+
6032+
If a client supports `applyKind` it must support it for all fields
6033+
that it supports that are listed in `CompletionList.applyKind`. This
6034+
means when clients add support for new/future fields in completion
6035+
items the MUST also support merge for them if those fields are
6036+
defined in `CompletionList.applyKind`.
6037+
6038+
@since 3.18.0 """
58986039

58996040

59006041
class ClientSignatureInformationOptions(TypedDict):
@@ -5931,6 +6072,12 @@ class ClientCodeActionResolveOptions(TypedDict):
59316072
""" The properties that a client can resolve lazily. """
59326073

59336074

6075+
class CodeActionTagOptions(TypedDict):
6076+
""" @since 3.18.0 - proposed """
6077+
valueSet: List['CodeActionTag']
6078+
""" The tags supported by the client. """
6079+
6080+
59346081
class ClientCodeLensResolveOptions(TypedDict):
59356082
""" @since 3.18.0 """
59366083
properties: List[str]

0 commit comments

Comments
 (0)