-
Notifications
You must be signed in to change notification settings - Fork 69
/
protocol.ts
346 lines (302 loc) · 11.2 KB
/
protocol.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
'use strict';
import { RequestType, NotificationType } from 'vscode-jsonrpc';
import * as vscode from 'vscode-languageserver-types';
export interface DocumentFilter {
language?: string,
pattern?: string,
scheme?: string,
}
export type DocumentSelector = string | DocumentFilter | (string | DocumentFilter)[];
/** The substitution settings for a language (or group of languages) */
export interface LanguageEntry {
/** language(s) to apply these substitutions on */
language: DocumentSelector;
/** substitution rules */
substitutions: Substitution[];
}
export interface PrettifySymbolsModeSettings {
substitutions: LanguageEntry[],
}
// The settings interface describe the server relevant settings part
export interface Settings {
coqtop: CoqTopSettings,
coq: CoqSettings,
prettifySymbolsMode?: PrettifySymbolsModeSettings,
}
export interface CoqTopSettings {
/** Path to coqc and coqtop binaries. @default `""` */
binPath: string;
/** A list of arguments to send to coqtop. @default `[]` */
args: string[];
/** When should an instance of coqtop be started for a Coq script */
startOn: "open-script" | "interaction",
}
export interface AutoFormattingSettings {
enable: boolean, // mast switch
indentAfterBullet: "none" | "indent" | "align",
indentAfterOpenProof: boolean,
unindentOnCloseProof: boolean,
}
export interface CoqSettings {
/** Load settings from _CoqProject (if found at the root of the Code project). @default `true` */
loadCoqProject: boolean,
/** Move the editor's cursor position as Coq interactively steps forward/backward a command. @default `true` */
moveCursorToFocus : boolean,
/** Interpret to end of sentence */
interpretToEndOfSentence: boolean,
/** Auto-reveal proof-state at cursor */
autoRevealProofStateAtCursor: boolean,
/** Reveal the preceding or subsequent proof state w.r.t. a position */
revealProofStateAtCursorDirection: "preceding" | "subsequent"
/** Command to view a uri in an external browser */
externalViewUrlCommand: string,
/** How to host external proof-views */
externalViewScheme: "file" | "http",
format: AutoFormattingSettings,
/** When to createa proof view for a script: when the script is opened, on first interaction, or else manually */
showProofViewOn: "open-script" | "first-interaction" | "manual",
/** Misc. diagnostic options */
diagnostics?: {
/** After each document edit, check for inconsistencies between the STM, sentences, and document. */
checkTextSynchronization?: boolean,
/** After each command, check sentence-states for inconsistencies */
checkSentenceStateConsistency?: boolean,
}
}
export interface FailValue {
message: AnnotatedText;
range?: vscode.Range;
sentence: vscode.Range;
}
export enum SetDisplayOption {
On, Off, Toggle
}
export enum DisplayOption {
ImplicitArguments,
Coercions,
RawMatchingExpressions,
Notations,
AllBasicLowLevelContents,
ExistentialVariableInstances,
UniverseLevels,
AllLowLevelContents,
}
export interface CoqTopParams {
uri: string;
}
export interface Substitution {
ugly: string; // regular expression describing the text to replace
pretty: string; // plain-text symbol to show instead
pre?: string; // regular expression guard on text before "ugly"
post?: string; // regular expression guard on text after "ugly"
style?: any; // stylings to apply to the "pretty" text, if specified, or else the ugly text
}
export type TextDifference = "added"|"removed";
export interface TextAnnotation {
/** the relationship this text has to the text of another state */
diff?: TextDifference,
/** what to display instead of this text */
substitution?: string,
/** the underlying text, possibly with more annotations */
text: string
}
export interface ScopedText {
/** A scope identifier */
scope: string,
/** Extra stuff */
attributes?: any,
/** the underlying text, possibly with more annotations */
text: AnnotatedText,
}
export type AnnotatedText = string | TextAnnotation | ScopedText | (string | TextAnnotation | ScopedText)[];
export enum HypothesisDifference { None, Changed, New, MovedUp, MovedDown }
export interface Hypothesis {
identifier: string;
relation: string;
expression: AnnotatedText;
diff: HypothesisDifference;
}
export interface Goal {
id: number;
hypotheses: Hypothesis[];
goal: AnnotatedText;
}
export interface UnfocusedGoalStack {
// subgoals that appear before the focus
before: Goal[];
// reference to the more-focused background goals
next?: UnfocusedGoalStack
// subgoals that appear after the focus
after: Goal[];
}
export interface ProofView {
goals: Goal[];
backgroundGoals?: UnfocusedGoalStack,
shelvedGoals: Goal[],
abandonedGoals: Goal[],
focus: vscode.Position,
}
export interface CommandInterrupted {
range: vscode.Range
}
export type FocusPosition = {focus: vscode.Position}
export type NotRunningTag = {type: 'not-running'}
export type NoProofTag = {type: 'no-proof'}
export type FailureTag = {type: 'failure'}
export type ProofViewTag = {type: 'proof-view'}
export type InterruptedTag = {type: 'interrupted'}
export type BusyTag = {type: 'busy'}
export type NotRunningResult = NotRunningTag & {reason: "not-started"|"spawn-failed", coqtop?: string}
export type BusyResult = BusyTag
export type NoProofResult = NoProofTag
export type FailureResult = FailValue & FailureTag
export type ProofViewResult = ProofView & ProofViewTag
export type InterruptedResult = CommandInterrupted & InterruptedTag
export type CommandResult =
NotRunningResult |
(BusyResult & FocusPosition) |
(FailureResult & FocusPosition) |
(ProofViewResult & FocusPosition) |
(InterruptedResult & FocusPosition) |
(NoProofResult & FocusPosition);
export interface CoqTopInterpretToPointParams extends CoqTopParams {
location: number|vscode.Position,
synchronous?: boolean,
}
export interface InterpretToEndParams extends CoqTopParams {
synchronous?: boolean,
}
export interface LtacProfTactic {
name: string,
statistics: {total: number; local: number; num_calls: number; max_total: number},
tactics: LtacProfTactic[]
}
export interface LtacProfResults {
total_time: number,
tactics: LtacProfTactic[]
}
export namespace InterruptCoqRequest {
export const type = new RequestType<CoqTopParams, void, void, void>('coqtop/interrupt');
}
export namespace QuitCoqRequest {
export const type = new RequestType<CoqTopParams, void, void, void>('coqtop/quitCoq')
}
export namespace ResetCoqRequest {
export const type = new RequestType<CoqTopParams, void, void, void>('coqtop/resetCoq')
}
export namespace StepForwardRequest {
export const type = new RequestType<CoqTopParams, CommandResult, void, void>('coqtop/stepForward')
}
export namespace StepBackwardRequest {
export const type = new RequestType<CoqTopParams, CommandResult, void, void>('coqtop/stepBackward')
}
export namespace InterpretToPointRequest {
export const type = new RequestType<CoqTopInterpretToPointParams, CommandResult, void, void>('coqtop/interpretToPoint')
}
export namespace InterpretToEndRequest {
export const type = new RequestType<InterpretToEndParams, CommandResult, void, void>('coqtop/interpretToEnd')
}
export namespace GoalRequest {
export const type = new RequestType<CoqTopParams, CommandResult, void, void>('coqtop/goal')
}
export interface CachedGoalParams extends CoqTopParams {
position: vscode.Position,
direction: "preceding"|"subsequent",
}
export namespace CachedGoalRequest {
export const type = new RequestType<CachedGoalParams, CommandResult, void, void>('coqtop/cachedGoal')
}
export namespace FinishComputationsRequest {
export const type = new RequestType<CoqTopParams, void, void, void>('coqtop/finishComputations')
}
export namespace QueryRequest {
export const type = new RequestType<CoqTopQueryParams, void, void, void>('coqtop/query')
}
export type QueryFunction = "locate"|"check"|"print"|"search"|"about"|"searchAbout";
export interface CoqTopQueryParams extends CoqTopParams {
queryFunction: QueryFunction;
query: string;
routeId: Number;
}
export interface CoqTopResizeWindowParams extends CoqTopParams {
columns: number;
}
export namespace ResizeWindowRequest {
export const type = new RequestType<CoqTopResizeWindowParams, void, void, void>('coqtop/resizeWindow')
}
export interface CoqTopSetDisplayOptionsParams extends CoqTopParams {
options: {item: DisplayOption, value: SetDisplayOption}[]
}
export namespace SetDisplayOptionsRequest {
export const type = new RequestType<CoqTopSetDisplayOptionsParams, void, void, void>('coqtop/setDisplayOptions')
}
export interface CoqTopLtacProfResultsParams extends CoqTopParams {
offset?: number;
}
export namespace LtacProfResultsRequest {
export const type = new RequestType<CoqTopLtacProfResultsParams, void, void, void>('coqtop/ltacProfResults')
}
export namespace GetSentencePrefixTextRequest {
export const type = new RequestType<DocumentPositionParams, string, void, void>('coqtop/getSentencePrefixText')
}
export enum HighlightType {
StateError=0, Parsing=1, Processing=2, Incomplete=3, Processed=4, Axiom=5
}
// export interface Highlight {
// style: HighlightType;
// range: vscode.Range;
// }
export interface NotificationParams {
uri: string;
}
export interface Highlights {
ranges: [vscode.Range[],vscode.Range[],vscode.Range[],vscode.Range[],vscode.Range[],vscode.Range[]];
}
export type NotifyHighlightParams = NotificationParams & Highlights;
export namespace UpdateHighlightsNotification {
export const type = new NotificationType<NotifyHighlightParams,void>('coqtop/updateHighlights')
}
export interface NotifyMessageParams extends NotificationParams {
level: string;
message: AnnotatedText;
routeId: Number;
}
export namespace CoqMessageNotification {
export const type = new NotificationType<NotifyMessageParams,void>('coqtop/message')
}
export namespace CoqResetNotification {
export const type = new NotificationType<NotificationParams,void>('coqtop/wasReset')
}
export namespace CoqtopStartNotification {
export const type = new NotificationType<NotificationParams,void>('coqtop/coqtopStarted')
}
export enum CoqtopStopReason { UserRequest, Anomaly, InternalError }
export interface NotifyCoqtopStopParams extends NotificationParams {
reason: CoqtopStopReason;
message?: string;
}
export namespace CoqtopStopNotification {
export const type = new NotificationType<NotifyCoqtopStopParams,void>('coqtop/coqtopStopped')
}
export interface DocumentPositionParams extends NotificationParams {
position: vscode.Position;
}
export namespace CoqStmFocusNotification {
export const type = new NotificationType<DocumentPositionParams,void>('coqtop/stmFocus')
}
export enum ComputingStatus {Finished, Computing, Interrupted}
// export interface NotifyComputingStatusParams extends NotificationParams {
// status: ComputingStatus;
// computeTimeMS: number;
// }
// export namespace CoqComputingStatusNotification {
// export const type: NotificationType<NotifyComputingStatusParams> =
// { get method() { return 'coqtop/computingStatus' }
// , _:undefined };
// }
export interface NotifyLtacProfResultsParams extends NotificationParams {
results: LtacProfResults
}
export namespace CoqLtacProfResultsNotification {
export const type = new NotificationType<NotifyLtacProfResultsParams,void>('coqtop/ltacProfResults')
}