-
Notifications
You must be signed in to change notification settings - Fork 11
/
Capabilities.lean
547 lines (439 loc) · 18.9 KB
/
Capabilities.lean
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
/-
Copyright (c) 2022 Mac Malone. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mac Malone
-/
import Lean.Data.Lsp.Capabilities
open Lean Lsp
namespace Alloy
structure EmptyObject deriving ToJson, FromJson
instance : EmptyCollection EmptyObject := ⟨.mk⟩
def Union := Sum
namespace Union
def inl (a : α) : Union α β := Sum.inl a
def inr (b : β) : Union α β := Sum.inr b
end Union
instance [ToJson α] [ToJson β] : ToJson (Union α β) where
toJson | .inl a => toJson a | .inr b => toJson b
instance [FromJson α] [FromJson β] : FromJson (Union α β) where
fromJson? v :=
match fromJson? v with
| .ok a => .ok <| .inl a
| .error _ => .inr <$> fromJson? v
--
structure WorkDoneProgressOptions where
workDoneProgress? : Option Bool := none
deriving instance DecidableEq for SymbolKind
instance : FromJson SymbolKind where
fromJson? v := do
let i : Nat ← fromJson? v
return SymbolKind.ofNat (i-1)
deriving instance DecidableEq for SymbolTag
instance : FromJson SymbolTag where
fromJson? v := return .ofNat ((← fromJson? v)-1)
inductive CompletionItemTag where
| deprecated
deriving Inhabited, DecidableEq, Repr
instance : ToJson CompletionItemTag where
toJson a := toJson <| a.toCtorIdx + 1
instance : FromJson CompletionItemTag where
fromJson? v := return .ofNat ((← fromJson? v)-1)
inductive InsertTextMode where
| asIs | adjustIndentation
deriving Inhabited, DecidableEq, Repr
instance : ToJson InsertTextMode where
toJson a := toJson <| a.toCtorIdx + 1
instance : FromJson InsertTextMode where
fromJson? v := return .ofNat ((← fromJson? v)-1)
inductive PrepareSupportDefaultBehavior where
| identifier
deriving Inhabited, DecidableEq, Repr
instance : ToJson PrepareSupportDefaultBehavior where
toJson a := toJson <| a.toCtorIdx + 1
instance : FromJson PrepareSupportDefaultBehavior where
fromJson? v := return .ofNat ((← fromJson? v)-1)
inductive DiagnosticTag where
| unnecessary | deprecated
deriving Inhabited, DecidableEq, Repr
instance : ToJson DiagnosticTag where
toJson a := toJson <| a.toCtorIdx + 1
instance : FromJson DiagnosticTag where
fromJson? v := return .ofNat ((← fromJson? v)-1)
deriving instance FromJson for FoldingRangeKind
---
inductive ResourceOperationKind
| create | rename | delete
deriving ToJson, FromJson
inductive FailureHandlingKind
| abort | transactional | undo | textOnlyTransactional
deriving ToJson, FromJson
structure ChangeAnnotationSupportClientCapabilities where
groupsOnLabel? : Option Bool := none
deriving ToJson, FromJson
structure WorkspaceEditClientCapabilities where
documentChanges? : Option Bool := none
resourceOperations? : Option (Array ResourceOperationKind) := none
failureHandling? : Option FailureHandlingKind := none
normalizeLineEndings? : Option Bool := none
changeAnnotationSupport? : Option ChangeAnnotationSupportClientCapabilities := none
deriving ToJson, FromJson
structure DidChangeConfigurationClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure DidChangeWatchedFilesClientCapabilities where
dynamicRegistration? : Option Bool := none
relativePatternSupport? : Option Bool := none
deriving ToJson, FromJson
structure SymbolKindCapabilities where
valueSet? : Option (Array SymbolKind) := none
deriving ToJson, FromJson
structure SymbolTagSupportCapabilities where
valueSet : Array SymbolTag
deriving ToJson, FromJson
structure ResolveSupportCapabilities where
properties : Array String
deriving ToJson, FromJson
structure WorkspaceSymbolClientCapabilities where
dynamicRegistration? : Option Bool := none
symbolKind? : Option SymbolKindCapabilities := none
tagSupport? : Option SymbolTagSupportCapabilities := none
resolveSupport? : Option ResolveSupportCapabilities := none
deriving ToJson, FromJson
structure ExecuteCommandClientCapabilities extends WorkDoneProgressOptions where
commands : Array String
deriving ToJson, FromJson
structure SemanticTokensWorkspaceClientCapabilities where
refreshSupport? : Option Bool := none
deriving ToJson, FromJson
structure CodeLensWorkspaceClientCapabilities where
refreshSupport? : Option Bool := none
deriving ToJson, FromJson
structure FileOperationsCapabilities where
dynamicRegistration? : Option Bool := none
didCreate? : Option Bool := none
willCreate? : Option Bool := none
didRename? : Option Bool := none
willRename? : Option Bool := none
didDelete? : Option Bool := none
willDelete? : Option Bool := none
deriving ToJson, FromJson
structure InlineValueWorkspaceClientCapabilities where
refreshSupport? : Option Bool := none
deriving ToJson, FromJson
structure InlayHintWorkspaceClientCapabilities where
refreshSupport? : Option Bool := none
deriving ToJson, FromJson
structure DiagnosticWorkspaceClientCapabilities where
refreshSupport? : Option Bool := none
deriving ToJson, FromJson
structure WorkspaceClientCapabilities where
applyEdit? : Option Bool := none
workspaceEdit? : Option WorkspaceEditClientCapabilities := none
didChangeConfiguration? : Option DidChangeConfigurationClientCapabilities := none
didChangeWatchedFiles? : Option DidChangeWatchedFilesClientCapabilities := none
symbol? : Option WorkspaceSymbolClientCapabilities := none
executeCommand? : Option ExecuteCommandClientCapabilities := none
workspaceFolders? : Option Bool := none
configuration? : Option Bool := none
semanticTokens? : Option SemanticTokensWorkspaceClientCapabilities := none
codeLens? : Option CodeLensWorkspaceClientCapabilities := none
fileOperations? : Option FileOperationsCapabilities := none
inlineValue? : Option InlineValueWorkspaceClientCapabilities := none
inlayHint? : Option InlayHintWorkspaceClientCapabilities := none
diagnostics? : Option DiagnosticWorkspaceClientCapabilities := none
deriving ToJson, FromJson
structure TextDocumentSyncClientCapabilities where
dynamicRegistration? : Option Bool := none
willSave? : Option Bool := none
willSaveWaitUntil? : Option Bool := none
didSave? : Option Bool := none
deriving ToJson, FromJson
structure CompletionItemTagSupportCapabilities where
valueSet : Array CompletionItemTag
deriving ToJson, FromJson
structure InsertTextModeSupportCapabilities where
valueSet : Array InsertTextMode
deriving ToJson, FromJson
structure CompletionItemCapabilities where
snippetSupport? : Option Bool := none
commitCharactersSupport? : Option Bool := none
documentationFormat? : Option (Array MarkupKind) := none
deprecatedSupport? : Option Bool := none
preselectSupport? : Option Bool := none
tagSupport? : Option CompletionItemTagSupportCapabilities := none
insertReplaceSupport? : Option Bool := none
insertTextModeSupport? : Option InsertTextModeSupportCapabilities := none
resolveSupport? : Option ResolveSupportCapabilities := none
labelDetailsSupport? : Option Bool := none
deriving ToJson, FromJson
structure CompletionItemKindCapabilities where
valueSet? : Option (Array CompletionItemKind) := none
deriving ToJson, FromJson
structure CompletionListCapabilities where
itemDefaults? : Option (Array String) := none
deriving ToJson, FromJson
structure CompletionClientCapabilities where
dynamicRegistration? : Option Bool := none
completionItem? : Option CompletionItemCapabilities := none
completionItemKind? : Option CompletionItemKindCapabilities := none
contextSupport? : Option Bool := none
insertTextMode? : Option InsertTextMode := none
completionList? : Option CompletionListCapabilities := none
deriving ToJson, FromJson
structure HoverClientCapabilities where
dynamicRegistration? : Option Bool := none
contentFormat? : Option (Array MarkupKind) := none
deriving ToJson, FromJson
structure ParameterInformationCapabilities where
labelOffsetSupport? : Option Bool := none
deriving ToJson, FromJson
structure SignatureInformationCapabilities where
documentationFormat? : Option (Array MarkupKind) := none
parameterInformation? : Option ParameterInformationCapabilities := none
activeParameterSupport : Option Bool := none
deriving ToJson, FromJson
structure SignatureHelpClientCapabilities where
dynamicRegistration? : Option Bool := none
signatureInformation? : Option SignatureInformationCapabilities := none
contentSupport? : Option Bool := none
deriving ToJson, FromJson
structure DeclarationClientCapabilities where
dynamicRegistration? : Option Bool := none
linkSupport? : Option Bool := none
deriving ToJson, FromJson
structure DefinitionClientCapabilities where
dynamicRegistration? : Option Bool := none
linkSupport? : Option Bool := none
deriving ToJson, FromJson
structure TypeDefinitionClientCapabilities where
dynamicRegistration? : Option Bool := none
linkSupport? : Option Bool := none
deriving ToJson, FromJson
structure ImplementationClientCapabilities where
dynamicRegistration? : Option Bool := none
linkSupport? : Option Bool := none
deriving ToJson, FromJson
structure ReferenceClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure DocumentHighlightClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure DocumentSymbolClientCapabilities where
dynamicRegistration? : Option Bool := none
symbolKind? : Option SymbolKindCapabilities := none
hierarchicalDocumentSymbolSupport? : Option Bool := none
tagSupport? : Option SymbolTagSupportCapabilities := none
labelSupport? : Option Bool := none
deriving ToJson, FromJson
def CodeActionKind := Name
namespace CodeActionKind
def empty := Name.anonymous
def quickfix := `quickfix
def refactor := `refactor
def refactorExtract := `refactor.extract
def refactorInline := `refactor.inline
def refactorRewrite := `refactor.inline
def source := `refactor.inline
def sourceOrganizeImports := `source.organizeImports
def sourceFixAll := `source.fixAll
instance : ToJson CodeActionKind where
toJson a := if a.isAnonymous then "" else a.toString false
instance : FromJson CodeActionKind where
fromJson? v := v.getStr? <&> fun v => if v.isEmpty then empty else v.toName
end CodeActionKind
structure CodeActionKindCapabilities where
valueSet : Array CodeActionKind
deriving ToJson, FromJson
structure CodeActionLiteralSupportCapabilities where
codeActionKind : CodeActionKindCapabilities
deriving ToJson, FromJson
structure CodeActionClientCapabilities where
dynamicRegistration? : Option Bool := none
codeActionLiteralSupport? : Option CodeActionLiteralSupportCapabilities := none
isPreferredSupport? : Option Bool := none
disabledSupport? : Option Bool := none
dataSupport? : Option Bool := none
resolveSupport? : Option ResolveSupportCapabilities := none
honorsChangeAnnotations? : Option Bool := none
deriving ToJson, FromJson
structure CodeLensClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure DocumentLinkClientCapabilities where
dynamicRegistration? : Option Bool := none
tooltipSupport? : Option Bool := none
deriving ToJson, FromJson
structure DocumentColorClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure DocumentFormattingClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure DocumentRangeFormattingClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure DocumentOnTypeFormattingClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure RenameClientCapabilities where
dynamicRegistration? : Option Bool := none
prepareSupport? : Option Bool := none
prepareSupportDefaultBehavior? : Option PrepareSupportDefaultBehavior := none
honorsChangeAnnotations? : Option Bool := none
deriving ToJson, FromJson
structure DiagnosticTagSupportCapabilities where
valueSet : Array DiagnosticTag
deriving ToJson, FromJson
structure PublishDiagnosticsClientCapabilities where
relatedInformation? : Option Bool := none
tagSupport? : Option DiagnosticTagSupportCapabilities := none
versionSupport? : Option PrepareSupportDefaultBehavior := none
codeDescriptionSupport? : Option Bool := none
dataSupport? : Option Bool := none
deriving ToJson, FromJson
structure FoldingRangeKindCapabilities where
valueSet? : Option (Array FoldingRangeKind) := none
deriving ToJson, FromJson
structure FoldingRangeCapabilities where
collapsedText? : Option Bool := none
deriving ToJson, FromJson
structure FoldingRangeClientCapabilities where
dynamicRegistration? : Option Bool := none
rangeLimit? : Option Nat := none
lineFoldingOnly? : Option Bool := none
foldingRangeKind? : Option FoldingRangeKindCapabilities := none
foldingRange? : Option FoldingRangeCapabilities := none
deriving ToJson, FromJson
structure SelectionRangeClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure LinkedEditingRangeClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure CallHierarchyClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure SemanticTokensRequestsFullCapabilities where
delta? : Option Bool := none
deriving ToJson, FromJson
structure SemanticTokensRequestsCapabilities where
range? : Option (Union Bool EmptyObject) := none
full? : Option (Union Bool SemanticTokensRequestsFullCapabilities) := none
deriving ToJson, FromJson
inductive TokenFormat
| relative
deriving ToJson, FromJson
structure SemanticTokensClientCapabilities where
dynamicRegistration? : Option Bool := none
requests : SemanticTokensRequestsCapabilities
tokenTypes : Array String
tokenModifiers : Array String
formats : Array TokenFormat
overlappingTokenSupport? : Option Bool := none
multilineTokenSupport? : Option Bool := none
serverCancelSupport? : Option Bool := none
augmentsSyntaxTokens : Option Bool := none
deriving ToJson, FromJson
structure MonikerClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure TypeHierarchyClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure InlineValueClientCapabilities where
dynamicRegistration? : Option Bool := none
deriving ToJson, FromJson
structure InlayHintClientCapabilities where
dynamicRegistration? : Option Bool := none
resolveSupport? : Option ResolveSupportCapabilities := none
deriving ToJson, FromJson
structure DiagnosticClientCapabilities where
dynamicRegistration? : Option Bool := none
relatedDocumentSupport? : Option Bool := none
deriving ToJson, FromJson
structure TextDocumentClientCapabilities where
synchronization? : Option TextDocumentSyncClientCapabilities := none
completion? : Option CompletionClientCapabilities := none
hover? : Option HoverClientCapabilities := none
signatureHelp? : Option SignatureHelpClientCapabilities := none
declaration? : Option DeclarationClientCapabilities := none
definition? : Option DefinitionClientCapabilities := none
typeDefinition? : Option TypeDefinitionClientCapabilities := none
implementation? : Option ImplementationClientCapabilities := none
references? : Option ReferenceClientCapabilities := none
documentHighlight? : Option DocumentHighlightClientCapabilities := none
documentSymbol? : Option DocumentSymbolClientCapabilities := none
codeAction? : Option CodeActionClientCapabilities := none
codeLens? : Option CodeLensClientCapabilities := none
documentLink? : Option DocumentLinkClientCapabilities := none
colorProvider? : Option DocumentColorClientCapabilities := none
formatting? : Option DocumentFormattingClientCapabilities := none
rangeFormatting? : Option DocumentRangeFormattingClientCapabilities := none
onTypeFormatting? : Option DocumentOnTypeFormattingClientCapabilities := none
rename? : Option RenameClientCapabilities := none
publishDiagnostics? : Option PublishDiagnosticsClientCapabilities := none
foldingRange? : Option FoldingRangeClientCapabilities := none
selectionRange? : Option SelectionRangeClientCapabilities := none
linkedEditingRange? : Option LinkedEditingRangeClientCapabilities := none
callHierarchy? : Option CallHierarchyClientCapabilities := none
semanticTokens? : Option SemanticTokensClientCapabilities := none
moniker? : Option MonikerClientCapabilities := none
typeHierarchy? : Option TypeHierarchyClientCapabilities := none
inlineValue? : Option InlineValueClientCapabilities := none
inlayHint? : Option InlayHintClientCapabilities := none
diagnostic? : Option DiagnosticClientCapabilities := none
deriving ToJson, FromJson
structure NotebookDocumentSyncClientCapabilities where
dynamicRegistration? : Option Bool := none
executionSummarySupport? : Option Bool := none
deriving ToJson, FromJson
structure NotebookDocumentClientCapabilities where
synchronization : NotebookDocumentSyncClientCapabilities
deriving ToJson, FromJson
structure MessageActionItemCapabilities where
additionalPropertiesSupport? : Option Bool := none
deriving ToJson, FromJson
structure ShowMessageRequestClientCapabilities where
messageActionItem? : Option MessageActionItemCapabilities := none
deriving ToJson, FromJson
structure WindowClientCapabilities where
workDoneProgress? : Option Bool := none
showMessage? : Option ShowMessageRequestClientCapabilities := none
showDocument? : Option ShowDocumentClientCapabilities := none
deriving ToJson, FromJson
structure StaleRequestSupportCapabilities where
cancel : Bool
retryOnContentModified : Array String
deriving ToJson, FromJson
structure RegularExpressionsClientCapabilities where
engine : String
version? : Option String := none
deriving ToJson, FromJson
structure MarkdownClientCapabilities where
parser : String
version? : Option String := none
allowedTags? : Option (Array String) := none
deriving ToJson, FromJson
abbrev PositionEncodingKind := String
namespace PositionEncodingKind
def utf8 := "utf-8"
def utf16 := "utf-16"
def utf32 := "utf-32"
end PositionEncodingKind
structure GeneralClientCapabilities where
staleRequestSupport? : Option StaleRequestSupportCapabilities := none
regularExpressions? : Option RegularExpressionsClientCapabilities := none
markdown? : Option MarkdownClientCapabilities := none
positionEncodings? : Option (Array PositionEncodingKind) := none
deriving ToJson, FromJson
structure ClientCapabilities (Experimental := Json) where
workspace? : Option WorkspaceClientCapabilities := none
textDocument? : Option TextDocumentClientCapabilities := none
notebookDocument? : Option NotebookDocumentClientCapabilities := none
window? : Option WindowClientCapabilities := none
general? : Option GeneralClientCapabilities := none
experimental? : Option Experimental := none
deriving Inhabited, ToJson, FromJson
instance [ToJson Exp] : Coe (ClientCapabilities Exp) ClientCapabilities where
coe caps := {caps with experimental? := caps.experimental?.map toJson}