@exercism/codemirror-lang-lean 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,873 @@
1
+ 'use strict';
2
+
3
+ var lr = require('@lezer/lr');
4
+ var language = require('@codemirror/language');
5
+ var highlight = require('@lezer/highlight');
6
+ var state = require('@codemirror/state');
7
+ var view = require('@codemirror/view');
8
+ var unicodeInput = require('@leanprover/unicode-input');
9
+
10
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
11
+ const InterpPrefix = 1,
12
+ InterpKeyword = 2,
13
+ StdNamespace = 3,
14
+ StdTypeName = 4,
15
+ stdTypeNameDot = 5,
16
+ QualifiedType = 6;
17
+
18
+ // Mirrors `idRest` in syntax.grammar (letters/digits/underscore/'!?, plus
19
+ // the letterLike and subscript unicode ranges), so the boundary this finds
20
+ // exactly matches where the grammar's own Identifier token would stop —
21
+ // without it, "TreeSetX" could be mistaken for a boundary at "TreeSet".
22
+ function isIdRest(code) {
23
+ if (code === 0x5f)
24
+ return true; // _
25
+ if (code >= 0x41 && code <= 0x5a)
26
+ return true; // A-Z
27
+ if (code >= 0x61 && code <= 0x7a)
28
+ return true; // a-z
29
+ if (code >= 0x30 && code <= 0x39)
30
+ return true; // 0-9
31
+ if (code === 0x27 || code === 0x21 || code === 0x3f)
32
+ return true; // ' ! ?
33
+ if (code >= 0x3b1 && code <= 0x3ba)
34
+ return true; // lower greek
35
+ if (code >= 0x3bc && code <= 0x3c9)
36
+ return true;
37
+ if (code >= 0x391 && code <= 0x39f)
38
+ return true; // upper greek
39
+ if (code >= 0x3a1 && code <= 0x3a2)
40
+ return true;
41
+ if (code >= 0x3a4 && code <= 0x3a9)
42
+ return true;
43
+ if (code >= 0x3ca && code <= 0x3fb)
44
+ return true; // coptic
45
+ if (code >= 0x1f00 && code <= 0x1ffe)
46
+ return true; // polytonic greek
47
+ if (code >= 0x2100 && code <= 0x214f)
48
+ return true; // letterlike symbols
49
+ if (code >= 0x1d49c && code <= 0x1d59f)
50
+ return true; // script/double-struck/fraktur
51
+ if (code >= 0xc0 && code <= 0xd6)
52
+ return true; // latin-1 supplement
53
+ if (code >= 0xd8 && code <= 0xf6)
54
+ return true;
55
+ if (code >= 0xf8 && code <= 0xff)
56
+ return true;
57
+ if (code >= 0x100 && code <= 0x17f)
58
+ return true; // latin extended-A
59
+ if (code >= 0x2080 && code <= 0x2089)
60
+ return true; // subscript digits
61
+ if (code >= 0x2090 && code <= 0x209c)
62
+ return true;
63
+ if (code >= 0x1d62 && code <= 0x1d6a)
64
+ return true;
65
+ if (code === 0x2c7c)
66
+ return true;
67
+ return false;
68
+ }
69
+ // Reads the run of idRest characters starting at `offset` (via peek, so
70
+ // the stream position is never advanced), or null if it's empty.
71
+ function readBoundedSegment(input, offset) {
72
+ let text = "";
73
+ let i = offset;
74
+ for (;;) {
75
+ const code = input.peek(i);
76
+ if (isIdRest(code)) {
77
+ text += String.fromCharCode(code);
78
+ i++;
79
+ continue;
80
+ }
81
+ // The stream hands out UTF-16 code units, so the script, double-struck
82
+ // and fraktur letters, which lie beyond U+FFFF, arrive as two halves.
83
+ if (code >= 0xd800 && code <= 0xdbff) {
84
+ const low = input.peek(i + 1);
85
+ if (low >= 0xdc00 &&
86
+ low <= 0xdfff &&
87
+ isIdRest(((code - 0xd800) << 10) + (low - 0xdc00) + 0x10000)) {
88
+ text += String.fromCharCode(code, low);
89
+ i += 2;
90
+ continue;
91
+ }
92
+ }
93
+ break;
94
+ }
95
+ return text.length > 0 ? text : null;
96
+ }
97
+
98
+ const S = "s".charCodeAt(0);
99
+ const F = "f".charCodeAt(0);
100
+ const M = "m".charCodeAt(0);
101
+ const BANG = "!".charCodeAt(0);
102
+ const QUOTE = '"'.charCodeAt(0);
103
+ // `s!`/`f!`/`m!` string interpolation prefixes, kept as their own two-character
104
+ // token so they can be styled apart from the string that follows (see
105
+ // StringInterp in syntax.grammar). A declarative token here would hit the
106
+ // same hazard as fusing the prefix and quote used to sidestep: Lezer
107
+ // prefers the highest-precedence matching token over the longest one, so
108
+ // a plain "s!"/"f!" token would win over Identifier even when nothing
109
+ // valid follows (`s!oo`, bare `s!`, `def s! : Nat := 0`), producing dead
110
+ // ends instead of falling back to Identifier. Peeking at the quote here,
111
+ // without consuming it, keeps the token from ever matching unless the
112
+ // interpolation is real — no candidate is offered at all otherwise, so
113
+ // Identifier wins uncontested with no precedence contest to get wrong.
114
+ //
115
+ // Takes the term id as a parameter, rather than importing the generated
116
+ // `./syntax.grammar.terms` module directly, so this logic can be reused
117
+ // by test/grammar.test.ts's in-memory `buildParser`, which supplies its
118
+ // own term id from the builder's term table instead of that (build-only)
119
+ // generated module.
120
+ function makeInterpPrefixTokenizer(interpPrefixTerm) {
121
+ return new lr.ExternalTokenizer((input) => {
122
+ if ((input.next == S || input.next == F || input.next == M) &&
123
+ input.peek(1) == BANG &&
124
+ input.peek(2) == QUOTE) {
125
+ input.acceptToken(interpPrefixTerm, 2);
126
+ }
127
+ });
128
+ }
129
+ // The keywords whose string argument is interpolated without a prefix, as
130
+ // in `panic! "no item at {i}"`: the ones the Lean 4 VS Code extension's
131
+ // grammar lists next to `s!` and `m!`.
132
+ const INTERP_KEYWORDS = new Set([
133
+ "dbg_trace", "panic!", "reportIssue!", "throwError",
134
+ ]);
135
+ const SPACE = " ".charCodeAt(0);
136
+ const TAB = "\t".charCodeAt(0);
137
+ // Offered only when the keyword is a whole word and a quote follows it on
138
+ // the same line, so that the interpolated string the grammar then requires
139
+ // (see keywordInterp in syntax.grammar) is always there. Anywhere else the
140
+ // word falls back to the ordinary Keyword.
141
+ function makeInterpKeywordTokenizer(interpKeywordTerm) {
142
+ return new lr.ExternalTokenizer((input) => {
143
+ const word = readBoundedSegment(input, 0);
144
+ if (!word || !INTERP_KEYWORDS.has(word))
145
+ return;
146
+ let after = word.length;
147
+ while (input.peek(after) == SPACE || input.peek(after) == TAB)
148
+ after++;
149
+ if (input.peek(after) == QUOTE) {
150
+ input.acceptToken(interpKeywordTerm, word.length);
151
+ }
152
+ });
153
+ }
154
+
155
+ const interpPrefixToken = makeInterpPrefixTokenizer(InterpPrefix);
156
+ const interpKeywordToken = makeInterpKeywordTokenizer(InterpKeyword);
157
+
158
+ // The single source of truth for Lean's curated built-in type names, used
159
+ // by the Std.<Type> external tokenizers (see std-namespace.ts). Kept in
160
+ // sync with the TypeName rule in syntax.grammar by hand, the same way
161
+ // qualifiedTypeStart already is — see the comment there.
162
+ const TYPE_NAMES = new Set([
163
+ "Add", "And", "Array", "BEq", "BitVec", "Bool", "ByteArray", "Char",
164
+ "Decidable", "DecidableEq", "DecidableRel", "DHashMap", "Div", "DTreeMap",
165
+ "Empty", "Eq", "Except", "ExceptT", "Expr", "ExtDHashMap", "ExtHashMap",
166
+ "ExtHashSet", "False", "Fin", "Float", "Float32", "FloatArray", "Format",
167
+ "GE", "GT", "HAppend", "HEq", "HashMap", "HashSet", "Hashable", "IO", "Id",
168
+ "Iff", "Inhabited", "Int", "Int8", "Int16", "Int32", "Int64", "LE", "LT",
169
+ "LawfulBEq", "List", "MacroM", "MProd", "Mod", "Mul", "Mutex", "Nat", "Ne",
170
+ "Neg", "Nonempty", "Not", "Option", "OptionT", "Or", "Ord", "Ordering",
171
+ "PEmpty", "PlainDate", "PlainDateTime", "PlainTime", "PLift", "PProd",
172
+ "PSigma", "PSum", "PUnit", "Pow", "Prod", "Quot", "Quotient", "Range",
173
+ "ReaderM", "ReaderT", "Ref", "Repr", "Sigma", "ST", "StateM", "StateT",
174
+ "String", "Sub", "Subarray", "Subtype", "Sum", "Syntax", "Task", "Thunk",
175
+ "ToString", "TreeMap", "TreeSet", "True", "TSyntax", "UInt8", "UInt16",
176
+ "UInt32", "UInt64", "ULift", "USize", "Unit", "Vector",
177
+ ]);
178
+ // Types that live in a namespace under `Std`, such as
179
+ // `Std.Time.PlainDateTime`, keyed by that namespace. Apart from the three
180
+ // `Plain…` types, which are also in the list above, they are recognised
181
+ // only after "Std.<namespace>." (see std-namespace.ts): a bare `Duration`
182
+ // or `Timestamp` stays plain, because exercises define their own types
183
+ // with names like these. The names are the date, time and duration types
184
+ // listed in the module documentation of Lean's `Std.Time`.
185
+ const STD_NAMESPACE_TYPES = new Map([
186
+ [
187
+ "Time",
188
+ new Set([
189
+ "DateTime", "Duration", "PlainDate", "PlainDateTime", "PlainTime",
190
+ "TimeZone", "Timestamp", "WallTime", "Weekday", "ZonedDateTime",
191
+ ]),
192
+ ],
193
+ ]);
194
+
195
+ const DOT$1 = ".".charCodeAt(0);
196
+ // `Std.<Type>`, and likewise `Lean.<Type>` (the node keeps the name
197
+ // StdNamespace for both) — `Std` and the curated type name after it get their own
198
+ // nodes (and colors), the type name taking a following "." along
199
+ // (`TreeSet.`), while anything further (`Std.TreeSet.empty`'s `empty`) is
200
+ // left alone as a plain Identifier. Splitting the
201
+ // literal "Std." off is easy, but the type name can't just be the
202
+ // existing (dot-chaining) Identifier/TypeName token reused at that
203
+ // position: Identifier's own regex would keep going through the next
204
+ // dot too (`TreeSet.empty` as one run), so specialize would compare the
205
+ // whole "TreeSet.empty" against the curated list, fail, and leave it
206
+ // entirely unstyled. Two purpose-built external tokenizers fix this:
207
+ // stdNamespaceToken consumes only "Std." — and only when the segment
208
+ // right after it (checked by peeking, not consuming) is an exact,
209
+ // bounded curated name, so anything else ("Std.foo", bare "Std", as in
210
+ // `open Std`) offers no token at all and falls back to plain Identifier
211
+ // with no dead end — while stdTypeNameToken, valid only as the required
212
+ // continuation right after StdNamespace (see StdQualifiedType in the
213
+ // grammar, not reachable from anywhere else `atom` is), matches just
214
+ // that one bounded segment and the "." after it, if there is one, without
215
+ // letting what follows that dot extend it.
216
+ // The namespaces whose types are split off this way: `Std.HashMap`, and
217
+ // `Lean.TSyntax` or `Lean.MacroM` in a macro. Returns the length of the
218
+ // one at the start of the input with its dot ("Std." is 4), or 0.
219
+ const ROOT_NAMESPACES = ["Std", "Lean"];
220
+ function rootNamespaceLength(input) {
221
+ for (const root of ROOT_NAMESPACES) {
222
+ let i = 0;
223
+ while (i < root.length && input.peek(i) == root.charCodeAt(i))
224
+ i++;
225
+ if (i == root.length && input.peek(i) == DOT$1)
226
+ return i + 1;
227
+ }
228
+ return 0;
229
+ }
230
+ function makeStdNamespaceTokenizer(stdNamespaceTerm) {
231
+ return new lr.ExternalTokenizer((input) => {
232
+ const root = rootNamespaceLength(input);
233
+ if (!root)
234
+ return;
235
+ const seg = readBoundedSegment(input, root);
236
+ if (!seg)
237
+ return;
238
+ if (TYPE_NAMES.has(seg)) {
239
+ input.acceptToken(stdNamespaceTerm, root);
240
+ return;
241
+ }
242
+ // `Std.Time.PlainDateTime`: the namespace under `Std` joins the
243
+ // token ("Std.Time."), under the same condition as above, that a
244
+ // type known to live there follows. `Std.Time` on its own, as in
245
+ // `import Std.Time`, stays a plain Identifier like `open Std` does.
246
+ const nested = root == 4 ? STD_NAMESPACE_TYPES.get(seg) : undefined;
247
+ const afterNested = root + seg.length + 1;
248
+ if (nested && input.peek(afterNested - 1) == DOT$1) {
249
+ const type = readBoundedSegment(input, afterNested);
250
+ if (type && nested.has(type)) {
251
+ input.acceptToken(stdNamespaceTerm, afterNested);
252
+ }
253
+ }
254
+ });
255
+ }
256
+ function makeStdTypeNameTokenizer(stdTypeNameTerm, stdTypeNameDotTerm) {
257
+ return new lr.ExternalTokenizer((input) => {
258
+ // Only reachable right after StdNamespace, which has already checked
259
+ // that this segment belongs to the namespace it consumed, so a name
260
+ // from either list is enough here.
261
+ const seg = readBoundedSegment(input, 0);
262
+ if (seg && (TYPE_NAMES.has(seg) || isNestedStdType(seg))) {
263
+ // Take a following "." too, as QualifiedType does for `IO.`, so that
264
+ // `Std.TreeMap.empty` splits the same way `IO.println` does. With
265
+ // the dot it is a term of its own (under the same node name), which
266
+ // is what lets `def Std.HashMap.foo` find its name.
267
+ const dot = input.peek(seg.length) == DOT$1 ? 1 : 0;
268
+ input.acceptToken(dot ? stdTypeNameDotTerm : stdTypeNameTerm, seg.length + dot);
269
+ }
270
+ });
271
+ }
272
+ function isNestedStdType(name) {
273
+ for (const types of STD_NAMESPACE_TYPES.values()) {
274
+ if (types.has(name))
275
+ return true;
276
+ }
277
+ return false;
278
+ }
279
+
280
+ const stdNamespaceToken = makeStdNamespaceTokenizer(StdNamespace);
281
+ const stdTypeNameToken = makeStdTypeNameTokenizer(StdTypeName, stdTypeNameDot);
282
+
283
+ const DOT = ".".charCodeAt(0);
284
+ // `IO.println`, `Nat.succ` — only the curated type name and the dot after
285
+ // it (`IO.`, `Nat.`) get their own node/color; the segment after that is
286
+ // left alone as a plain Identifier, the same way Std.TreeSet.empty leaves
287
+ // `empty` plain after `TreeSet.` (see std-namespace.ts, which this
288
+ // mirrors). Reusing Identifier/TypeName for just the "IO" part doesn't
289
+ // work here either:
290
+ // Identifier's own regex keeps going through the dot (matching
291
+ // "IO.println" as one run), so specialize would compare that whole run
292
+ // against the curated list, fail, and leave it entirely unstyled — hence
293
+ // a dedicated external tokenizer that stops right after the dot.
294
+ //
295
+ // Unlike StdNamespace, this doesn't need to verify what follows the dot:
296
+ // "IO." isn't required to be part of anything (no wrapping grammar rule
297
+ // depends on a continuation existing), so it's a well-formed token on its
298
+ // own even with nothing, or nothing valid, after it — matching how a
299
+ // curated type name is already highlighted standalone (as TypeName) with
300
+ // no such requirement either.
301
+ function makeQualifiedTypeTokenizer(qualifiedTypeTerm) {
302
+ return new lr.ExternalTokenizer((input) => {
303
+ const seg = readBoundedSegment(input, 0);
304
+ if (seg && TYPE_NAMES.has(seg) && input.peek(seg.length) == DOT) {
305
+ input.acceptToken(qualifiedTypeTerm, seg.length + 1);
306
+ }
307
+ });
308
+ }
309
+
310
+ const qualifiedTypeToken = makeQualifiedTypeTokenizer(QualifiedType);
311
+
312
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
313
+ const spec_Identifier = {__proto__:null,add_decl_doc:154, binder_predicate:156, builtin_dsimproc:158, builtin_dsimproc_decl:160, builtin_grind_propagator:162, builtin_initialize:164, builtin_simproc:166, builtin_simproc_decl:168, coinductive_fixpoint:170, declare_config_elab:172, declare_syntax_cat:174, dsimproc:176, dsimproc_decl:178, elab:180, elab_rules:182, end:184, example:186, export:188, extends:190, grind_pattern:192, grind_propagator:194, hiding:196, import:198, include:200, inductive_fixpoint:202, infix:204, infixl:206, infixr:208, initialize:210, macro:212, macro_rules:214, module:216, mutual:218, namespace:220, notation:222, omit:224, opaque:226, open:228, postfix:230, prefix:232, prelude:234, recommended_spelling:236, register_builtin_option:238, register_error_explanation:240, register_label_attr:242, register_linter_set:244, register_option:246, register_parser_alias:248, register_simp_attr:250, register_tactic_tag:252, renaming:254, reprove:256, run_cmd:258, run_elab:260, run_meta:262, seal:264, section:266, set_option:268, show_panel_widgets:270, simproc:272, simproc_decl:274, syntax:276, tactic_alt:278, tactic_extension:280, tactic_tag:282, universe:284, unseal:286, variable:288, at:292, bif:294, by:296, "by?":298, calc:300, decreasing_by:302, else:304, exists:306, forall:308, from:310, fun:312, generalizing:314, have:316, haveI:318, if:320, in:322, include_str:324, leading_parser:326, let:328, letI:330, let_expr:332, match:334, match_expr:336, matches:338, max_prec:340, mod_cast:342, nat_lit:344, no_index:346, nofun:348, nomatch:350, "panic!":352, partial_fixpoint:354, "println!":356, rec:358, "reportIssue!":360, show:362, show_term:364, suffices:366, termination_by:368, "termination_by?":370, then:372, this:374, trailing_parser:376, "unreachable!":378, using:380, where:382, with:384, "assert!":388, break:390, catch:392, continue:394, dbg_trace:396, do:398, finally:400, for:402, logNamedError:404, logNamedErrorAt:406, logNamedWarning:408, logNamedWarningAt:410, mut:412, repeat:414, return:416, throwError:418, throwErrorAt:420, throwNamedError:422, throwNamedErrorAt:424, try:426, unless:428, until:430, while:432, ac_rfl:436, all_goals:438, any_goals:440, apply:442, "apply?":444, assumption:446, assumption_mod_cast:448, by_cases:450, congr:452, constructor:454, contradiction:456, conv:458, decide:460, dsimp:462, exact:464, "exact?":466, exact_mod_cast:468, exfalso:470, funext:472, generalize:474, grind:476, guard_expr:478, guard_hyp:480, guard_target:482, induction:484, infer_instance:486, injection:488, injections:490, intro:492, intros:494, native_decide:496, norm_cast:498, norm_cast_add_elim:500, obtain:502, omega:504, push_cast:506, rcases:508, refine:510, rename_i:512, revert:514, rfl:516, rintro:518, rotate_left:520, rotate_right:522, rw:524, rwa:526, simp:528, simp_all:530, simp_arith:532, simpa:534, specialize:536, subst:538, subst_vars:540, symm:542, trivial:544, unfold:546, abbrev:550, axiom:552, class:554, coinductive:556, def:558, inductive:560, instance:562, structure:564, theorem:566, deriving:570, attribute:574, local:576, meta:578, noncomputable:580, nonrec:582, partial:584, private:586, protected:588, public:590, scoped:592, unsafe:594, sorry:602, admit:604, Type:608, Prop:610, Sort:612, Add:614, And:616, Array:618, BEq:620, BitVec:622, Bool:624, ByteArray:626, Char:628, Decidable:630, DecidableEq:632, DecidableRel:634, DHashMap:636, Div:638, DTreeMap:640, Empty:642, Eq:644, Except:646, ExceptT:648, Expr:650, ExtDHashMap:652, ExtHashMap:654, ExtHashSet:656, False:658, Fin:660, Float:662, Float32:664, FloatArray:666, Format:668, GE:670, GT:672, HAppend:674, HEq:676, HashMap:678, HashSet:680, Hashable:682, IO:684, Id:686, Iff:688, Inhabited:690, Int:692, Int8:694, Int16:696, Int32:698, Int64:700, LE:702, LT:704, LawfulBEq:706, List:708, MacroM:710, MProd:712, Mod:714, Mul:716, Mutex:718, Nat:720, Ne:722, Neg:724, Nonempty:726, Not:728, Option:730, OptionT:732, Or:734, Ord:736, Ordering:738, PEmpty:740, PlainDate:742, PlainDateTime:744, PlainTime:746, PLift:748, PProd:750, PSigma:752, PSum:754, PUnit:756, Pow:758, Prod:760, Quot:762, Quotient:764, Range:766, ReaderM:768, ReaderT:770, Ref:772, Repr:774, Sigma:776, ST:778, StateM:780, StateT:782, String:784, Sub:786, Subarray:788, Subtype:790, Sum:792, Syntax:794, Task:796, Thunk:798, ToString:800, TreeMap:802, TreeSet:804, True:806, TSyntax:808, UInt8:810, UInt16:812, UInt32:814, UInt64:816, ULift:818, USize:820, Unit:822, Vector:824, true:826, false:828};
314
+ const spec_HashCommand = {__proto__:null,"#exit":606};
315
+ const parser = lr.LRParser.deserialize({
316
+ version: 14,
317
+ states: "-UQYQ!XOOO8]Q!XO'#CgO8dQ!XO'#CjO8kQ!XO'#CmO8rQ!XO'#CoO8yO!bO'#CqO8yO!bO'#CsO8yO!bO'#CtOOQg'#Dq'#DqOOQg'#Cu'#CuO9UQxO'#CyO9^Q!XO'#IYO!!pQ!XO'#IdO!:SQ!XO'#IfO##fQ!XO'#DQOOQg'#DW'#DWO##mO#tO'#D_O##xOpO'#DaOOQg'#Dy'#DyOOQg'#Dp'#DpOOQg'#Di'#DiQYQ!XOOOOQg'#Dz'#DzOOQg'#Fc'#FcOOQg'#Ge'#GeOOQg'#G}'#G}OOQg'#Cw'#CwOOQg'#C{'#C{OOQg'#C}'#C}OOQg'#DR'#DROOQg'#DZ'#DZOOQg'#D['#D[OOQg'#D]'#D]O##}QpO'#DyOOQg,59R,59RO#$SQ!XO,59ROOQg,59U,59UO#$ZQ!XO,59UOOQg,59X,59XO#$bQ!XO,59XOOQg,59Z,59ZO#$iQ!XO,59ZO8yO!bO'#CrOOOO'#Dj'#DjO#$pO!bO'#DsOOQg'#Ds'#DsOOQg,59],59]OOQg,59_,59_OOQg,59`,59`OOQg,59e,59eOOQg,59f,59fOOQg'#Cx'#CxOOQg,5>t,5>tO#${Q!XO,5>tOOQg,5?O,5?OOOQg'#C|'#C|O#<_Q!XO'#DOOOQg,5?Q,5?QOOQg,59l,59lO#<fQ!XO,59lOOOO'#Dl'#DlO#<mO#tO,59yOOQg,59y,59yO#<xO&jO,59{OOQg-E7g-E7gO#=WO&jO'#DSOOQg,5:e,5:eOOQg1G.m1G.mOOQg1G.p1G.pOOQg1G.s1G.sOOQg1G.u1G.uOOOO,59^,59^OOOO-E7h-E7hOOQg,5:_,5:_OOQg1G4`1G4`OOQg,59j,59jO#=fQ!XO,59jOOQg1G/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PPP-RPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP-RPPPPPPPPPPPPPPPPPPPPPPP-RPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP(XPPPPPPPPP(XP(XqcOPQRS^esuwy!Y!]!n!r!zqWOPQRS^esuwy!Y!]!n!r!zZ{TUVz|qbOPQRS^esuwy!Y!]!n!r!zqZOPQRS^esuwy!Y!]!n!r!zQ!UZR!l!VpbOPQRS^esuwy!Y!]!n!r!zR!UZpbOPQRS^esuwy!Y!]!n!r!zR!VZq[OPQRS^esuwy!Y!]!n!r!zR!W[q]OPQRS^esuwy!Y!]!n!r!zR!Z]R!dqX!s!a!c!t!vQeOQsPQuQQwRQySQ!]^`!besuwy!]!n!zQ!n!YR!z!rW|TUVzR!j|Q!t!aQ!v!cT!{!t!vQ!_`R!p!_qdOPQRS^esuwy!Y!]!n!r!zQ!OTQ!PUQ!QVR!izqXOPQRS^esuwy!Y!]!n!r!z",
320
+ nodeNames: "⚠ InterpPrefix InterpKeyword StdNamespace StdTypeName StdTypeName QualifiedType LineComment Program ) ( Parens ] [ Brackets } { Braces ⟩ Anonymous ⟨ BlockComment NestedComment DocComment ModuleDoc Keyword Identifier Keyword DefinitionName StdQualifiedType StdQualifiedType Keyword Keyword Keyword Attribute @[ Attribute Modifier InterpolatedString InterpEscape InterpBraces InterpBraceStart Incomplete HashCommand SymbolKeyword Sort TypeName BooleanLiteral NameLiteral String Escape StringInterp RawString Char CharEscape Scientific Number Operator Unknown",
321
+ maxTerm: 416,
322
+ nodeProps: [
323
+ ["openedBy", 9,"(",12,"[ @[",15,"{",18,"⟨"],
324
+ ["closedBy", 10,")",-2,13,35,"]",16,"}",20,"⟩"]
325
+ ],
326
+ skippedNodes: [0,7],
327
+ repeatNodeCount: 4,
328
+ tokenData: "!?S~R#[OX'wX^'|^p'wpq'|qr)hrs.Yst.atu)huv)hvw)hwx3kxy6dyz6kz{)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`<%l'w~!>yR![~;=`;@r'w;@r;FbNX;Fb<%l'w",
329
+ tokenizers: [interpPrefixToken, interpKeywordToken, stdNamespaceToken, stdTypeNameToken, qualifiedTypeToken, 3, new lr.LocalTokenGroup("p~RQ}!OX!P!Qd~[P!P!Q_~dO!j~~gP}!Oj~oO!i~~", 31, 70), new lr.LocalTokenGroup("x~RQrsX#O#P^~^O*Q~~aRO;'Sj;'S;=`o;=`Oj~oO!S~~tP!S~;=`<%lj~", 39, 415), new lr.LocalTokenGroup("!Q~RRrs[#O#Pa#o#pz~aO'h~~dRO;'Sm;'S;=`r;=`Om~rOw~~wPw~;=`<%lm~!POy~~", 47, 299)],
330
+ topRules: {"Program":[0,8]},
331
+ specialized: [{term: 26, get: (value) => spec_Identifier[value] || -1},{term: 43, get: (value) => spec_HashCommand[value] || -1}],
332
+ tokenPrec: 5591
333
+ });
334
+
335
+ // The tokens that open a bracket pair. `InterpBraceStart` is the `{` of an
336
+ // interpolation in `s!"…"`, and `@[` opens an attribute list.
337
+ const opening = new Set(["(", "[", "@[", "{", "⟨", "InterpBraceStart"]);
338
+ // A line that starts with a focus dot, as in the Lean 4 VS Code extension's
339
+ // only `onEnterRules` entry.
340
+ const focusDot = /^\s*[·.]\s/;
341
+ /// Indentation for a new line, as in the Lean 4 VS Code extension: it starts
342
+ /// where the line before it starts, one level deeper when that line ends
343
+ /// with an opening bracket or begins with a focus dot.
344
+ ///
345
+ /// Lean's layout carries meaning and is the author's to decide, so this
346
+ /// only answers for a line that is being broken (Enter). Asked about a line
347
+ /// that already exists, it returns `null`, which leaves the line alone.
348
+ function leanIndent(context) {
349
+ const { pos } = context;
350
+ if (context.simulatedBreak !== pos)
351
+ return null;
352
+ // Read the line from the document itself: with the double break that
353
+ // Enter simulates between a pair of brackets, the context reports the
354
+ // text before the break as empty.
355
+ const line = context.state.doc.lineAt(pos);
356
+ const before = line.text.slice(0, pos - line.from);
357
+ const indent = context.countColumn(before, before.search(/\S|$/));
358
+ if (focusDot.test(before))
359
+ return indent + context.unit;
360
+ const text = before.trimEnd();
361
+ if (text === "")
362
+ return indent;
363
+ const last = language.syntaxTree(context.state).resolveInner(line.from + text.length, -1);
364
+ return opening.has(last.name) ? indent + context.unit : indent;
365
+ }
366
+
367
+ /******************************************************************************
368
+ Copyright (c) Microsoft Corporation.
369
+
370
+ Permission to use, copy, modify, and/or distribute this software for any
371
+ purpose with or without fee is hereby granted.
372
+
373
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
374
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
375
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
376
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
377
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
378
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
379
+ PERFORMANCE OF THIS SOFTWARE.
380
+ ***************************************************************************** */
381
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
382
+
383
+
384
+ function __awaiter(thisArg, _arguments, P, generator) {
385
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
386
+ return new (P || (P = Promise))(function (resolve, reject) {
387
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
388
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
389
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
390
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
391
+ });
392
+ }
393
+
394
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
395
+ var e = new Error(message);
396
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
397
+ };
398
+
399
+ function resolveConfig(config) {
400
+ var _a, _b, _c, _d;
401
+ return {
402
+ abbreviationCharacter: (_a = config.leader) !== null && _a !== void 0 ? _a : "\\",
403
+ customTranslations: (_b = config.customTranslations) !== null && _b !== void 0 ? _b : {},
404
+ eagerReplacementEnabled: (_c = config.eagerReplacement) !== null && _c !== void 0 ? _c : true,
405
+ inStringLiterals: (_d = config.inStringLiterals) !== null && _d !== void 0 ? _d : false,
406
+ };
407
+ }
408
+ const stringLiteralNodes = new Set([
409
+ "String",
410
+ "RawString",
411
+ "StringInterp",
412
+ "InterpolatedString",
413
+ "Char",
414
+ "CharEscape",
415
+ ]);
416
+ // Whether `pos` is inside the quotes of a string or character literal.
417
+ function insideStringLiteral(state, pos) {
418
+ var _a;
419
+ const tree = language.syntaxTree(state);
420
+ // A character literal that is still being typed is not a literal to the
421
+ // parser yet: all there is before the cursor is a lone `'` operator, or
422
+ // that and the backslash of an escape (the second leader of `'\\'`).
423
+ // (`x'` is an identifier, so a leader after it still starts an
424
+ // abbreviation.)
425
+ const before = state.sliceDoc(Math.max(0, pos - 2), pos);
426
+ const quote = before.endsWith("'") ? pos - 1 : before === "'\\" ? pos - 2 : -1;
427
+ if (quote >= 0) {
428
+ const node = tree.resolveInner(quote + 1, -1);
429
+ if (node.name === "Operator" && node.from === quote)
430
+ return true;
431
+ }
432
+ const inner = tree.resolveInner(pos, -1);
433
+ for (let node = inner; node; node = node.parent) {
434
+ // Strictly inside the node, or at the end of one that isn't closed yet
435
+ // (a string without its closing quote runs to the end of the document).
436
+ const inside = node.from < pos && (pos < node.to || !!((_a = node.lastChild) === null || _a === void 0 ? void 0 : _a.type.isError));
437
+ if (!inside)
438
+ continue;
439
+ // The braces of an `s!"…{…}…"` interpolation hold ordinary code.
440
+ if (node.name === "InterpBraces")
441
+ return false;
442
+ if (stringLiteralNodes.has(node.name))
443
+ return true;
444
+ }
445
+ return false;
446
+ }
447
+ // Dispatched when the set of tracked abbreviations changed without the
448
+ // document changing, so that the underline is redrawn.
449
+ const trackingChanged = state.StateEffect.define();
450
+ /// Connects one editor to the abbreviation engine. The host must call
451
+ /// `applyChanges` for every transaction as it is applied, and `afterUpdate`
452
+ /// once the new state is in place.
453
+ class AbbreviationSession {
454
+ constructor(host, config = {}, provider) {
455
+ this.host = host;
456
+ // Replacements run one after the other: each one may dispatch, which
457
+ // reports further changes while it is still in progress.
458
+ this.queue = Promise.resolve();
459
+ // How many of them have not finished yet.
460
+ this.unfinished = 0;
461
+ this.failed = false;
462
+ this.destroyed = false;
463
+ this.config = resolveConfig(config);
464
+ this.rewriter = new unicodeInput.AbbreviationRewriter(this.config, provider !== null && provider !== void 0 ? provider : new unicodeInput.AbbreviationProvider(this.config), this);
465
+ }
466
+ /// The abbreviations being typed, leader included, as document ranges.
467
+ get tracked() {
468
+ const ranges = [];
469
+ for (const { range } of this.rewriter.getTrackedAbbreviations())
470
+ ranges.push({ from: range.offset, to: range.offset + range.length });
471
+ return ranges.sort((a, b) => a.from - b.from);
472
+ }
473
+ /// Report a transaction's changes. Never dispatches, so it is safe to
474
+ /// call while the editor is updating.
475
+ applyChanges(startState, changes) {
476
+ if (changes.empty)
477
+ return;
478
+ const { abbreviationCharacter: leader, inStringLiterals } = this.config;
479
+ const input = [];
480
+ changes.iterChanges((fromA, toA, _fromB, _toB, inserted) => {
481
+ let newText = inserted.toString();
482
+ // The engine starts tracking when the inserted text is the leader.
483
+ // Where that must not happen, report text of the same length that
484
+ // isn't the leader, so that the positions it keeps stay correct.
485
+ if (newText === leader &&
486
+ !inStringLiterals &&
487
+ insideStringLiteral(startState, fromA))
488
+ newText = "\0".repeat(newText.length);
489
+ input.push({ range: new unicodeInput.Range(fromA, toA - fromA), newText });
490
+ });
491
+ try {
492
+ this.rewriter.changeInput(input);
493
+ }
494
+ catch (_a) {
495
+ this.rewriter.resetTrackedAbbreviations();
496
+ }
497
+ }
498
+ /// Let the engine react to the update that was just applied: replace what
499
+ /// the change finished, and what the cursor has left. Resolves once the
500
+ /// editor is up to date.
501
+ afterUpdate(docChanged, selectionSet) {
502
+ if (!docChanged && !selectionSet)
503
+ return this.queue;
504
+ if (this.rewriter.getTrackedAbbreviations().size === 0)
505
+ return this.queue;
506
+ return this.enqueue(() => __awaiter(this, void 0, void 0, function* () {
507
+ if (docChanged)
508
+ yield this.rewriter.triggerAbbreviationReplacement();
509
+ yield this.rewriter.changeSelections(this.collectSelections());
510
+ }));
511
+ }
512
+ /// Replace every abbreviation being typed, finished or not. This is VS
513
+ /// Code's `lean4.input.convert`, which it binds to Tab.
514
+ ///
515
+ /// The document is changed before this returns (unless a replacement is
516
+ /// still in progress), so that whatever runs next sees the symbols: the
517
+ /// rest of a key binding, or a host that reads the document when a button
518
+ /// is pressed. Only a cursor that the abbreviation places is moved later.
519
+ convertAll() {
520
+ return this.enqueue(() => this.rewriter.replaceAllTrackedAbbreviations(), true);
521
+ }
522
+ destroy() {
523
+ this.destroyed = true;
524
+ this.rewriter.resetTrackedAbbreviations();
525
+ }
526
+ enqueue(step, immediately = false) {
527
+ const idle = this.unfinished === 0;
528
+ this.unfinished++;
529
+ const run = () => this.execute(step).then(() => void this.unfinished--);
530
+ if (immediately && idle) {
531
+ // The queue has to name this step before it starts, for anything that
532
+ // is enqueued while it runs.
533
+ let finished;
534
+ const running = new Promise((resolve) => (finished = resolve));
535
+ this.queue = running;
536
+ void run().then(finished);
537
+ return running;
538
+ }
539
+ return (this.queue = this.queue.then(run));
540
+ }
541
+ // Runs one step, and never rejects.
542
+ execute(step) {
543
+ return __awaiter(this, void 0, void 0, function* () {
544
+ if (this.destroyed)
545
+ return;
546
+ try {
547
+ yield step();
548
+ }
549
+ catch (_a) {
550
+ this.failed = true;
551
+ }
552
+ if (this.failed && !this.destroyed) {
553
+ // Whatever went wrong, typing must keep working: forget what was
554
+ // being tracked and start afresh at the next leader.
555
+ this.failed = false;
556
+ const wasTracking = this.rewriter.getTrackedAbbreviations().size > 0;
557
+ this.rewriter.resetTrackedAbbreviations();
558
+ if (wasTracking)
559
+ this.host.dispatch({ effects: trackingChanged.of(null) });
560
+ }
561
+ });
562
+ }
563
+ // AbbreviationTextSource, the engine's view of the editor.
564
+ replaceAbbreviations(changes) {
565
+ try {
566
+ const { state } = this.host;
567
+ if (state.readOnly)
568
+ throw new Error("The editor is read-only");
569
+ if (changes.length === 0) {
570
+ // Nothing to replace (the abbreviation matched nothing), but it is
571
+ // no longer tracked, so its underline has to go.
572
+ this.host.dispatch({ effects: trackingChanged.of(null) });
573
+ return Promise.resolve(true);
574
+ }
575
+ const changeSet = state.changes(changes.map(({ range, newText }) => ({
576
+ from: range.offset,
577
+ to: range.offset + range.length,
578
+ insert: newText,
579
+ })));
580
+ this.host.dispatch({
581
+ changes: changeSet,
582
+ // A cursor inside an abbreviation ends up after its symbol.
583
+ selection: state.selection.map(changeSet, 1),
584
+ // Not "input.type": the replacement then is an undo step of its
585
+ // own, so that one undo brings back the abbreviation as typed.
586
+ userEvent: "input.abbreviation",
587
+ });
588
+ return Promise.resolve(true);
589
+ }
590
+ catch (_a) {
591
+ this.failed = true;
592
+ return Promise.resolve(false);
593
+ }
594
+ }
595
+ selectionMoveMode() {
596
+ // As in VS Code: only a cursor that sits right behind a replaced
597
+ // abbreviation moves, to where the abbreviation says the cursor goes
598
+ // (between the brackets of `\<>`, for instance).
599
+ return { kind: "OnlyMoveCursorSelections", updateUnchangedSelections: false };
600
+ }
601
+ collectSelections() {
602
+ return this.host.state.selection.ranges.map((range) => new unicodeInput.Range(range.from, range.to - range.from));
603
+ }
604
+ setSelections(selections) {
605
+ const { state: state$1 } = this.host;
606
+ const current = state$1.selection;
607
+ if (selections.length === 0 || selections.length !== current.ranges.length)
608
+ return;
609
+ const length = state$1.doc.length;
610
+ let moved = false;
611
+ const ranges = selections.map((selection, i) => {
612
+ const from = Math.min(selection.offset, length);
613
+ const to = Math.min(selection.offset + selection.length, length);
614
+ const before = current.ranges[i];
615
+ if (before.from === from && before.to === to)
616
+ return before;
617
+ moved = true;
618
+ return state.EditorSelection.range(from, to);
619
+ });
620
+ if (moved)
621
+ this.host.dispatch({
622
+ selection: state.EditorSelection.create(ranges, current.mainIndex),
623
+ });
624
+ }
625
+ }
626
+ // The session of each editor that has the extension, for the command below.
627
+ const sessions = new WeakMap();
628
+ // VS Code underlines the abbreviation being typed.
629
+ const trackedMark = view.Decoration.mark({ class: "cm-lean-abbreviation" });
630
+ const abbreviationTheme = view.EditorView.baseTheme({
631
+ ".cm-lean-abbreviation": { textDecoration: "underline" },
632
+ ".cm-lean-abbreviation-hint": { padding: "3px 8px" },
633
+ ".cm-lean-abbreviation-hint code": { fontFamily: "monospace" },
634
+ });
635
+ /// The hint for the symbol that starts at `pos`, if the table has one. This
636
+ /// is what the VS Code extension shows on hover, from the same table.
637
+ ///
638
+ /// Characters every keyboard has give no hint (the table has `\\` for `\`),
639
+ /// and neither does a symbol in a string or character literal, unless
640
+ /// abbreviations work there.
641
+ function abbreviationHintAt(state, pos, config = {}, provider = new unicodeInput.AbbreviationProvider(resolveConfig(config))) {
642
+ const line = state.doc.lineAt(pos);
643
+ const leader = provider.config.abbreviationCharacter;
644
+ const symbols = provider.findSymbolsIn(line.text.slice(pos - line.from));
645
+ for (const symbol of symbols) {
646
+ if (!/[^\x00-\x7f]/.test(symbol))
647
+ continue;
648
+ const abbreviations = provider.collectAllAbbreviations(symbol);
649
+ if (abbreviations.length === 0)
650
+ continue;
651
+ if (!config.inStringLiterals && insideStringLiteral(state, pos))
652
+ return null;
653
+ return {
654
+ from: pos,
655
+ to: pos + symbol.length,
656
+ symbol,
657
+ abbreviations: abbreviations.map((abbreviation) => leader + abbreviation),
658
+ pairs: provider
659
+ .findAutoClosingAbbreviations(symbol)
660
+ .map(([abbreviation, closing]) => ({
661
+ abbreviation: leader + abbreviation,
662
+ closing,
663
+ })),
664
+ };
665
+ }
666
+ return null;
667
+ }
668
+ // "Type ⟨ using \< or \langle. ⟨ can be auto-closed with ⟩ using \<>."
669
+ function renderHint(hint) {
670
+ const dom = document.createElement("div");
671
+ dom.className = "cm-lean-abbreviation-hint";
672
+ const code = (text) => {
673
+ dom.appendChild(document.createElement("code")).textContent = text;
674
+ };
675
+ dom.append(`Type ${hint.symbol} using `);
676
+ hint.abbreviations.forEach((abbreviation, index) => {
677
+ if (index > 0)
678
+ dom.append(" or ");
679
+ code(abbreviation);
680
+ });
681
+ if (hint.pairs.length > 0) {
682
+ dom.append(`. ${hint.symbol} can be auto-closed with `);
683
+ hint.pairs.forEach(({ abbreviation, closing }, index) => {
684
+ if (index > 0)
685
+ dom.append(" or ");
686
+ dom.append(`${closing} using `);
687
+ code(abbreviation);
688
+ });
689
+ dom.append(".");
690
+ }
691
+ return dom;
692
+ }
693
+ class AbbreviationPlugin {
694
+ constructor(view$1, config, provider) {
695
+ this.view = view$1;
696
+ this.decorations = view.Decoration.none;
697
+ this.session = new AbbreviationSession(view$1, config, provider);
698
+ sessions.set(view$1, this.session);
699
+ }
700
+ update(update) {
701
+ for (const tr of update.transactions)
702
+ this.session.applyChanges(tr.startState, tr.changes);
703
+ const length = update.state.doc.length;
704
+ this.decorations = view.Decoration.set(this.session.tracked
705
+ .filter(({ from, to }) => from < to && to <= length)
706
+ .map(({ from, to }) => trackedMark.range(from, to)));
707
+ }
708
+ destroy() {
709
+ this.session.destroy();
710
+ if (sessions.get(this.view) === this.session)
711
+ sessions.delete(this.view);
712
+ }
713
+ }
714
+ /// Replace the abbreviations being typed with their symbols right away.
715
+ /// Returns false, leaving the key to other bindings, when there are none.
716
+ const convertLeanAbbreviations = (view) => {
717
+ const session = sessions.get(view);
718
+ if (!session || session.tracked.length === 0)
719
+ return false;
720
+ void session.convertAll();
721
+ return true;
722
+ };
723
+ // The same, but never claims the key: what the key normally does happens
724
+ // next, on the document with the symbols in it.
725
+ const convertFirst = (view) => {
726
+ convertLeanAbbreviations(view);
727
+ return false;
728
+ };
729
+ /// Lean's `\`-abbreviations, as an extension. `lean()` includes it.
730
+ function leanUnicodeInput(config = {}) {
731
+ // The table is the same for every editor this extension ends up in.
732
+ const provider = new unicodeInput.AbbreviationProvider(resolveConfig(config));
733
+ const plugin = view.ViewPlugin.define((view) => new AbbreviationPlugin(view, config, provider), { decorations: (instance) => instance.decorations });
734
+ return [
735
+ plugin,
736
+ // Listeners run once the update is complete, which is when the engine
737
+ // may dispatch its replacements.
738
+ view.EditorView.updateListener.of((update) => {
739
+ var _a;
740
+ const session = (_a = update.view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.session;
741
+ if (!session)
742
+ return;
743
+ void session.afterUpdate(update.docChanged, update.selectionSet);
744
+ }),
745
+ // VS Code replaces everything when the editor is switched away from.
746
+ // Here that is when focus moves elsewhere on the page, and it is done
747
+ // in the event itself: pressing a button is what takes the focus away,
748
+ // and the button's action must find the symbols in the document.
749
+ // Switching to another window is not leaving the editor.
750
+ view.EditorView.domEventHandlers({
751
+ blur(_event, view) {
752
+ if (view.dom.ownerDocument.hasFocus())
753
+ convertLeanAbbreviations(view);
754
+ return false;
755
+ },
756
+ }),
757
+ state.Prec.highest(view.keymap.of([
758
+ // Only takes Tab while an abbreviation is being typed. Highest
759
+ // precedence, because the editor's own Tab binding would otherwise
760
+ // indent instead.
761
+ { key: "Tab", run: convertLeanAbbreviations },
762
+ // A new line is indented by what is in front of it. Replace first,
763
+ // so that `\<` counts as the opening bracket it is about to become.
764
+ { key: "Enter", run: convertFirst, shift: convertFirst },
765
+ { key: "Mod-Enter", run: convertFirst },
766
+ ])),
767
+ config.hover === false
768
+ ? []
769
+ : view.hoverTooltip((view, pos, side) => {
770
+ // `pos` is the position nearest the pointer. The character under
771
+ // the pointer starts there, or ends there when the pointer is to
772
+ // its left.
773
+ const line = view.state.doc.lineAt(pos);
774
+ const start = side < 0
775
+ ? line.from + state.findClusterBreak(line.text, pos - line.from, false)
776
+ : pos;
777
+ const hint = abbreviationHintAt(view.state, start, config, provider);
778
+ if (!hint)
779
+ return null;
780
+ return {
781
+ pos: hint.from,
782
+ end: hint.to,
783
+ above: true,
784
+ create: () => ({ dom: renderHint(hint) }),
785
+ };
786
+ }),
787
+ abbreviationTheme,
788
+ ];
789
+ }
790
+
791
+ const leanLanguage = language.LRLanguage.define({
792
+ name: "lean",
793
+ parser: parser.configure({
794
+ props: [
795
+ highlight.styleTags({
796
+ // Modifiers (`private`, `partial`, …) are a node of their own but
797
+ // share the keyword tag: that is how VS Code's stock themes show
798
+ // them, and `t.modifier` would give them the colour of a type name
799
+ // in Exercism's dark theme (One Dark), where types should stand out.
800
+ "Keyword SymbolKeyword InterpKeyword Modifier": highlight.tags.keyword,
801
+ // The name a declaration introduces, as in `def add`. Not every
802
+ // such name is a function (`structure Point`), but the Lean 4 VS
803
+ // Code extension's grammar calls them all `entity.name.function`.
804
+ "DefinitionName/Identifier": highlight.tags.function(highlight.tags.definition(highlight.tags.variableName)),
805
+ // `@[simp]` and the list of `attribute [simp]`, as one unit: the
806
+ // `!` keeps what is inside from being styled on its own.
807
+ "Attribute!": highlight.tags.meta,
808
+ Incomplete: highlight.tags.invalid,
809
+ HashCommand: highlight.tags.meta,
810
+ "Sort TypeName StdTypeName": highlight.tags.typeName,
811
+ "QualifiedType StdNamespace": highlight.tags.namespace,
812
+ BooleanLiteral: highlight.tags.bool,
813
+ Identifier: highlight.tags.variableName,
814
+ NameLiteral: highlight.tags.atom,
815
+ "String RawString StringInterp InterpolatedString": highlight.tags.string,
816
+ "InterpPrefix InterpBraceStart": highlight.tags.meta,
817
+ Char: highlight.tags.character,
818
+ "Escape CharEscape InterpEscape": highlight.tags.escape,
819
+ Number: highlight.tags.number,
820
+ Scientific: highlight.tags.float,
821
+ LineComment: highlight.tags.lineComment,
822
+ "BlockComment NestedComment": highlight.tags.blockComment,
823
+ "DocComment ModuleDoc": highlight.tags.docComment,
824
+ "Operator [ ]": highlight.tags.operator,
825
+ "( )": highlight.tags.paren,
826
+ "{ }": highlight.tags.brace,
827
+ "⟨ ⟩": highlight.tags.bracket,
828
+ // InterpBraces closes with the same "}" token ordinary Braces
829
+ // does (see the grammar comment on InterpBraces for why), so this
830
+ // more specific, parent-scoped rule is what makes it read as part
831
+ // of the interpolation instead of an ordinary brace — it takes
832
+ // priority over the generic "{ }" rule above for this one case.
833
+ "InterpBraces/}": highlight.tags.meta,
834
+ }),
835
+ // One rule for every node, so that neither the bracket-aligning
836
+ // default for delimited nodes nor the column-0 default for the top
837
+ // node applies. See `leanIndent`.
838
+ language.indentNodeProp.add(() => leanIndent),
839
+ language.foldNodeProp.add({
840
+ "Parens Brackets Braces Anonymous": language.foldInside,
841
+ "BlockComment DocComment ModuleDoc": language.foldInside,
842
+ }),
843
+ ],
844
+ }),
845
+ languageData: {
846
+ commentTokens: {
847
+ line: "--",
848
+ block: { open: "/-", close: "-/" },
849
+ },
850
+ closeBrackets: {
851
+ brackets: ["(", "[", "{", "⟨", '"'],
852
+ // A quote typed right after a word is not closed, unless the word is
853
+ // one of these. `!` counts as part of a word here, see `wordChars`.
854
+ stringPrefixes: ["s!", "f!", "m!", "r"],
855
+ },
856
+ // `x'`, `get!` and `find?` are names, so a double click, word motion and
857
+ // whole-word search take each as one word. The Lean 4 VS Code extension
858
+ // does this with its `wordPattern`.
859
+ wordChars: "'!?",
860
+ },
861
+ });
862
+ function lean(config = {}) {
863
+ const { unicodeInput = true } = config;
864
+ return new language.LanguageSupport(leanLanguage, unicodeInput === false
865
+ ? []
866
+ : [leanUnicodeInput(unicodeInput === true ? {} : unicodeInput)]);
867
+ }
868
+
869
+ exports.abbreviationHintAt = abbreviationHintAt;
870
+ exports.convertLeanAbbreviations = convertLeanAbbreviations;
871
+ exports.lean = lean;
872
+ exports.leanLanguage = leanLanguage;
873
+ exports.leanUnicodeInput = leanUnicodeInput;