-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathprotocol.lua
More file actions
1851 lines (1505 loc) · 59.8 KB
/
protocol.lua
File metadata and controls
1851 lines (1505 loc) · 59.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--
-- This file defines some of the LSP protocol elements as needed
-- for type hinting usage with the sumneko lua language server.
--
-- LSP Documentation:
-- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification
local protocol = {}
---Generic array type for lsp.
---@alias array table<integer,any>
---Generic object type for lsp.
---@alias object table<string,any>
---Defines an unsigned integer number in the range of 0 to 2^31 - 1.
---@alias uinteger integer
---Defines a decimal number. Since decimal numbers are very
---rare in the language server specification we denote the
---exact range with every decimal using the mathematics
---interval notation (e.g. [0, 1] denotes all decimals d with
---0 <= d <= 1.
---@alias decimal integer
---URI’s are transferred as strings. The URI’s format is defined in https://tools.ietf.org/html/rfc3986
---@alias lsp.protocol.DocumentURI string
---URI's are transferred as strings. DocumentUri is an alias kept by the
---upstream specification for generated protocol definitions.
---@alias lsp.protocol.DocumentUri lsp.protocol.DocumentURI
---LSP object definition.
---
---since 3.17.0
---@alias lsp.protocol.LSPObject table<string,lsp.protocol.LSPAny>
---LSP arrays.
---
---since 3.17.0
---@alias lsp.protocol.LSPArray lsp.protocol.LSPAny[]
---The LSP any type
---
---since 3.17.0
---@alias lsp.protocol.LSPAny lsp.protocol.LSPObject | lsp.protocol.LSPArray | string | integer | uinteger | decimal | boolean | nil
---An identifier referring to a change annotation managed by a workspace edit.
---
---since 3.16.0.
---@alias lsp.protocol.ChangeAnnotationIdentifier string
---Position in a text document expressed as zero-based line and zero-based
---character offset. A position is between two characters like an ‘insert’
---cursor in an editor. Special values like for example -1 to denote the end
---of a line are not supported.
---@class lsp.protocol.Position
---Line position in a document (zero-based).
---@field line integer
---Character offset on a line in a document (zero-based). The meaning of this
---offset is determined by the negotiated `PositionEncodingKind`.
---
---If the character value is greater than the line length it defaults back
---to the line length.
---@field character integer
---A range in a text document expressed as (zero-based) start and end
---positions. A range is comparable to a selection in an editor. Therefore,
---the end position is exclusive. If you want to specify a range that contains
---a line including the line ending character(s) then use an end position
---denoting the start of the next line. For example:
---@class lsp.protocol.Range
---The range's start position.
---@field start lsp.protocol.Position
---The range's end position.
---@field end lsp.protocol.Position
---A textual edit applicable to a text document.
---@class lsp.protocol.TextEdit
---The range of the text document to be manipulated. To insert
---text into a document create a range where start === end.
---@field newText string
---The string to be inserted. For delete operations use an
---empty string.
---@field range lsp.protocol.Range
---@class lsp.protocol.AnnotatedTextEdit : lsp.protocol.TextEdit
---The actual annotation identifier.
---@field annotationId lsp.protocol.ChangeAnnotationIdentifier
---A special text edit to provide an insert and a replace operation.
---since 3.16.0
---@class lsp.protocol.InsertReplaceEdit
---The string to be inserted.
---@field newText string
---The range if the insert is requested
---@field insert lsp.protocol.Range
---The range if the replace is requested.
---@field replace lsp.protocol.Range
---Text documents are identified using a URI. On the protocol level, URIs are
---passed as strings. The corresponding JSON structure looks like this:
---@class lsp.protocol.TextDocumentIdentifier
---The text document's URI.
---@field uri lsp.protocol.DocumentURI
---An identifier which optionally denotes a specific version of a text
---document. This information usually flows from the server to the client.
---@class lsp.protocol.OptionalVersionedTextDocumentIdentifier : lsp.protocol.TextDocumentIdentifier
---The version number of this document. If an optional versioned text document
---identifier is sent from the server to the client and the file is not
---open in the editor (the server has not received an open notification
---before) the server can send `null` to indicate that the version is
---known and the content on disk is the master (as specified with document
---content ownership).
---
---The version number of a document will increase after each change,
---including undo/redo. The number doesn't need to be consecutive.
---@field version? integer
---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.
---
---Describes textual changes on a single text document. The text document is
---referred to as a 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.
---@class lsp.protocol.TextDocumentEdit
---The text document to change.
---@field textDocument lsp.protocol.OptionalVersionedTextDocumentIdentifier
---The edits to be applied.
---
---since 3.16.0 - support for AnnotatedTextEdit. This is guarded by the
---client capability `workspace.workspaceEdit.changeAnnotationSupport`
---@field edits lsp.protocol.TextEdit[] | lsp.protocol.AnnotatedTextEdit[]
---Options to create a file.
---@class lsp.protocol.CreateFileOptions
---Overwrite existing file. Overwrite wins over `ignoreIfExists`
---@field overwrite? boolean
---Ignore if exists.
---@field ignoreIfExists? boolean
---Create file operation
---@class lsp.protocol.CreateFile
---A create
---@field kind 'create'
---The resource to create.
---@field uri lsp.protocol.DocumentURI
---Additional options
---@field options? lsp.protocol.CreateFileOptions
---An optional annotation identifier describing the operation.
---
---since 3.16.0
---@field annotationId? lsp.protocol.ChangeAnnotationIdentifier
---Rename file options
---@class lsp.protocol.RenameFileOptions
---Overwrite target if existing. Overwrite wins over `ignoreIfExists`
---@field overwrite? boolean
---Ignores if target exists.
---@field ignoreIfExists? boolean
---Rename file operation
---@class lsp.protocol.RenameFile
---A rename
---@field kind 'rename'
---The old (existing) location.
---@field oldUri lsp.protocol.DocumentURI
---The new location.
---@field newUri lsp.protocol.DocumentURI
---Rename options.
---@field options? lsp.protocol.RenameFileOptions
---An optional annotation identifier describing the operation.
---
---since 3.16.0
---@field annotationId? lsp.protocol.ChangeAnnotationIdentifier
---Delete file options
---@class lsp.protocol.DeleteFileOptions
---Delete the content recursively if a folder is denoted.
---@field recursive? boolean
---Ignore the operation if the file doesn't exist.
---@field ignoreIfNotExists? boolean
---Delete file operation
---@class lsp.protocol.DeleteFile
---A delete
---@field kind 'delete'
---The file to delete.
---@field uri lsp.protocol.DocumentURI
---Delete options
---@field options? lsp.protocol.DeleteFileOptions
---An optional annotation identifier describing the operation.
---
---since 3.16.0
---@field annotationId? lsp.protocol.ChangeAnnotationIdentifier
---Additional information that describes document changes.
---
---since 3.16.0
---@class lsp.protocol.ChangeAnnotation
---A human-readable string describing the actual change. The string
---is rendered prominent in the user interface.
---@field label string
---A flag which indicates that user confirmation is needed
---before applying the change.
---@field needsConfirmation? boolean
---A human-readable string which is rendered less prominent in
---the user interface.
---@field description? string
---Alias for the WorkspaceEdit documentChanges field type.
---@alias lsp.protocol.WorkspaceEditDocumentChange lsp.protocol.TextDocumentEdit | lsp.protocol.CreateFile | lsp.protocol.RenameFile | lsp.protocol.DeleteFile
---A workspace edit represents changes to many resources managed in the
---workspace. The edit should either provide changes or documentChanges. If the
---client can handle versioned document edits and if documentChanges are
---present, the latter are preferred over changes.
---
---Since version 3.13.0 a workspace edit can contain resource operations
---(create, delete or rename files and folders) as well. If resource operations
---are present clients need to execute the operations in the order in which
---they are provided. So a workspace edit for example can consist of the
---following two changes: (1) create file a.txt and (2) a text document edit
---which insert text into file a.txt. An invalid sequence (e.g. (1) delete
---file a.txt and (2) insert text into file a.txt) will cause failure of the
---operation. How the client recovers from the failure is described by the
---client capability: workspace.workspaceEdit.failureHandling
---@class lsp.protocol.WorkspaceEdit
---Holds changes to existing resources.
---@field changes? table<lsp.protocol.DocumentURI,lsp.protocol.TextEdit[]>
---Depending on the client capability
---`workspace.workspaceEdit.resourceOperations` document changes are either
---an array of `TextDocumentEdit`s to express changes to n different text
---documents where each text document edit addresses a specific version of
---a text document. Or it can contain above `TextDocumentEdit`s mixed with
---create, rename and delete file / folder operations.
---
---Whether a client supports versioned document edits is expressed via
---`workspace.workspaceEdit.documentChanges` client capability.
---
---If a client neither supports `documentChanges` nor
---`workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s
---using the `changes` property are supported.
---
---@field documentChanges? lsp.protocol.TextDocumentEdit[] | lsp.protocol.WorkspaceEditDocumentChange[]
---A map of change annotations that can be referenced in
---`AnnotatedTextEdit`s or create, rename and delete file / folder
---operations.
---
---Whether clients honor this property depends on the client capability
---`workspace.changeAnnotationSupport`.
---
---since 3.16.0
---@field changeAnnotations? table<string,lsp.protocol.ChangeAnnotation>
---The parameters passed via a workspace/applyEdit request.
---@class lsp.protocol.ApplyWorkspaceEditParams
---An optional label of the workspace edit. This label is presented in the user
---interface for example on an undo stack to undo the workspace edit.
---@field label? string
---The edits to apply.
---@field edit lsp.protocol.WorkspaceEdit
---The result returned from a workspace/applyEdit request.
---@class lsp.protocol.ApplyWorkspaceEditResult
---Indicates whether the edit was applied or not.
---@field applied boolean
---An optional textual description for why the edit was not applied.
---@field failureReason? string
---The parameters of a workspace/executeCommand request.
---@class lsp.protocol.ExecuteCommandParams
---The identifier of the actual command handler.
---@field command string
---Arguments that the command should be invoked with.
---@field arguments? lsp.protocol.LSPAny[]
---Represents a location inside a resource, such as a line inside a text file.
---@class lsp.protocol.Location
---@field uri lsp.protocol.DocumentURI
---@field range lsp.protocol.Range
---Represents the connection of two locations. Provides additional metadata
---over normal locations, including origin and target selection ranges.
---@class lsp.protocol.LocationLink
---@field originSelectionRange? lsp.protocol.Range
---@field targetUri lsp.protocol.DocumentURI
---@field targetRange lsp.protocol.Range
---@field targetSelectionRange lsp.protocol.Range
---An item to transfer a text document from the client to the server.
---@class lsp.protocol.TextDocumentItem
---@field uri lsp.protocol.DocumentURI
---@field languageId string
---@field version integer
---@field text string
---An identifier to denote a specific version of a text document.
---@class lsp.protocol.VersionedTextDocumentIdentifier : lsp.protocol.TextDocumentIdentifier
---@field version integer
---A parameter literal used in requests to pass a text document and a position
---inside that document.
---@class lsp.protocol.TextDocumentPositionParams
---@field textDocument lsp.protocol.TextDocumentIdentifier
---@field position lsp.protocol.Position
---A document filter describes a top level text document or notebook cell
---document by language, scheme, or glob pattern.
---@class lsp.protocol.DocumentFilter
---@field language? string
---@field scheme? string
---@field pattern? string
---A document selector is the combination of one or more document filters.
---@alias lsp.protocol.DocumentSelector lsp.protocol.DocumentFilter[]
---Text document save options.
---@class lsp.protocol.SaveOptions
---The client is supposed to include the content on save.
---@field includeText? boolean
---Defines how text documents are synced.
---@class lsp.protocol.TextDocumentSyncOptions
---@field openClose? boolean
---@field change? lsp.protocol.TextDocumentSyncKind
---@field willSave? boolean
---@field willSaveWaitUntil? boolean
---@field save? boolean | lsp.protocol.SaveOptions
---A general message as defined by JSON-RPC. The language server protocol
---always uses “2.0” as the jsonrpc version.
---@class lsp.protocol.Message
---The language server protocol always uses “2.0” as the jsonrpc version.
---@field jsonrpc string
---A request message to describe a request between the client and the server.
---Every processed request must send a response back to the sender of the request.
---@class lsp.protocol.RequestMessage
---The request id.
---@field id integer | string
---The method to be invoked.
---@field method string
---The method's params.
---@field params array | object
---@class lsp.protocol.ResponseError
---A number indicating the error type that occurred.
---@field code integer
---A string providing a short description of the error.
---@field message string
---A primitive or structured value that contains additional
---information about the error. Can be omitted.
---@field data? string | number | boolean | array | object | nil
---A Response Message sent as a result of a request. If a request doesn’t
---provide a result value the receiver of a request still needs to return a
---response message to conform to the JSON-RPC specification. The result
---property of the ResponseMessage should be set to null in this case to signal
---a successful request.
---@class lsp.protocol.ResponseMessage : lsp.protocol.Message
---The request id.
---@field id integer | string | nil
---The result of a request. This member is REQUIRED on success.
---This member MUST NOT exist if there was an error invoking the method.
---@field result? string | number | boolean | array | object
---The error object in case a request fails.
---@field error? lsp.protocol.ResponseError
---A notification message. A processed notification message must not send a
---response back. They work like events.
---@class lsp.protocol.NotificationMessage : lsp.protocol.Message
---The method to be invoked.
---@field method string
---The notification's params.
---@field params? array | object
---Symbol tags are extra annotations that tweak the rendering of a symbol.
---
---since 3.16
---@enum lsp.protocol.SymbolTag
protocol.SymbolTag = {
---Render a symbol as obsolete, usually using a strike-out.
Deprecated = 1
}
---A symbol kind.
---@enum lsp.protocol.SymbolKind
protocol.SymbolKind = {
File = 1,
Module = 2,
Namespace = 3,
Package = 4,
Class = 5,
Method = 6,
Property = 7,
Field = 8,
Constructor = 9,
Enum = 10,
Interface = 11,
Function = 12,
Variable = 13,
Constant = 14,
String = 15,
Number = 16,
Boolean = 17,
Array = 18,
Object = 19,
Key = 20,
Null = 21,
EnumMember = 22,
Struct = 23,
Event = 24,
Operator = 25,
TypeParameter = 26
}
---Represents programming constructs like variables, classes, interfaces etc.
---that appear in a document. Document symbols can be hierarchical and they
---have two ranges: one that encloses its definition and one that points to its
---most interesting range, e.g. the range of an identifier.
---@class lsp.protocol.DocumentSymbol
---The name of this symbol. Will be displayed in the user interface and
---therefore must not be an empty string or a string only consisting of
---white spaces.
---@field name string
---More detail for this symbol, e.g the signature of a function.
---@field detail? string
---The kind of this symbol.
---@field kind lsp.protocol.SymbolKind
---Tags for this document symbol.
---
---since 3.16.0
---@field tags? lsp.protocol.SymbolTag[]
---Indicates if this symbol is deprecated.
---
---deprecated Use tags instead
---@field deprecated? boolean
---The range enclosing this symbol not including leading/trailing whitespace
---but everything else like comments. This information is typically used to
---determine if the clients cursor is inside the symbol to reveal in the
---symbol in the UI.
---@field range lsp.protocol.Range
---The range that should be selected and revealed when this symbol is being
---picked, e.g. the name of a function. Must be contained by the `range`.
---@field selectionRange lsp.protocol.Range
---Children of this symbol, e.g. properties of a class.
---@field children? lsp.protocol.DocumentSymbol[]
---Represents information about programming constructs like variables, classes,
---interfaces etc.
---
---deprecated use DocumentSymbol or WorkspaceSymbol instead.
---@class lsp.protocol.SymbolInformation
---The name of this symbol.
---@field name string
---The kind of this symbol.
---@field kind lsp.protocol.SymbolKind
---Tags for this symbol.
---
---since 3.16.0
---@field tags? lsp.protocol.SymbolTag[]
---Indicates if this symbol is deprecated.
---
---deprecated Use tags instead
---@field deprecated? boolean
---The location of this symbol. The location's range is used by a tool
---to reveal the location in the editor. If the symbol is selected in the
---tool the range's start information is used to position the cursor. So
---the range usually spans more then the actual symbol's name and does
---normally include things like visibility modifiers.
---
---The range doesn't have to denote a node range in the sense of an abstract
---syntax tree. It can therefore not be used to re-construct a hierarchy of
---the symbols.
---@field location lsp.protocol.Location
---The name of the symbol containing this symbol. This information is for
---user interface purposes (e.g. to render a qualifier in the user interface
---if necessary). It can't be used to re-infer a hierarchy for the document
---symbols.
---@field containerName? string
---List of codes returned on response error messages.
---@enum lsp.protocol.ErrorCodes
protocol.ErrorCodes = {
ParseError = -32700,
InvalidRequest = -32600,
MethodNotFound = -32601,
InvalidParams = -32602,
InternalError = -32603,
---This is the start range of JSON-RPC reserved error codes.
---It doesn't denote a real error code. No LSP error codes should
---be defined between the start and end range. For backwards
---compatibility the `ServerNotInitialized` and the `UnknownErrorCode`
---are left in the range.
---
---since 3.16.0
jsonrpcReservedErrorRangeStart = -32099,
---deprecated use jsonrpcReservedErrorRangeStart
serverErrorStart = -32099,
---Error code indicating that a server received a notification or
---request before the server has received the `initialize` request.
ServerNotInitialized = -32002,
UnknownErrorCode = -32001,
---This is the end range of JSON-RPC reserved error codes.
---It doesn't denote a real error code.
---
---since 3.16.0
jsonrpcReservedErrorRangeEnd = -32000,
---deprecated use jsonrpcReservedErrorRangeEnd
serverErrorEnd = -32000,
---This is the start range of LSP reserved error codes.
---It doesn't denote a real error code.
---
---since 3.16.0
lspReservedErrorRangeStart = -32899,
---A request failed but it was syntactically correct, e.g the
---method name was known and the parameters were valid. The error
---message should contain human readable information about why
---the request failed.
---
---since 3.17.0
RequestFailed = -32803,
---The server cancelled the request. This error code should
---only be used for requests that explicitly support being
---server cancellable.
---
---since 3.17.0
ServerCancelled = -32802,
---The server detected that the content of a document got
---modified outside normal conditions. A server should
---NOT send this error code if it detects a content change
---in it unprocessed messages. The result even computed
---on an older state might still be useful for the client.
---
---If a client decides that a result is not of any use anymore
---the client should cancel the request.
ContentModified = -32801,
---The client has canceled a request and a server as detected
---the cancel.
RequestCancelled = -32800,
---This is the end range of LSP reserved error codes.
---It doesn't denote a real error code.
---
---since 3.16.0
lspReservedErrorRangeEnd = -32800,
}
---How a completion was triggered
---@enum lsp.protocol.CompletionTriggerKind
protocol.CompletionTriggerKind = {
---Completion was triggered by typing an identifier (24x7 code
---complete), manual invocation (e.g Ctrl+Space) or via API.
Invoked = 1,
---Completion was triggered by a trigger character specified by
--the `triggerCharacters` properties of the
---`CompletionRegistrationOptions`.
TriggerCharacter = 2,
---Completion was re-triggered as the current completion list is incomplete.
TriggerForIncompleteCompletions = 3
}
---The protocol currently supports the following diagnostic severities and tags:
---@enum lsp.protocol.DiagnosticSeverity
protocol.DiagnosticSeverity = {
---Reports an error.
Error = 1,
---Reports a warning.
Warning = 2,
---Reports an information.
Information = 3,
---Reports a hint.
Hint = 4
}
---Defines how the host (editor) should sync document changes to the language
---server.
---@enum lsp.protocol.TextDocumentSyncKind
protocol.TextDocumentSyncKind = {
---Documents should not be synced at all.
None = 0,
---Documents are synced by always sending the full content
---of the document.
Full = 1,
---Documents are synced by sending the full content on open.
---After that only incremental updates to the document are
---sent.
Incremental = 2
}
---The kind of a completion entry.
---@enum lsp.protocol.CompletionItemKind
protocol.CompletionItemKind = {
Text = 1,
Method = 2,
Function = 3,
Constructor = 4,
Field = 5,
Variable = 6,
Class = 7,
Interface = 8,
Module = 9,
Property = 10,
Unit = 11,
Value = 12,
Enum = 13,
Keyword = 14,
Snippet = 15,
Color = 16,
File = 17,
Reference = 18,
Folder = 19,
EnumMember = 20,
Constant = 21,
Struct = 22,
Event = 23,
Operator = 24,
TypeParameter = 25
}
---Used for easy integer to string matching
---@type table<integer,string>
---@see lsp.protocol.CompletionItemKind
protocol.CompletionItemKindString = {
'Text', 'Method', 'Function', 'Constructor', 'Field', 'Variable', 'Class',
'Interface', 'Module', 'Property', 'Unit', 'Value', 'Enum', 'Keyword',
'Snippet', 'Color', 'File', 'Reference', 'Folder', 'EnumMember',
'Constant', 'Struct', 'Event', 'Operator', 'TypeParameter'
}
---A symbol kind.
---@enum lsp.protocol.SymbolKind
protocol.SymbolKind = {
File = 1,
Module = 2,
Namespace = 3,
Package = 4,
Class = 5,
Method = 6,
Property = 7,
Field = 8,
Constructor = 9,
Enum = 10,
Interface = 11,
Function = 12,
Variable = 13,
Constant = 14,
String = 15,
Number = 16,
Boolean = 17,
Array = 18,
Object = 19,
Key = 20,
Null = 21,
EnumMember = 22,
Struct = 23,
Event = 24,
Operator = 25,
TypeParameter = 26
}
---Used for easy integer to string matching
---@type table<integer,string>
---@see lsp.protocol.SymbolKind
protocol.SymbolKindString = {
'File', 'Module', 'Namespace', 'Package', 'Class', 'Method', 'Property',
'Field', 'Constructor', 'Enum', 'Interface', 'Function', 'Variable',
'Constant', 'String', 'Number', 'Boolean', 'Array', 'Object', 'Key',
'Null', 'EnumMember', 'Struct', 'Event', 'Operator', 'TypeParameter'
}
---Defines whether the insert text in a completion item should be interpreted as
---plain text or a snippet.
---@enum lsp.protocol.InsertTextFormat
protocol.InsertTextFormat = {
---The primary text to be inserted is treated as a plain string.
PlainText = 1,
---The primary text to be inserted is treated as a snippet.
---
---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. Placeholders with equal identifiers are linked,
---that is typing in one will update others too.
Snippet = 2
}
---How whitespace and indentation is handled during completion
---item insertion.
---
---since 3.16.0
---@enum lsp.protocol.InsertTextMode
protocol.InsertTextMode = {
---The insertion or replace strings is taken as it is. If the
---value is multi line the lines below the cursor will be
---inserted using the indentation defined in the string value.
---The client will not apply any kind of adjustments to the
---string.
asIs = 1,
---The editor adjusts leading whitespace of new lines so that
---they match the indentation up to the cursor of the line for
---which the item is accepted.
---
---Consider a line like this: <2tabs><cursor><3tabs>foo. Accepting a
---multi line completion item is indented using 2 tabs and all
---following lines inserted will be indented using 2 tabs as well.
adjustIndentation = 2
}
---A message type.
---@enum lsp.protocol.MessageType
protocol.MessageType = {
---An error message.
Error = 1,
---A warning message.
Warning = 2,
---An information message.
Info = 3,
---A log message.
Log = 4,
---A debug message.
---
---since 3.18.0
Debug = 5
}
---A set of predefined position encoding kinds.
---
---since 3.17.0
---@enum lsp.protocol.PositionEncodingKind
protocol.PositionEncodingKind = {
---Character offsets count UTF-8 code units (e.g bytes).
UTF8 = 'utf-8',
---Character offsets count UTF-16 code units.
---
---This is the default and must always be supported
---by servers
UTF16 = 'utf-16',
---Character offsets count UTF-32 code units.
---
---Implementation note: these are the same as Unicode code points,
---so this `PositionEncodingKind` may also be used for an
---encoding-agnostic representation of character offsets.
UTF32 = 'utf-32'
}
---Describes the content type that a client supports in various
---result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
---
---Please note that `MarkupKinds` must not start with a `$`. This kinds
---are reserved for internal usage.
---@enum lsp.protocol.MarkupKind
protocol.MarkupKind = {
---Plain text is supported as a content format
PlainText = 'plaintext',
---Markdown is supported as a content format
Markdown = 'markdown'
}
---A `MarkupContent` literal represents a string value which content is
---interpreted base on its kind flag. Currently the protocol supports
---`plaintext` and `markdown` as markup kinds.
---
---If the kind is `markdown` then the value can contain fenced code blocks like
---in GitHub issues.
---
---Here is an example how such a string can be constructed using
---JavaScript / TypeScript:
---```typescript
---let markdown: MarkdownContent = {
--- kind: MarkupKind.Markdown,
--- value: [
--- '# Header',
--- 'Some text',
--- '```typescript',
--- 'someCode();',
--- '```'
--- ].join('\n')
---};
---```
---
---*Please Note* that clients might sanitize the return markdown. A client could
---decide to remove HTML from the markdown to avoid script execution.
---@class lsp.protocol.MarkupContent
---The type of the Markup
---@field kind lsp.protocol.MarkupKind
---The content itself
---@field value string
---A set of predefined code action kinds.
---@enum lsp.protocol.CodeActionKind
protocol.CodeActionKind = {
---Empty kind.
Empty = '',
---Base kind for quickfix actions: 'quickfix'.
QuickFix = 'quickfix',
---Base kind for refactoring actions: 'refactor'.
Refactor = 'refactor',
---Base kind for refactoring extraction actions: 'refactor.extract'.
---
---Example extract actions:
---
--- Extract method
--- Extract function
--- Extract variable
--- Extract interface from class
--- ...
RefactorExtract = 'refactor.extract',
---Base kind for refactoring inline actions: 'refactor.inline'.
---
---Example inline actions:
---
--- Inline function
--- Inline variable
--- Inline constant
--- ...
RefactorInline = 'refactor.inline',
---Base kind for refactoring rewrite actions: 'refactor.rewrite'.
---
---Example rewrite actions:
---
--- Convert JavaScript function to class
--- Add or remove parameter
--- Encapsulate field
--- Make method static
--- Move method to base class
--- ...
RefactorRewrite = 'refactor.rewrite',
---Base kind for source actions: `source`.
---
---Source code actions apply to the entire file.
Source = 'source',
---Base kind for an organize imports source action:
---`source.organizeImports`.
SourceOrganizeImports = 'source.organizeImports',
---Base kind for a 'fix all' source action: `source.fixAll`.
---
---'Fix all' actions automatically fix errors that have a clear fix that
---do not require user input. They should not suppress errors or perform
---unsafe fixes such as generating new types or classes.
---
---since 3.17.0
SourceFixAll = 'source.fixAll'
}
---@enum lsp.protocol.PrepareSupportDefaultBehavior
protocol.PrepareSupportDefaultBehavior = {
---The client's default behavior is to select the identifier
---according to the language's syntax rule.
Identifier = 1
}
---The diagnostic tags.
---
---since 3.15.0
---@enum lsp.protocol.DiagnosticTag
protocol.DiagnosticTag = {
--- Unused or unnecessary code.
---
--- Clients are allowed to render diagnostics with this tag faded out
--- instead of having an error squiggle.
Unnecessary = 1,
--- Deprecated or obsolete code.
---
--- Clients are allowed to rendered diagnostics with this tag strike through.
Deprecated = 2
}
---A set of predefined range kinds.
---@enum lsp.protocol.FoldingRangeKind
protocol.FoldingRangeKind = {
---Folding range for a comment
Comment = 'comment',
---Folding range for imports or includes
Imports = 'imports',
---Folding range for a region (e.g. `#region`)
Region = 'region'
}
---The protocol defines an additional token format capability to allow future
---extensions of the format. The only format that is currently specified is
---relative expressing that the tokens are described using relative positions.
---@enum lsp.protocol.TokenFormat
protocol.TokenFormat = {
Relative = 'relative'
}
---A document highlight kind.
---@enum lsp.protocol.DocumentHighlightKind
protocol.DocumentHighlightKind = {
Text = 1,
Read = 2,
Write = 3
}
---A code action trigger kind.
---@enum lsp.protocol.CodeActionTriggerKind
protocol.CodeActionTriggerKind = {
Invoked = 1,
Automatic = 2
}
---Moniker uniqueness level.
---@enum lsp.protocol.UniquenessLevel
protocol.UniquenessLevel = {
document = 'document',
project = 'project',
group = 'group',
scheme = 'scheme',
global = 'global'
}
---Moniker kind.
---@enum lsp.protocol.MonikerKind
protocol.MonikerKind = {
Import = 'import',
Export = 'export',
Local = 'local'
}
---Inlay hint kind.
---
---since 3.17.0
---@enum lsp.protocol.InlayHintKind
protocol.InlayHintKind = {
Type = 1,
Parameter = 2
}
---The document diagnostic report kind.
---
---since 3.17.0
---@enum lsp.protocol.DocumentDiagnosticReportKind