-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcommands.ts
351 lines (298 loc) · 7.43 KB
/
commands.ts
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
export interface Request {
command: string;
seq_num?: number; // the sequence number is filled in automatically
}
export interface Response {
response: string;
}
export type Severity = 'information' | 'warning' | 'error';
export interface Message {
file_name: string;
pos_line: number;
pos_col: number;
end_pos_line?: number;
end_pos_col?: number;
severity: Severity;
caption: string;
text: string;
widget?: WidgetIdentifier;
}
export interface AllMessagesResponse extends Response {
response: 'all_messages';
msgs: Message[];
}
// Only used in Lean < 3.1.1
export interface AdditionalMessageResponse extends Response {
response: 'additional_message';
msg: Message;
}
export interface Task {
file_name: string;
pos_line: number;
pos_col: number;
end_pos_line: number;
end_pos_col: number;
desc: string;
}
export interface CurrentTasksResponse extends Response {
response: 'current_tasks';
is_running: boolean;
cur_task?: Task;
tasks: Task[];
}
export interface CommandResponse extends Response {
response: 'ok';
seq_num: number;
}
export interface ErrorResponse extends Response {
response: 'error';
seq_num?: number;
message: string;
}
export interface SyncRequest extends Request {
command: 'sync';
file_name: string;
content: string;
}
export interface CompleteRequest extends Request {
command: 'complete';
file_name: string;
line: number;
column: number;
skip_completions?: boolean;
}
export declare type SymbolKind
= 'class'
| 'definition'
| 'meta'
| 'inductive'
| 'instance'
| 'structure'
| 'theorem'
export interface CompletionCandidate {
type?: string;
tactic_params?: string[];
text: string;
kind?: SymbolKind;
doc?: string;
}
export interface CompleteResponse extends CommandResponse {
prefix: string;
completions: CompletionCandidate[];
}
export interface InfoRequest extends Request {
command: 'info';
file_name: string;
line: number;
column: number;
}
export interface GetWidgetRequest extends Request {
command: 'get_widget';
file_name: string;
line: number;
column: number;
/** The widget root component id. */
id: number;
}
export interface GetWidgetResponse extends CommandResponse {
widget: WidgetData;
}
export interface InfoSource {
line: number;
column: number;
file?: string;
}
export type GoalState = string;
export interface WidgetIdentifier {
html?: WidgetComponent;
line: number;
column: number;
/** The widget root component id. */
id?: number;
}
export interface WidgetData extends WidgetIdentifier {
html: WidgetComponent;
}
export interface InfoRecord {
'full-id'?: string;
text?: string;
type?: string;
doc?: string;
source?: InfoSource;
tactic_params?: string[];
state?: GoalState;
widget?: WidgetIdentifier;
}
export interface InfoResponse extends CommandResponse {
record?: InfoRecord;
}
export interface SymbolRequest extends Request {
command: 'symbols';
file_name: string;
}
export interface SymbolItem {
source?: InfoSource;
name: string;
name_parts: string[];
type: string;
kind: SymbolKind;
}
export interface SymbolResponse extends CommandResponse {
results: SymbolItem[];
}
/** Experimental API, >=3.1.1 */
export interface SearchRequest extends Request {
command: 'search';
query: string;
}
export interface SearchItem {
source?: InfoSource;
text: string;
type: string;
kind?: SymbolKind;
doc?: string;
}
export interface SearchResponse extends CommandResponse {
results: SearchItem[];
}
export interface HoleCommandsRequest extends Request {
command: 'hole_commands';
file_name: string;
line: number;
column: number;
}
export interface HoleCommandAction {
name: string;
description: string;
}
export interface HoleCommands {
file: string;
start: { line: number; column: number };
end: { line: number; column: number };
results: HoleCommandAction[];
}
export interface HoleCommandsResponse extends CommandResponse, HoleCommands {}
export interface AllHoleCommandsRequest extends Request {
command: 'all_hole_commands';
file_name: string;
}
export interface AllHoleCommandsResponse extends CommandResponse {
holes: HoleCommands[];
}
export interface HoleRequest extends Request {
command: 'hole';
file_name: string;
line: number;
column: number;
action: string;
}
export interface HoleReplacementAlternative {
code: string;
description: string;
}
export interface HoleReplacements {
file: string;
start: { line: number; column: number };
end: { line: number; column: number };
alternatives: HoleReplacementAlternative[];
}
export interface HoleResponse extends CommandResponse {
replacements?: HoleReplacements;
message?: string;
}
export type CheckingMode = 'nothing' | 'visible-lines'
| 'visible-lines-and-above' | 'visible-files' | 'open-files';
export interface RoiRange {
begin_line: number;
end_line: number;
}
export interface FileRoi {
file_name: string;
ranges: RoiRange[];
}
export interface RoiRequest extends Request {
command: 'roi';
mode: CheckingMode;
files: FileRoi[];
}
export interface SleepRequest extends Request {
command: 'sleep';
}
export interface LongSleepRequest extends Request {
command: 'long_sleep';
}
export type WidgetEffect =
| {kind: 'insert_text'; text: string}
| {kind: 'reveal_position'; file_name: string; line: number; column: number}
| {kind: 'highlight_position'; file_name: string; line: number; column: number}
| {kind: 'clear_highlighting'}
| {kind: 'copy_text'; text:string}
| {kind: 'custom'; key: string; value: string}
export interface WidgetEventRecordSuccess {
status: 'success';
widget: WidgetData;
effects?: WidgetEffect[];
}
/** 3.15 ≤ lean.version ≤ 3.16 */
export interface WidgetEventRecordEdit {
status: 'edit';
widget: WidgetData;
/** Some text to insert after the widget's comma. */
action: string;
}
export interface WidgetEventRecordInvalid {
status: 'invalid_handler';
}
export interface WidgetEventRecordError {
status: 'error';
message: string;
}
export type WidgetEventRecord =
| WidgetEventRecordSuccess
| WidgetEventRecordInvalid
| WidgetEventRecordEdit
| WidgetEventRecordError;
export interface WidgetEventResponse extends CommandResponse {
record: WidgetEventRecord;
}
export interface WidgetEventHandler {
/** handler id */
h: number;
/** route */
r: number[];
}
export interface WidgetElement {
/** tag */
t: string;
/** children */
c: WidgetHtml[];
/** attributes */
a?: { [k: string]: any };
/** events */
e: {
'onClick'?: WidgetEventHandler;
'onMouseEnter'?: WidgetEventHandler;
'onMouseLeave'?: WidgetEventHandler;
};
/** tooltip */
tt?: WidgetHtml;
}
export interface WidgetComponent {
/** children */
c: WidgetHtml[];
}
export type WidgetHtml =
| WidgetComponent
| string
| WidgetElement
| null;
export interface WidgetEventRequest extends Request {
command: 'widget_event';
kind: 'onClick' | 'onMouseEnter' | 'onMouseLeave' | 'onChange';
handler: WidgetEventHandler;
args: { type: 'unit' } | { type: 'string'; value: string };
file_name: string;
line: number;
column: number;
id?: number;
}