@exercism/codemirror-lang-vimscript 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,1310 @@
1
+ 'use strict';
2
+
3
+ var lr = require('@lezer/lr');
4
+ var language = require('@codemirror/language');
5
+ var highlight = require('@lezer/highlight');
6
+ var autocomplete = require('@codemirror/autocomplete');
7
+
8
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
9
+ const newline = 166,
10
+ continuation = 167,
11
+ Comment = 1,
12
+ doubleQuoted = 168,
13
+ memberDot = 169,
14
+ RawArgs = 2,
15
+ kw_let = 3,
16
+ kw_const = 4,
17
+ kw_var = 5,
18
+ kw_final = 6,
19
+ kw_unlet = 7,
20
+ kw_return = 8,
21
+ kw_call = 9,
22
+ kw_eval = 10,
23
+ kw_throw = 11,
24
+ kw_echo = 12,
25
+ kw_execute = 13,
26
+ kw_break = 14,
27
+ kw_continue = 15,
28
+ kw_if = 16,
29
+ kw_elseif = 17,
30
+ kw_else = 18,
31
+ kw_endif = 19,
32
+ kw_for = 20,
33
+ kw_in = 21,
34
+ kw_endfor = 22,
35
+ kw_while = 23,
36
+ kw_endwhile = 24,
37
+ kw_try = 25,
38
+ kw_catch = 26,
39
+ kw_finally = 27,
40
+ kw_endtry = 28,
41
+ kw_function = 29,
42
+ kw_endfunction = 30,
43
+ kw_def = 31,
44
+ kw_enddef = 32,
45
+ kw_class = 33,
46
+ kw_endclass = 34,
47
+ kw_range = 35,
48
+ kw_abort = 36,
49
+ kw_dict = 37,
50
+ kw_closure = 38,
51
+ kw_is = 39,
52
+ kw_isnot = 40,
53
+ kw_modifier = 170,
54
+ CommandName = 41;
55
+
56
+ function isLetter(ch) {
57
+ return (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) || ch == 95 /* Ch.Underscore */;
58
+ }
59
+ function isWordChar(ch) {
60
+ return isLetter(ch) || (ch >= 48 && ch <= 57) || ch == 35 /* Ch.Hash */;
61
+ }
62
+ function isBlank(ch) {
63
+ return ch == 32 /* Ch.Space */ || ch == 9 /* Ch.Tab */;
64
+ }
65
+ function isLineEnd(ch) {
66
+ return ch == 10 /* Ch.Newline */ || ch == 13 /* Ch.Return */ || ch == -1 /* Ch.EOF */;
67
+ }
68
+ // True if only spaces and tabs come between the start of the line and the
69
+ // current position.
70
+ function atLineStart(input) {
71
+ for (let i = -1;; i--) {
72
+ const ch = input.peek(i);
73
+ if (ch == 10 /* Ch.Newline */ || ch == -1 /* Ch.EOF */)
74
+ return true;
75
+ if (!isBlank(ch))
76
+ return false;
77
+ }
78
+ }
79
+ function skipBlanks(input, offset) {
80
+ while (isBlank(input.peek(offset)))
81
+ offset++;
82
+ return offset;
83
+ }
84
+ function lineEnd(input, offset) {
85
+ while (!isLineEnd(input.peek(offset)))
86
+ offset++;
87
+ return offset;
88
+ }
89
+ // The offset just past the line break at `offset`.
90
+ function pastBreak(input, offset) {
91
+ if (input.peek(offset) == 13 /* Ch.Return */)
92
+ offset++;
93
+ if (input.peek(offset) == 10 /* Ch.Newline */)
94
+ offset++;
95
+ return offset;
96
+ }
97
+ // If the line at `offset` carries on the line before it, this returns the
98
+ // offset where the carried-on text starts. Otherwise it returns -1.
99
+ //
100
+ // A line carries on with a leading `\`, and in Vim9 script with a leading
101
+ // `->`, `&&`, `||` or `..`. A comment line written as `"\ text` can sit
102
+ // between continued lines.
103
+ function continuedLine(input, offset) {
104
+ for (;;) {
105
+ const start = skipBlanks(input, offset);
106
+ const ch = input.peek(start);
107
+ const next = input.peek(start + 1);
108
+ if (ch == 92 /* Ch.Backslash */)
109
+ return start + 1;
110
+ if (ch == 34 /* Ch.Quote */ && next == 92 /* Ch.Backslash */ && isBlank(input.peek(start + 2))) {
111
+ const end = lineEnd(input, start);
112
+ if (input.peek(end) == -1 /* Ch.EOF */)
113
+ return -1;
114
+ offset = pastBreak(input, end);
115
+ continue;
116
+ }
117
+ if ((ch == 45 /* Ch.Minus */ && next == 62 /* Ch.Greater */) ||
118
+ (ch == 38 /* Ch.Ampersand */ && next == 38 /* Ch.Ampersand */) ||
119
+ (ch == 124 /* Ch.Bar */ && next == 124 /* Ch.Bar */) ||
120
+ (ch == 46 /* Ch.Dot */ && next == 46 /* Ch.Dot */))
121
+ return start;
122
+ return -1;
123
+ }
124
+ }
125
+ function readComment(input) {
126
+ while (!isLineEnd(input.next))
127
+ input.advance();
128
+ input.acceptToken(Comment);
129
+ }
130
+ // Reads a double-quoted string, where `\` escapes the next character. A string
131
+ // that isn't closed on its line is read as a comment instead, since that's
132
+ // what an old-style trailing comment looks like.
133
+ function readDoubleQuoted(input, start) {
134
+ for (let i = start + 1;; i++) {
135
+ const ch = input.peek(i);
136
+ if (isLineEnd(ch))
137
+ break;
138
+ if (ch == 92 /* Ch.Backslash */) {
139
+ if (isLineEnd(input.peek(i + 1)))
140
+ break;
141
+ i++;
142
+ }
143
+ else if (ch == 34 /* Ch.Quote */) {
144
+ input.acceptToken(doubleQuoted, i + 1);
145
+ return;
146
+ }
147
+ }
148
+ readComment(input);
149
+ }
150
+ // Counts the brackets open at each point. A line break inside a bracket
151
+ // doesn't end the command, as Vim9 script allows.
152
+ const bracketDepth = new lr.ContextTracker({
153
+ start: 0,
154
+ shift(depth, term, _stack, input) {
155
+ if (term == RawArgs)
156
+ return depth;
157
+ const ch = input.next;
158
+ if (ch == 40 /* Ch.ParenL */ || ch == 91 /* Ch.BracketL */ || ch == 123 /* Ch.BraceL */)
159
+ return depth + 1;
160
+ if (ch == 35 /* Ch.Hash */ && input.peek(1) == 123 /* Ch.BraceL */)
161
+ return depth + 1;
162
+ if (ch == 41 /* Ch.ParenR */ || ch == 93 /* Ch.BracketR */ || ch == 125 /* Ch.BraceR */)
163
+ return Math.max(0, depth - 1);
164
+ return depth;
165
+ },
166
+ hash: (depth) => depth,
167
+ });
168
+ const lineTokens = new lr.ExternalTokenizer((input, stack) => {
169
+ const ch = input.next;
170
+ if (ch == 10 /* Ch.Newline */ || ch == 13 /* Ch.Return */) {
171
+ const after = pastBreak(input, 0);
172
+ const carried = continuedLine(input, after);
173
+ if (carried >= 0)
174
+ input.acceptToken(continuation, carried);
175
+ else if (stack.context > 0)
176
+ input.acceptToken(continuation, after);
177
+ else
178
+ input.acceptToken(newline, after);
179
+ return;
180
+ }
181
+ if (stack.canShift(RawArgs) &&
182
+ !isBlank(ch) &&
183
+ !isLineEnd(ch) &&
184
+ ch != 124 /* Ch.Bar */ &&
185
+ !(ch == 33 /* Ch.Bang */ && isLetter(input.peek(-1)))) {
186
+ input.acceptToken(RawArgs, lineEnd(input, 0));
187
+ return;
188
+ }
189
+ if (ch == 34 /* Ch.Quote */) {
190
+ const comment = !stack.canShift(doubleQuoted) || (atLineStart(input) && stack.canShift(newline));
191
+ if (comment)
192
+ readComment(input);
193
+ else
194
+ readDoubleQuoted(input, 0);
195
+ return;
196
+ }
197
+ if (ch == 36 /* Ch.Dollar */ && input.peek(1) == 34 /* Ch.Quote */ && stack.canShift(doubleQuoted)) {
198
+ readDoubleQuoted(input, 1);
199
+ return;
200
+ }
201
+ if (ch == 35 /* Ch.Hash */) {
202
+ const before = input.peek(-1);
203
+ if (input.peek(1) != 123 /* Ch.BraceL */ && (isBlank(before) || isLineEnd(before)))
204
+ readComment(input);
205
+ return;
206
+ }
207
+ if (ch == 46 /* Ch.Dot */) {
208
+ const before = input.peek(-1);
209
+ if (isLetter(input.peek(1)) &&
210
+ (isWordChar(before) || before == 41 /* Ch.ParenR */ || before == 93 /* Ch.BracketR */ || before == 125 /* Ch.BraceR */) &&
211
+ stack.canShift(memberDot))
212
+ input.acceptToken(memberDot, 1);
213
+ }
214
+ }, { contextual: true });
215
+ // Each command word, with the shortest abbreviation Vim accepts for it.
216
+ const commandWords = [
217
+ ["let", 3, kw_let],
218
+ ["const", 4, kw_const],
219
+ ["var", 3, kw_var],
220
+ ["final", 5, kw_final],
221
+ ["unlet", 3, kw_unlet],
222
+ ["return", 4, kw_return],
223
+ ["call", 3, kw_call],
224
+ ["eval", 2, kw_eval],
225
+ ["throw", 2, kw_throw],
226
+ ["echo", 2, kw_echo],
227
+ ["echon", 5, kw_echo],
228
+ ["echomsg", 5, kw_echo],
229
+ ["echoerr", 5, kw_echo],
230
+ ["echowindow", 5, kw_echo],
231
+ ["echoconsole", 7, kw_echo],
232
+ ["execute", 3, kw_execute],
233
+ ["break", 4, kw_break],
234
+ ["continue", 3, kw_continue],
235
+ ["if", 2, kw_if],
236
+ ["elseif", 5, kw_elseif],
237
+ ["else", 2, kw_else],
238
+ ["endif", 2, kw_endif],
239
+ ["for", 3, kw_for],
240
+ ["in", 2, kw_in],
241
+ ["endfor", 5, kw_endfor],
242
+ ["while", 2, kw_while],
243
+ ["endwhile", 4, kw_endwhile],
244
+ ["try", 3, kw_try],
245
+ ["catch", 3, kw_catch],
246
+ ["finally", 4, kw_finally],
247
+ ["endtry", 4, kw_endtry],
248
+ ["function", 2, kw_function],
249
+ ["endfunction", 4, kw_endfunction],
250
+ ["def", 3, kw_def],
251
+ ["enddef", 6, kw_enddef],
252
+ ["class", 5, kw_class],
253
+ ["endclass", 8, kw_endclass],
254
+ ["range", 5, kw_range],
255
+ ["abort", 5, kw_abort],
256
+ ["dict", 4, kw_dict],
257
+ ["closure", 7, kw_closure],
258
+ ["is", 2, kw_is],
259
+ ["is#", 3, kw_is],
260
+ ["isnot", 5, kw_isnot],
261
+ ["isnot#", 6, kw_isnot],
262
+ ];
263
+ const keywordMap = new Map();
264
+ for (const [word, min, term] of commandWords)
265
+ for (let len = min; len <= word.length; len++) {
266
+ const short = word.slice(0, len);
267
+ if (!keywordMap.has(short))
268
+ keywordMap.set(short, term);
269
+ }
270
+ // Ex commands whose arguments the grammar keeps as plain text. Commands that
271
+ // share a name with a built-in function, such as `sort` and `map`, are left
272
+ // out so that a Vim9 statement such as `sort(items)` still reads as a call.
273
+ const rawCommands = [
274
+ "normal", "set", "setlocal", "setglobal", "scriptencoding", "scriptversion",
275
+ "syntax", "highlight", "autocmd", "augroup", "command", "filetype", "source",
276
+ "runtime", "packadd", "redraw", "sleep", "lockvar",
277
+ "unlockvar", "vim9script", "defcompile", "finish", "echohl", "delfunction",
278
+ "nnoremap", "vnoremap", "inoremap", "xnoremap", "onoremap", "cnoremap",
279
+ "tnoremap", "noremap", "nmap", "vmap", "imap", "xmap", "omap", "cmap", "tmap",
280
+ "unmap", "nunmap", "vunmap", "iunmap", "abbreviate", "iabbrev", "cabbrev",
281
+ "colorscheme", "compiler", "doautocmd", "startinsert", "stopinsert", "wincmd",
282
+ "language", "messages", "redir", "wincmd", "edit", "write", "quit", "wq",
283
+ "buffer", "bdelete", "tabnew", "vsplit", "cd", "lcd", "retab", "undo",
284
+ "nohlsearch", "debug", "breakadd", "profile", "import", "export",
285
+ ];
286
+ // Words that go in front of another command and change how it runs, as in
287
+ // `silent! call Setup()`.
288
+ const commandModifiers = [
289
+ "silent", "unsilent", "keepjumps", "keeppatterns", "keepalt", "keepmarks",
290
+ "noautocmd", "verbose", "sandbox", "lockmarks", "noswapfile", "vertical",
291
+ "aboveleft", "belowright", "botright", "topleft", "tab", "legacy", "vim9cmd",
292
+ ];
293
+ for (const word of rawCommands)
294
+ keywordMap.set(word, CommandName);
295
+ keywordMap.set("hi", CommandName);
296
+ keywordMap.set("au", CommandName);
297
+ keywordMap.set("aug", CommandName);
298
+ keywordMap.set("com", CommandName);
299
+ keywordMap.set("norm", CommandName);
300
+ for (const word of commandModifiers)
301
+ keywordMap.set(word, kw_modifier);
302
+ keywordMap.set("sil", kw_modifier);
303
+ keywordMap.set("se", CommandName);
304
+ keywordMap.set("setl", CommandName);
305
+ keywordMap.set("syn", CommandName);
306
+ // Command words are keywords only where the parser can take one. Elsewhere
307
+ // they stay names, so `range(5)` and `call(F, [])` read as calls.
308
+ function keywords(value, stack) {
309
+ const term = keywordMap.get(value);
310
+ return term != null && stack.canShift(term) ? term : -1;
311
+ }
312
+
313
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
314
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(mQ(}(qR)R(yR&d%P",
319
+ nodeNames: "⚠ Comment RawArgs let const var final unlet return call eval throw echo execute break continue if elseif else endif for in endfor while endwhile try catch finally endtry function endfunction def enddef class endclass range abort dict closure is isnot CommandName Program : CommandModifier ! LetStatement VariableDefinition ] [ ListPattern VariableName Subscript Number String List , } { Dictionary DictionaryEntry #{ LiteralDictionary LiteralEntry PropertyName Lambda -> ArrowFunction ) ( ParamList Parameter Type TypeName < > Spread ... Parameter => ParenthesizedExpression Option EnvironmentVariable Register UnaryExpression LogicOp ArithOp - + BinaryExpression ArithOp * / % ArithOp ConcatOp CompareOp IsOp LogicOp && LogicOp || LogicOp ?? TernaryExpression ? CallExpression ArgList SubscriptExpression MemberExpression Property MethodCall MethodName ; AssignOp UpdateOp Declaration UnletStatement ReturnStatement CallStatement EvalStatement ThrowStatement EchoStatement ExecuteStatement IfStatement | ElseIfClause ElseClause ForStatement WhileStatement TryStatement CatchClause FinallyClause FunctionDefinition FunctionName ParamList Parameter FunctionAttribute DefDefinition ClassDefinition TypeDefinition ClassField BreakStatement ContinueStatement Command ExpressionStatement",
320
+ maxTerm: 188,
321
+ context: bracketDepth,
322
+ nodeProps: [
323
+ ["group", -21,46,116,117,118,119,120,121,122,123,124,128,129,130,133,138,139,141,142,143,144,145,"Statement",-19,51,53,54,55,59,62,65,67,80,81,82,83,84,89,104,106,108,109,111,"Expression"],
324
+ ["openedBy", 48,"[",57,"{ #{",68,"("],
325
+ ["closedBy", 49,"]",-2,58,61,"}",69,")"]
326
+ ],
327
+ skippedNodes: [0,1],
328
+ repeatNodeCount: 19,
329
+ tokenData: "3Z~R}XY$Opq$Oqr$Zst$vtu%Ruv&hvw&uwx%bxy(Wyz(]z{(b{|(j|}(r}!O(w!O!P)X!P!Q)t!Q!R)|!R![+q![!]-m!]!^-r!^!_-w!_!`.X!`!a.l!a!b.|!b!c/Z!c!}0_!}#O0s#P#Q0x#R#S0_#T#U0}#U#V1}#V#Z0_#Z#[1}#[#`0_#`#a1}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!c0Y!c!}0Y#T#o0Y~0_O!u~~0dT$v~st0_!Q![0_!c!}0_#R#S0_#T#o0_~0xO!R~~0}O!Q~~1SU$v~st0_!Q![0_![!]1f!c!}0_#R#S0_#T#o0_~1iS!Q![1u!c!}0_#R#S0_#T#o0_~1zP$v~!Q![1u~2SU$v~st0_!Q![0_![!]2f!c!}0_#R#S0_#T#o0_~2iR!c!}0_#R#S0_#T#o0_~2wO![~~2|P#q~#p#q3P~3UO#X~~3ZO!Z~",
330
+ tokenizers: [lineTokens, 0, 1, 2],
331
+ topRules: {"Program":[0,42]},
332
+ specialized: [{term: 176, get: (value, stack) => (keywords(value, stack) << 1), external: keywords}],
333
+ tokenPrec: 0
334
+ });
335
+
336
+ // Generated by scripts/builtins.mjs from Vim's help files. Don't edit it by hand.
337
+ /// Each built-in function, with its arguments.
338
+ const builtinFunctions = [
339
+ ["abs", "({expr})"],
340
+ ["acos", "({expr})"],
341
+ ["add", "({object}, {item})"],
342
+ ["and", "({expr}, {expr})"],
343
+ ["append", "({lnum}, {text})"],
344
+ ["appendbufline", "({buf}, {lnum}, {text})"],
345
+ ["argc", "([{winid}])"],
346
+ ["argidx", "()"],
347
+ ["arglistid", "([{winnr} [, {tabnr}]])"],
348
+ ["argv", "({nr} [, {winid}])"],
349
+ ["asin", "({expr})"],
350
+ ["assert_beeps", "({cmd})"],
351
+ ["assert_equal", "({exp}, {act} [, {msg}])"],
352
+ ["assert_equalfile", "({fname-one}, {fname-two} [, {msg}])"],
353
+ ["assert_exception", "({error} [, {msg}])"],
354
+ ["assert_fails", "({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])"],
355
+ ["assert_false", "({actual} [, {msg}])"],
356
+ ["assert_inrange", "({lower}, {upper}, {actual} [, {msg}])"],
357
+ ["assert_match", "({pat}, {text} [, {msg}])"],
358
+ ["assert_nobeep", "({cmd})"],
359
+ ["assert_notequal", "({exp}, {act} [, {msg}])"],
360
+ ["assert_notmatch", "({pat}, {text} [, {msg}])"],
361
+ ["assert_report", "({msg})"],
362
+ ["assert_true", "({actual} [, {msg}])"],
363
+ ["atan", "({expr})"],
364
+ ["atan2", "({expr1}, {expr2})"],
365
+ ["autocmd_add", "({acmds})"],
366
+ ["autocmd_delete", "({acmds})"],
367
+ ["autocmd_get", "([{opts}])"],
368
+ ["balloon_gettext", "()"],
369
+ ["balloon_show", "({expr})"],
370
+ ["balloon_split", "({msg})"],
371
+ ["base64_decode", "({string})"],
372
+ ["base64_encode", "({blob})"],
373
+ ["bindtextdomain", "({package}, {path})"],
374
+ ["blob2list", "({blob})"],
375
+ ["blob2str", "({blob} [, {options}])"],
376
+ ["browse", "({save}, {title}, {initdir}, {default})"],
377
+ ["browsedir", "({title}, {initdir})"],
378
+ ["bufadd", "({name})"],
379
+ ["bufexists", "({buf})"],
380
+ ["buflisted", "({buf})"],
381
+ ["bufload", "({buf})"],
382
+ ["bufloaded", "({buf})"],
383
+ ["bufname", "([{buf}])"],
384
+ ["bufnr", "([{buf} [, {create}]])"],
385
+ ["bufwinid", "({buf})"],
386
+ ["bufwinnr", "({buf})"],
387
+ ["byte2line", "({byte})"],
388
+ ["byteidx", "({expr}, {nr} [, {utf16}])"],
389
+ ["byteidxcomp", "({expr}, {nr} [, {utf16}])"],
390
+ ["call", "({func}, {arglist} [, {dict}])"],
391
+ ["ceil", "({expr})"],
392
+ ["ch_canread", "({handle})"],
393
+ ["ch_close", "({handle})"],
394
+ ["ch_close_in", "({handle})"],
395
+ ["ch_evalexpr", "({handle}, {expr} [, {options}])"],
396
+ ["ch_evalraw", "({handle}, {string} [, {options}])"],
397
+ ["ch_getbufnr", "({handle}, {what})"],
398
+ ["ch_getjob", "({channel})"],
399
+ ["ch_info", "({handle})"],
400
+ ["ch_listen", "({address} [, {options}])"],
401
+ ["ch_log", "({msg} [, {handle}])"],
402
+ ["ch_logfile", "({fname} [, {mode}])"],
403
+ ["ch_open", "({address} [, {options}])"],
404
+ ["ch_read", "({handle} [, {options}])"],
405
+ ["ch_readblob", "({handle} [, {options}])"],
406
+ ["ch_readraw", "({handle} [, {options}])"],
407
+ ["ch_sendexpr", "({handle}, {expr} [, {options}])"],
408
+ ["ch_sendraw", "({handle}, {expr} [, {options}])"],
409
+ ["ch_setoptions", "({handle}, {options})"],
410
+ ["ch_status", "({handle} [, {options}])"],
411
+ ["changenr", "()"],
412
+ ["char2nr", "({expr} [, {utf8}])"],
413
+ ["charclass", "({string})"],
414
+ ["charcol", "({expr} [, {winid}])"],
415
+ ["charidx", "({string}, {idx} [, {countcc} [, {utf16}]])"],
416
+ ["chdir", "({dir})"],
417
+ ["cindent", "({lnum})"],
418
+ ["clearmatches", "([{win}])"],
419
+ ["cmdcomplete_info", "()"],
420
+ ["col", "({expr} [, {winid}])"],
421
+ ["complete", "({startcol}, {matches})"],
422
+ ["complete_add", "({expr})"],
423
+ ["complete_check", "()"],
424
+ ["complete_info", "([{what}])"],
425
+ ["confirm", "({msg} [, {choices} [, {default} [, {type}]]])"],
426
+ ["copy", "({expr})"],
427
+ ["cos", "({expr})"],
428
+ ["cosh", "({expr})"],
429
+ ["count", "({comp}, {expr} [, {ic} [, {start}]])"],
430
+ ["cscope_connection", "([{num}, {dbpath} [, {prepend}]])"],
431
+ ["cursor", "({lnum}, {col} [, {off}])"],
432
+ ["debugbreak", "({pid})"],
433
+ ["deepcopy", "({expr} [, {noref}])"],
434
+ ["delete", "({fname} [, {flags}])"],
435
+ ["deletebufline", "({buf}, {first} [, {last}])"],
436
+ ["did_filetype", "()"],
437
+ ["diff", "({fromlist}, {tolist} [, {options}])"],
438
+ ["diff_filler", "({lnum})"],
439
+ ["digraph_get", "({chars})"],
440
+ ["digraph_getlist", "([{listall}])"],
441
+ ["digraph_set", "({chars}, {digraph})"],
442
+ ["digraph_setlist", "({digraphlist})"],
443
+ ["echoraw", "({expr})"],
444
+ ["empty", "({expr})"],
445
+ ["environ", "()"],
446
+ ["err_teapot", "([{expr}])"],
447
+ ["escape", "({string}, {chars})"],
448
+ ["eval", "({string})"],
449
+ ["eventhandler", "()"],
450
+ ["executable", "({expr})"],
451
+ ["execute", "({command})"],
452
+ ["exepath", "({expr})"],
453
+ ["exists", "({expr})"],
454
+ ["exists_compiled", "({expr})"],
455
+ ["exp", "({expr})"],
456
+ ["expand", "({expr} [, {nosuf} [, {list}]])"],
457
+ ["expandcmd", "({string} [, {options}])"],
458
+ ["extend", "({expr1}, {expr2} [, {expr3}])"],
459
+ ["extendnew", "({expr1}, {expr2} [, {expr3}])"],
460
+ ["feedkeys", "({string} [, {mode}])"],
461
+ ["filecopy", "({from}, {to})"],
462
+ ["filereadable", "({file})"],
463
+ ["filewritable", "({file})"],
464
+ ["filter", "({expr1}, {expr2})"],
465
+ ["finddir", "({name} [, {path} [, {count}]])"],
466
+ ["findfile", "({name} [, {path} [, {count}]])"],
467
+ ["flatten", "({list} [, {maxdepth}])"],
468
+ ["flattennew", "({list} [, {maxdepth}])"],
469
+ ["float2nr", "({expr})"],
470
+ ["floor", "({expr})"],
471
+ ["fmod", "({expr1}, {expr2})"],
472
+ ["fnameescape", "({fname})"],
473
+ ["fnamemodify", "({fname}, {mods})"],
474
+ ["foldclosed", "({lnum})"],
475
+ ["foldclosedend", "({lnum})"],
476
+ ["foldlevel", "({lnum})"],
477
+ ["foldtext", "()"],
478
+ ["foldtextresult", "({lnum})"],
479
+ ["foreach", "({expr1}, {expr2})"],
480
+ ["foreground", "()"],
481
+ ["fullcommand", "({name} [, {vim9}])"],
482
+ ["funcref", "({name} [, {arglist}] [, {dict}])"],
483
+ ["function", "({name} [, {arglist}] [, {dict}])"],
484
+ ["garbagecollect", "([{atexit}])"],
485
+ ["get", "({list}, {idx} [, {def}])"],
486
+ ["getbgcolor", "()"],
487
+ ["getbufinfo", "([{buf}])"],
488
+ ["getbufline", "({buf}, {lnum} [, {end}])"],
489
+ ["getbufoneline", "({buf}, {lnum})"],
490
+ ["getbufvar", "({buf}, {varname} [, {def}])"],
491
+ ["getcellpixels", "()"],
492
+ ["getcellwidths", "()"],
493
+ ["getchangelist", "([{buf}])"],
494
+ ["getchar", "([{expr} [, {opts}]])"],
495
+ ["getcharmod", "()"],
496
+ ["getcharpos", "({expr})"],
497
+ ["getcharsearch", "()"],
498
+ ["getcharstr", "([{expr} [, {opts}]])"],
499
+ ["getcmdcomplpat", "()"],
500
+ ["getcmdcompltype", "()"],
501
+ ["getcmdline", "()"],
502
+ ["getcmdpos", "()"],
503
+ ["getcmdprompt", "()"],
504
+ ["getcmdscreenpos", "()"],
505
+ ["getcmdtype", "()"],
506
+ ["getcmdwintype", "()"],
507
+ ["getcompletion", "({pat}, {type} [, {filtered}])"],
508
+ ["getcompletiontype", "({pat})"],
509
+ ["getcurpos", "([{winnr}])"],
510
+ ["getcursorcharpos", "([{winnr}])"],
511
+ ["getcwd", "([{winnr} [, {tabnr}]])"],
512
+ ["getenv", "({name})"],
513
+ ["getfontname", "([{name}])"],
514
+ ["getfperm", "({fname})"],
515
+ ["getfsize", "({fname})"],
516
+ ["getftime", "({fname})"],
517
+ ["getftype", "({fname})"],
518
+ ["getimstatus", "()"],
519
+ ["getjumplist", "([{winnr} [, {tabnr}]])"],
520
+ ["getline", "({lnum})"],
521
+ ["getloclist", "({nr})"],
522
+ ["getmarklist", "([{buf}])"],
523
+ ["getmatches", "([{win}])"],
524
+ ["getmousepos", "()"],
525
+ ["getmouseshape", "()"],
526
+ ["getpid", "()"],
527
+ ["getpos", "({expr})"],
528
+ ["getqflist", "()"],
529
+ ["getreg", "([{regname} [, 1 [, {list}]]])"],
530
+ ["getreginfo", "([{regname}])"],
531
+ ["getregion", "({pos1}, {pos2} [, {opts}])"],
532
+ ["getregionpos", "({pos1}, {pos2} [, {opts}])"],
533
+ ["getregtype", "([{regname}])"],
534
+ ["getscriptinfo", "([{opts}])"],
535
+ ["getstacktrace", "()"],
536
+ ["gettabinfo", "([{expr}])"],
537
+ ["gettabvar", "({nr}, {varname} [, {def}])"],
538
+ ["gettabwinvar", "({tabnr}, {winnr}, {name} [, {def}])"],
539
+ ["gettagstack", "([{nr}])"],
540
+ ["gettext", "({text} [, {package}])"],
541
+ ["getwininfo", "([{winid}])"],
542
+ ["getwinpos", "([{timeout}])"],
543
+ ["getwinposx", "()"],
544
+ ["getwinposy", "()"],
545
+ ["getwinvar", "({nr}, {varname} [, {def}])"],
546
+ ["glob", "({expr} [, {nosuf} [, {list} [, {alllinks}]]])"],
547
+ ["glob2regpat", "({expr})"],
548
+ ["globpath", "({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])"],
549
+ ["has", "({feature} [, {check}])"],
550
+ ["has_key", "({dict}, {key})"],
551
+ ["haslocaldir", "([{winnr} [, {tabnr}]])"],
552
+ ["hasmapto", "({what} [, {mode} [, {abbr}]])"],
553
+ ["histadd", "({history}, {item})"],
554
+ ["histdel", "({history} [, {item}])"],
555
+ ["histget", "({history} [, {index}])"],
556
+ ["histnr", "({history})"],
557
+ ["hlexists", "({name})"],
558
+ ["hlget", "([{name} [, {resolve}]])"],
559
+ ["hlset", "({list})"],
560
+ ["hostname", "()"],
561
+ ["iconv", "({expr}, {from}, {to})"],
562
+ ["id", "({item})"],
563
+ ["indent", "({lnum})"],
564
+ ["index", "({object}, {expr} [, {start} [, {ic}]])"],
565
+ ["indexof", "({object}, {expr} [, {opts}]])"],
566
+ ["input", "({prompt} [, {text} [, {completion}]])"],
567
+ ["inputdialog", "({prompt} [, {text} [, {cancelreturn}]])"],
568
+ ["inputlist", "({textlist})"],
569
+ ["inputrestore", "()"],
570
+ ["inputsave", "()"],
571
+ ["inputsecret", "({prompt} [, {text}])"],
572
+ ["insert", "({object}, {item} [, {idx}])"],
573
+ ["instanceof", "({object}, {class})"],
574
+ ["interrupt", "()"],
575
+ ["invert", "({expr})"],
576
+ ["isabsolutepath", "({path})"],
577
+ ["isdirectory", "({directory})"],
578
+ ["isinf", "({expr})"],
579
+ ["islocked", "({expr})"],
580
+ ["isnan", "({expr})"],
581
+ ["items", "({expr})"],
582
+ ["job_getchannel", "({job})"],
583
+ ["job_info", "([{job}])"],
584
+ ["job_setoptions", "({job}, {options})"],
585
+ ["job_start", "({command} [, {options}])"],
586
+ ["job_status", "({job})"],
587
+ ["job_stop", "({job} [, {how}])"],
588
+ ["join", "({expr} [, {sep}])"],
589
+ ["js_decode", "({string})"],
590
+ ["js_encode", "({expr})"],
591
+ ["json_decode", "({string})"],
592
+ ["json_encode", "({expr})"],
593
+ ["keys", "({dict})"],
594
+ ["keytrans", "({string})"],
595
+ ["len", "({expr})"],
596
+ ["libcall", "({lib}, {func}, {arg})"],
597
+ ["libcallnr", "({lib}, {func}, {arg})"],
598
+ ["line", "({expr} [, {winid}])"],
599
+ ["line2byte", "({lnum})"],
600
+ ["lispindent", "({lnum})"],
601
+ ["list2blob", "({list})"],
602
+ ["list2str", "({list} [, {utf8}])"],
603
+ ["list2tuple", "({list})"],
604
+ ["listener_add", "({callback} [, {buf} [, {unbuffered}]])"],
605
+ ["listener_flush", "([{buf}])"],
606
+ ["listener_remove", "({id})"],
607
+ ["localtime", "()"],
608
+ ["log", "({expr})"],
609
+ ["log10", "({expr})"],
610
+ ["luaeval", "({expr} [, {expr}])"],
611
+ ["map", "({expr1}, {expr2})"],
612
+ ["maparg", "({name} [, {mode} [, {abbr} [, {dict}]]])"],
613
+ ["mapcheck", "({name} [, {mode} [, {abbr}]])"],
614
+ ["maplist", "([{abbr}])"],
615
+ ["mapnew", "({expr1}, {expr2})"],
616
+ ["mapset", "({mode}, {abbr}, {dict})"],
617
+ ["match", "({expr}, {pat} [, {start} [, {count}]])"],
618
+ ["matchadd", "({group}, {pattern} [, {priority} [, {id} [, {dict}]]])"],
619
+ ["matchaddpos", "({group}, {pos} [, {priority} [, {id} [, {dict}]]])"],
620
+ ["matcharg", "({nr})"],
621
+ ["matchbufline", "({buf}, {pat}, {lnum}, {end}, [, {dict})"],
622
+ ["matchdelete", "({id} [, {win}])"],
623
+ ["matchend", "({expr}, {pat} [, {start} [, {count}]])"],
624
+ ["matchfuzzy", "({list}, {str} [, {dict}])"],
625
+ ["matchfuzzypos", "({list}, {str} [, {dict}])"],
626
+ ["matchlist", "({expr}, {pat} [, {start} [, {count}]])"],
627
+ ["matchstr", "({expr}, {pat} [, {start} [, {count}]])"],
628
+ ["matchstrlist", "({list}, {pat} [, {dict})"],
629
+ ["matchstrpos", "({expr}, {pat} [, {start} [, {count}]])"],
630
+ ["max", "({expr})"],
631
+ ["menu_info", "({name} [, {mode}])"],
632
+ ["min", "({expr})"],
633
+ ["mkdir", "({name} [, {flags} [, {prot}]])"],
634
+ ["mode", "([{expr}])"],
635
+ ["mzeval", "({expr})"],
636
+ ["nextnonblank", "({lnum})"],
637
+ ["ngettext", "({single}, {plural}, {number}[, {domain}])"],
638
+ ["nr2char", "({expr} [, {utf8}])"],
639
+ ["or", "({expr}, {expr})"],
640
+ ["pathshorten", "({expr} [, {len}])"],
641
+ ["perleval", "({expr})"],
642
+ ["popup_atcursor", "({what}, {options})"],
643
+ ["popup_beval", "({what}, {options})"],
644
+ ["popup_clear", "()"],
645
+ ["popup_close", "({id} [, {result}])"],
646
+ ["popup_create", "({what}, {options})"],
647
+ ["popup_dialog", "({what}, {options})"],
648
+ ["popup_filter_menu", "({id}, {key})"],
649
+ ["popup_filter_yesno", "({id}, {key})"],
650
+ ["popup_findecho", "()"],
651
+ ["popup_findinfo", "()"],
652
+ ["popup_findpreview", "()"],
653
+ ["popup_getoptions", "({id})"],
654
+ ["popup_getpos", "({id})"],
655
+ ["popup_hide", "({id})"],
656
+ ["popup_list", "()"],
657
+ ["popup_locate", "({row}, {col})"],
658
+ ["popup_menu", "({what}, {options})"],
659
+ ["popup_move", "({id}, {options})"],
660
+ ["popup_notification", "({what}, {options})"],
661
+ ["popup_setbuf", "({id}, {buf})"],
662
+ ["popup_setoptions", "({id}, {options})"],
663
+ ["popup_settext", "({id}, {text})"],
664
+ ["popup_show", "({id})"],
665
+ ["pow", "({x}, {y})"],
666
+ ["preinserted", "()"],
667
+ ["prevnonblank", "({lnum})"],
668
+ ["printf", "({fmt}, {expr1}...)"],
669
+ ["prompt_getprompt", "({buf})"],
670
+ ["prompt_setcallback", "({buf}, {expr})"],
671
+ ["prompt_setinterrupt", "({buf}, {text})"],
672
+ ["prompt_setprompt", "({buf}, {text})"],
673
+ ["prop_add", "({lnum}, {col}, {props})"],
674
+ ["prop_add_list", "({props}, [[{lnum}, {col}, {end-lnum}, {end-col}], ...])"],
675
+ ["prop_clear", "({lnum} [, {lnum-end} [, {props}]])"],
676
+ ["prop_find", "({props} [, {direction}])"],
677
+ ["prop_list", "({lnum} [, {props}])"],
678
+ ["prop_remove", "({props} [, {lnum} [, {lnum-end}]])"],
679
+ ["prop_type_add", "({name}, {props})"],
680
+ ["prop_type_change", "({name}, {props})"],
681
+ ["prop_type_delete", "({name} [, {props}])"],
682
+ ["prop_type_get", "({name} [, {props}])"],
683
+ ["prop_type_list", "([{props}])"],
684
+ ["pum_getpos", "()"],
685
+ ["pumvisible", "()"],
686
+ ["py3eval", "({expr} [, {locals}])"],
687
+ ["pyeval", "({expr} [, {locals}])"],
688
+ ["pyxeval", "({expr} [, {locals}])"],
689
+ ["rand", "([{expr}])"],
690
+ ["range", "({expr} [, {max} [, {stride}]])"],
691
+ ["readblob", "({fname} [, {offset} [, {size}]])"],
692
+ ["readdir", "({dir} [, {expr} [, {dict}]])"],
693
+ ["readdirex", "({dir} [, {expr} [, {dict}]])"],
694
+ ["readfile", "({fname} [, {type} [, {max}]])"],
695
+ ["redraw_listener_add", "({opts})"],
696
+ ["redraw_listener_remove", "({id})"],
697
+ ["reduce", "({object}, {func} [, {initial}])"],
698
+ ["reg_executing", "()"],
699
+ ["reg_recording", "()"],
700
+ ["reltime", "([{start} [, {end}]])"],
701
+ ["reltimefloat", "({time})"],
702
+ ["reltimestr", "({time})"],
703
+ ["remote_expr", "({server}, {string} [, {idvar} [, {timeout}]])"],
704
+ ["remote_foreground", "({server})"],
705
+ ["remote_peek", "({serverid} [, {retvar}])"],
706
+ ["remote_read", "({serverid} [, {timeout}])"],
707
+ ["remote_send", "({server}, {string} [, {idvar}])"],
708
+ ["remote_startserver", "({name})"],
709
+ ["remove", "({list}, {idx} [, {end}])"],
710
+ ["rename", "({from}, {to})"],
711
+ ["repeat", "({expr}, {count})"],
712
+ ["resolve", "({filename})"],
713
+ ["reverse", "({obj})"],
714
+ ["round", "({expr})"],
715
+ ["rubyeval", "({expr})"],
716
+ ["screenattr", "({row}, {col})"],
717
+ ["screenchar", "({row}, {col})"],
718
+ ["screenchars", "({row}, {col})"],
719
+ ["screencol", "()"],
720
+ ["screenpos", "({winid}, {lnum}, {col})"],
721
+ ["screenrow", "()"],
722
+ ["screenstring", "({row}, {col})"],
723
+ ["search", "({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])"],
724
+ ["searchcount", "([{options}])"],
725
+ ["searchdecl", "({name} [, {global} [, {thisblock}]])"],
726
+ ["searchpair", "({start}, {middle}, {end} [, {flags} [, {skip} [...]]])"],
727
+ ["searchpairpos", "({start}, {middle}, {end} [, {flags} [, {skip} [...]]])"],
728
+ ["searchpos", "({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])"],
729
+ ["server2client", "({clientid}, {string})"],
730
+ ["serverlist", "()"],
731
+ ["setbufline", "({buf}, {lnum}, {text})"],
732
+ ["setbufvar", "({buf}, {varname}, {val})"],
733
+ ["setcellwidths", "({list})"],
734
+ ["setcharpos", "({expr}, {list})"],
735
+ ["setcharsearch", "({dict})"],
736
+ ["setcmdline", "({str} [, {pos}])"],
737
+ ["setcmdpos", "({pos})"],
738
+ ["setcursorcharpos", "({list})"],
739
+ ["setenv", "({name}, {val})"],
740
+ ["setfperm", "({fname}, {mode})"],
741
+ ["setline", "({lnum}, {line})"],
742
+ ["setloclist", "({nr}, {list} [, {action}])"],
743
+ ["setmatches", "({list} [, {win}])"],
744
+ ["setpos", "({expr}, {list})"],
745
+ ["setqflist", "({list} [, {action}])"],
746
+ ["setreg", "({n}, {v} [, {opt}])"],
747
+ ["settabvar", "({nr}, {varname}, {val})"],
748
+ ["settabwinvar", "({tabnr}, {winnr}, {varname}, {val})"],
749
+ ["settagstack", "({nr}, {dict} [, {action}])"],
750
+ ["setwinvar", "({nr}, {varname}, {val})"],
751
+ ["sha256", "({expr})"],
752
+ ["shellescape", "({string} [, {special}])"],
753
+ ["shiftwidth", "([{col}])"],
754
+ ["sign_define", "({name} [, {dict}])"],
755
+ ["sign_getdefined", "([{name}])"],
756
+ ["sign_getplaced", "([{buf} [, {dict}]])"],
757
+ ["sign_jump", "({id}, {group}, {buf})"],
758
+ ["sign_place", "({id}, {group}, {name}, {buf} [, {dict}])"],
759
+ ["sign_placelist", "({list})"],
760
+ ["sign_undefine", "([{name}])"],
761
+ ["sign_unplace", "({group} [, {dict}])"],
762
+ ["sign_unplacelist", "({list})"],
763
+ ["simplify", "({filename})"],
764
+ ["sin", "({expr})"],
765
+ ["sinh", "({expr})"],
766
+ ["slice", "({expr}, {start} [, {end}])"],
767
+ ["sort", "({list} [, {how} [, {dict}]])"],
768
+ ["sound_clear", "()"],
769
+ ["sound_playevent", "({name} [, {callback}])"],
770
+ ["sound_playfile", "({path} [, {callback}])"],
771
+ ["sound_stop", "({id})"],
772
+ ["soundfold", "({word})"],
773
+ ["spellbadword", "()"],
774
+ ["spellsuggest", "({word} [, {max} [, {capital}]])"],
775
+ ["split", "({expr} [, {pat} [, {keepempty}]])"],
776
+ ["sqrt", "({expr})"],
777
+ ["srand", "([{expr}])"],
778
+ ["state", "([{what}])"],
779
+ ["str2blob", "({list} [, {options}])"],
780
+ ["str2float", "({expr} [, {quoted}])"],
781
+ ["str2list", "({expr} [, {utf8}])"],
782
+ ["str2nr", "({expr} [, {base} [, {quoted}]])"],
783
+ ["strcharlen", "({expr})"],
784
+ ["strcharpart", "({str}, {start} [, {len} [, {skipcc}]])"],
785
+ ["strchars", "({expr} [, {skipcc}])"],
786
+ ["strdisplaywidth", "({expr} [, {col}])"],
787
+ ["strftime", "({format} [, {time}])"],
788
+ ["strgetchar", "({str}, {index})"],
789
+ ["stridx", "({haystack}, {needle} [, {start}])"],
790
+ ["string", "({expr})"],
791
+ ["strlen", "({expr})"],
792
+ ["strpart", "({str}, {start} [, {len} [, {chars}]])"],
793
+ ["strptime", "({format}, {timestring})"],
794
+ ["strridx", "({haystack}, {needle} [, {start}])"],
795
+ ["strtrans", "({expr})"],
796
+ ["strutf16len", "({string} [, {countcc}])"],
797
+ ["strwidth", "({expr})"],
798
+ ["submatch", "({nr} [, {list}])"],
799
+ ["substitute", "({expr}, {pat}, {sub}, {flags})"],
800
+ ["swapfilelist", "()"],
801
+ ["swapinfo", "({fname})"],
802
+ ["swapname", "({buf})"],
803
+ ["synconcealed", "({lnum}, {col})"],
804
+ ["synstack", "({lnum}, {col})"],
805
+ ["system", "({expr} [, {input}])"],
806
+ ["systemlist", "({expr} [, {input}])"],
807
+ ["tabpagebuflist", "([{arg}])"],
808
+ ["tabpagenr", "([{arg}])"],
809
+ ["tabpagewinnr", "({tabarg} [, {arg}])"],
810
+ ["tabpanel_getinfo", "()"],
811
+ ["tabpanel_scroll", "({n} [, {opts}])"],
812
+ ["tagfiles", "()"],
813
+ ["taglist", "({expr} [, {filename}])"],
814
+ ["tan", "({expr})"],
815
+ ["tanh", "({expr})"],
816
+ ["tempname", "()"],
817
+ ["term_dumpdiff", "({filename}, {filename} [, {options}])"],
818
+ ["term_dumpload", "({filename} [, {options}])"],
819
+ ["term_dumpwrite", "({buf}, {filename} [, {options}])"],
820
+ ["term_getaltscreen", "({buf})"],
821
+ ["term_getansicolors", "({buf})"],
822
+ ["term_getattr", "({attr}, {what})"],
823
+ ["term_getcursor", "({buf})"],
824
+ ["term_getjob", "({buf})"],
825
+ ["term_getline", "({buf}, {row})"],
826
+ ["term_getscrolled", "({buf})"],
827
+ ["term_getsize", "({buf})"],
828
+ ["term_getstatus", "({buf})"],
829
+ ["term_gettitle", "({buf})"],
830
+ ["term_gettty", "({buf}, [{input}])"],
831
+ ["term_list", "()"],
832
+ ["term_scrape", "({buf}, {row})"],
833
+ ["term_sendkeys", "({buf}, {keys})"],
834
+ ["term_setansicolors", "({buf}, {colors})"],
835
+ ["term_setapi", "({buf}, {expr})"],
836
+ ["term_setkill", "({buf}, {how})"],
837
+ ["term_setrestore", "({buf}, {command})"],
838
+ ["term_setsize", "({buf}, {rows}, {cols})"],
839
+ ["term_start", "({cmd} [, {options}])"],
840
+ ["term_wait", "({buf} [, {time}])"],
841
+ ["terminalprops", "()"],
842
+ ["test_alloc_fail", "({id}, {countdown}, {repeat})"],
843
+ ["test_autochdir", "()"],
844
+ ["test_feedinput", "({string})"],
845
+ ["test_garbagecollect_now", "()"],
846
+ ["test_garbagecollect_soon", "()"],
847
+ ["test_getvalue", "({string})"],
848
+ ["test_gui_event", "({event}, {args})"],
849
+ ["test_ignore_error", "({expr})"],
850
+ ["test_mswin_event", "({event}, {args})"],
851
+ ["test_null_blob", "()"],
852
+ ["test_null_channel", "()"],
853
+ ["test_null_dict", "()"],
854
+ ["test_null_function", "()"],
855
+ ["test_null_job", "()"],
856
+ ["test_null_list", "()"],
857
+ ["test_null_partial", "()"],
858
+ ["test_null_string", "()"],
859
+ ["test_null_tuple", "()"],
860
+ ["test_option_not_set", "({name})"],
861
+ ["test_override", "({expr}, {val})"],
862
+ ["test_refcount", "({expr})"],
863
+ ["test_setmouse", "({row}, {col})"],
864
+ ["test_settime", "({expr})"],
865
+ ["test_srand_seed", "([{seed}])"],
866
+ ["test_unknown", "()"],
867
+ ["test_void", "()"],
868
+ ["timer_info", "([{id}])"],
869
+ ["timer_pause", "({id}, {pause})"],
870
+ ["timer_start", "({time}, {callback} [, {options}])"],
871
+ ["timer_stop", "({timer})"],
872
+ ["timer_stopall", "()"],
873
+ ["tolower", "({expr})"],
874
+ ["toupper", "({expr})"],
875
+ ["tr", "({src}, {fromstr}, {tostr})"],
876
+ ["trim", "({text} [, {mask} [, {dir}]])"],
877
+ ["trunc", "({expr})"],
878
+ ["tuple2list", "({tuple})"],
879
+ ["type", "({expr})"],
880
+ ["typename", "({expr})"],
881
+ ["undofile", "({name})"],
882
+ ["undotree", "([{buf}])"],
883
+ ["uniq", "({list} [, {func} [, {dict}]])"],
884
+ ["uri_decode", "({string})"],
885
+ ["uri_encode", "({string})"],
886
+ ["utf16idx", "({string}, {idx} [, {countcc} [, {charidx}]])"],
887
+ ["values", "({dict})"],
888
+ ["virtcol", "({expr} [, {list} [, {winid}])"],
889
+ ["virtcol2col", "({winid}, {lnum}, {col})"],
890
+ ["visualmode", "([{expr}])"],
891
+ ["wildmenumode", "()"],
892
+ ["wildtrigger", "()"],
893
+ ["win_execute", "({id}, {command} [, {silent}])"],
894
+ ["win_findbuf", "({bufnr})"],
895
+ ["win_getid", "([{win} [, {tab}]])"],
896
+ ["win_gettype", "([{nr}])"],
897
+ ["win_gotoid", "({expr})"],
898
+ ["win_id2tabwin", "({expr})"],
899
+ ["win_id2win", "({expr})"],
900
+ ["win_move_separator", "({nr})"],
901
+ ["win_move_statusline", "({nr})"],
902
+ ["win_screenpos", "({nr})"],
903
+ ["win_splitmove", "({nr}, {target} [, {options}])"],
904
+ ["winbufnr", "({nr})"],
905
+ ["wincol", "()"],
906
+ ["windowsversion", "()"],
907
+ ["winheight", "({nr})"],
908
+ ["winlayout", "([{tabnr}])"],
909
+ ["winline", "()"],
910
+ ["winnr", "([{expr}])"],
911
+ ["winrestcmd", "()"],
912
+ ["winrestview", "({dict})"],
913
+ ["winsaveview", "()"],
914
+ ["winwidth", "({nr})"],
915
+ ["wordcount", "()"],
916
+ ["writefile", "({object}, {fname} [, {flags}])"],
917
+ ["xor", "({expr}, {expr})"],
918
+ ];
919
+ /// The full name of each Ex command.
920
+ const exCommands = ["append", "abbreviate", "abclear", "aboveleft", "abstract", "all", "amenu", "anoremenu", "args", "argadd", "argdedupe", "argdelete", "argedit", "argdo", "argglobal", "arglocal", "argument", "ascii", "autocmd", "augroup", "aunmenu", "buffer", "ball", "badd", "balt", "bdelete", "behave", "belowright", "bfirst", "blast", "bmodified", "bnext", "botright", "bprevious", "brewind", "break", "breakadd", "breakdel", "breaklist", "browse", "bufdo", "buffers", "bunload", "bwipeout", "change", "cabbrev", "cabclear", "cabove", "caddbuffer", "caddexpr", "caddfile", "cafter", "call", "catch", "cbefore", "cbelow", "cbottom", "cbuffer", "cc", "cclose", "cd", "cdo", "cfdo", "center", "cexpr", "cfile", "cfirst", "cgetbuffer", "cgetexpr", "cgetfile", "changes", "chdir", "checkpath", "checktime", "chistory", "class", "clast", "clearjumps", "clipreset", "clist", "close", "cmap", "cmapclear", "cmenu", "cnext", "cnewer", "cnfile", "cnoremap", "cnoreabbrev", "cnoremenu", "copy", "colder", "colorscheme", "command", "comclear", "compiler", "continue", "confirm", "const", "copen", "cprevious", "cpfile", "cquit", "crewind", "cscope", "cstag", "cunmap", "cunabbrev", "cunmenu", "cwindow", "delete", "debug", "debuggreedy", "def", "defcompile", "defer", "delcommand", "delfunction", "delmarks", "diffupdate", "diffget", "diffoff", "diffpatch", "diffput", "diffsplit", "diffthis", "digraphs", "display", "disassemble", "djump", "dl", "dlist", "doautocmd", "doautoall", "drop", "dsearch", "dsplit", "edit", "earlier", "echo", "echoconsole", "echoerr", "echohl", "echomsg", "echon", "echowindow", "else", "elseif", "emenu", "endclass", "enddef", "endenum", "endif", "endinterface", "endfor", "endfunction", "endtry", "endwhile", "enew", "enum", "eval", "ex", "execute", "exit", "export", "exusage", "file", "files", "filetype", "filter", "find", "final", "finally", "finish", "first", "fixdel", "fold", "foldclose", "folddoopen", "folddoclosed", "foldopen", "for", "function", "global", "goto", "grep", "grepadd", "gui", "gvim", "hardcopy", "help", "helpclose", "helpfind", "helpgrep", "helptags", "highlight", "hide", "history", "horizontal", "insert", "iabbrev", "iabclear", "if", "ijump", "ilist", "imap", "imapclear", "imenu", "import", "inoremap", "inoreabbrev", "inoremenu", "intro", "interface", "iput", "isearch", "isplit", "iunmap", "iunabbrev", "iunmenu", "join", "jumps", "k", "keepalt", "keepmarks", "keepjumps", "keeppatterns", "list", "labove", "laddexpr", "laddbuffer", "laddfile", "lafter", "last", "language", "later", "lbefore", "lbelow", "lbottom", "lbuffer", "lcd", "lchdir", "lclose", "lcscope", "ldo", "lfdo", "left", "leftabove", "legacy", "let", "lexpr", "lfile", "lfirst", "lgetbuffer", "lgetexpr", "lgetfile", "lgrep", "lgrepadd", "lhelpgrep", "lhistory", "ll", "llast", "llist", "lmake", "lmap", "lmapclear", "lnext", "lnewer", "lnfile", "lnoremap", "loadkeymap", "loadview", "lockmarks", "lockvar", "lolder", "lopen", "lprevious", "lpfile", "lrewind", "ls", "ltag", "lunmap", "lua", "luado", "luafile", "lvimgrep", "lvimgrepadd", "lwindow", "move", "mark", "make", "map", "mapclear", "marks", "match", "menu", "menutranslate", "messages", "mkexrc", "mksession", "mkspell", "mkvimrc", "mkview", "mode", "mzscheme", "mzfile", "nbclose", "nbkey", "nbstart", "next", "new", "nmap", "nmapclear", "nmenu", "nnoremap", "nnoremenu", "noautocmd", "noremap", "nohlsearch", "noreabbrev", "noremenu", "normal", "noswapfile", "number", "nunmap", "nunmenu", "oldfiles", "open", "omap", "omapclear", "omenu", "only", "onoremap", "onoremenu", "options", "ounmap", "ounmenu", "ownsyntax", "packadd", "packloadall", "pbuffer", "pclose", "pedit", "perl", "print", "profdel", "profile", "promptfind", "promptrepl", "perldo", "pop", "popup", "ppop", "preserve", "previous", "psearch", "ptag", "ptfirst", "ptjump", "ptlast", "ptnext", "ptprevious", "ptrewind", "ptselect", "public", "put", "pwd", "py3", "python3", "py3do", "py3file", "python", "pydo", "pyfile", "pyx", "pythonx", "pyxdo", "pyxfile", "quit", "quitall", "qall", "read", "recover", "redo", "redir", "redraw", "redrawstatus", "redrawtabline", "redrawtabpanel", "registers", "resize", "retab", "return", "rewind", "right", "rightbelow", "ruby", "rubydo", "rubyfile", "rundo", "runtime", "rviminfo", "substitute", "sandbox", "sargument", "sall", "saveas", "sbuffer", "sball", "sbfirst", "sblast", "sbmodified", "sbnext", "sbprevious", "sbrewind", "scriptnames", "scriptencoding", "scriptversion", "scscope", "set", "setfiletype", "setglobal", "setlocal", "sfind", "sfirst", "shell", "simalt", "sign", "silent", "sleep", "slast", "smagic", "smap", "smapclear", "smenu", "smile", "snext", "snomagic", "snoremap", "snoremenu", "sort", "source", "spelldump", "spellgood", "spellinfo", "spellrare", "spellrepall", "spellundo", "spellwrong", "split", "sprevious", "srewind", "stop", "stag", "startinsert", "startgreplace", "startreplace", "static", "stopinsert", "stjump", "stselect", "sunhide", "sunmap", "sunmenu", "suspend", "sview", "swapname", "syntax", "syntime", "syncbind", "t", "tabclose", "tabdo", "tabedit", "tabfind", "tabfirst", "tablast", "tabmove", "tabnew", "tabnext", "tabonly", "tabprevious", "tabrewind", "tabs", "tab", "tag", "tags", "tcd", "tchdir", "tcl", "tcldo", "tclfile", "tearoff", "terminal", "tfirst", "throw", "this", "tjump", "tlast", "tlmenu", "tlnoremenu", "tlunmenu", "tmapclear", "tmap", "tmenu", "tnext", "tnoremap", "topleft", "tprevious", "trewind", "try", "tselect", "tunmap", "tunmenu", "type", "undo", "undojoin", "undolist", "unabbreviate", "unhide", "uniq", "unlet", "unlockvar", "unmap", "unmenu", "unsilent", "update", "vglobal", "var", "version", "verbose", "vertical", "vim9cmd", "vim9script", "vimgrep", "vimgrepadd", "visual", "viusage", "view", "vmap", "vmapclear", "vmenu", "vnew", "vnoremap", "vnoremenu", "vsplit", "vunmap", "vunmenu", "windo", "write", "wall", "while", "winsize", "wincmd", "winpos", "wlrestore", "wnext", "wprevious", "wq", "wqall", "wundo", "wviminfo", "xit", "xall", "xmapclear", "xmap", "xmenu", "xrestore", "xnoremap", "xnoremenu", "xunmap", "xunmenu", "yank", "z"];
921
+ /// The predefined v: variables.
922
+ const vimVariables = ["v:argv", "v:beval_col", "v:beval_bufnr", "v:beval_lnum", "v:beval_text", "v:beval_winnr", "v:beval_winid", "v:char", "v:charconvert_from", "v:charconvert_to", "v:clipmethod", "v:clipproviders", "v:cmdarg", "v:cmdbang", "v:collate", "v:colornames", "v:completed_item", "v:count", "v:ctype", "v:dying", "v:exiting", "v:echospace", "v:errmsg", "v:errors", "v:event", "v:exception", "v:false", "v:fcs_reason", "v:fcs_choice", "v:fname", "v:fname_in", "v:fname_out", "v:fname_new", "v:fname_diff", "v:folddashes", "v:foldlevel", "v:foldend", "v:foldstart", "v:hlsearch", "v:insertmode", "v:key", "v:lang", "v:lc_time", "v:lnum", "v:maxcol", "v:mouse_win", "v:mouse_winid", "v:mouse_lnum", "v:mouse_col", "v:none", "v:null", "v:numbermax", "v:numbermin", "v:numbersize", "v:oldfiles", "v:option_new", "v:option_old", "v:option_oldlocal", "v:option_oldglobal", "v:option_type", "v:option_command", "v:operator", "v:prevcount", "v:profiling", "v:progname", "v:progpath", "v:register", "v:scrollstart", "v:servername", "v:searchforward", "v:shell_error", "v:sizeofint", "v:sizeoflong", "v:sizeofpointer", "v:stacktrace", "v:statusmsg", "v:swapname", "v:swapchoice", "v:swapcommand", "v:t_bool", "v:t_channel", "v:t_dict", "v:t_float", "v:t_func", "v:t_job", "v:t_list", "v:t_none", "v:t_number", "v:t_string", "v:t_blob", "v:t_class", "v:t_object", "v:t_typealias", "v:t_enum", "v:t_enumvalue", "v:t_tuple", "v:termresponse", "v:termblinkresp", "v:termstyleresp", "v:termrbgresp", "v:termrfgresp", "v:termosc", "v:testing", "v:this_session", "v:throwpoint", "v:true", "v:val", "v:version", "v:versionlong", "v:vim_did_enter", "v:vim_did_init", "v:warningmsg", "v:wayland_display", "v:windowid"];
923
+
924
+ /// Snippets for the common blocks, offered where a command can start.
925
+ const snippets = [
926
+ autocomplete.snippetCompletion("function! ${Name}(${}) abort\n\t${}\nendfunction", {
927
+ label: "function",
928
+ detail: "definition",
929
+ type: "keyword",
930
+ }),
931
+ autocomplete.snippetCompletion("def ${Name}(${}): ${void}\n\t${}\nenddef", {
932
+ label: "def",
933
+ detail: "Vim9 definition",
934
+ type: "keyword",
935
+ }),
936
+ autocomplete.snippetCompletion("if ${condition}\n\t${}\nendif", { label: "if", detail: "block", type: "keyword" }),
937
+ autocomplete.snippetCompletion("if ${condition}\n\t${}\nelse\n\t${}\nendif", {
938
+ label: "if",
939
+ detail: "/ else block",
940
+ type: "keyword",
941
+ }),
942
+ autocomplete.snippetCompletion("elseif ${condition}\n\t${}", { label: "elseif", detail: "branch", type: "keyword" }),
943
+ autocomplete.snippetCompletion("for ${item} in ${list}\n\t${}\nendfor", { label: "for", detail: "loop", type: "keyword" }),
944
+ autocomplete.snippetCompletion("for [${key}, ${value}] in items(${dict})\n\t${}\nendfor", {
945
+ label: "for",
946
+ detail: "/ items loop",
947
+ type: "keyword",
948
+ }),
949
+ autocomplete.snippetCompletion("while ${condition}\n\t${}\nendwhile", { label: "while", detail: "loop", type: "keyword" }),
950
+ autocomplete.snippetCompletion("try\n\t${}\ncatch ${/pattern/}\n\t${}\nendtry", {
951
+ label: "try",
952
+ detail: "/ catch block",
953
+ type: "keyword",
954
+ }),
955
+ autocomplete.snippetCompletion("let ${name} = ${value}", { label: "let", detail: "assignment", type: "keyword" }),
956
+ ];
957
+ /// A snippet for a lambda, offered inside expressions.
958
+ const expressionSnippets = [
959
+ autocomplete.snippetCompletion("{${args} -> ${expression}}", { label: "lambda", detail: "{args -> expr}", type: "keyword" }),
960
+ ];
961
+ const commandOptions = exCommands.map((label) => ({
962
+ label,
963
+ type: "keyword",
964
+ }));
965
+ const functionOptions = builtinFunctions.map(([label, detail]) => ({
966
+ label,
967
+ detail,
968
+ type: "function",
969
+ }));
970
+ const scopePrefixes = [
971
+ ["g:", "global variable"],
972
+ ["s:", "script-local variable"],
973
+ ["l:", "function-local variable"],
974
+ ["a:", "function argument"],
975
+ ["v:", "Vim variable"],
976
+ ["b:", "buffer-local variable"],
977
+ ["w:", "window-local variable"],
978
+ ["t:", "tab-local variable"],
979
+ ].map(([label, detail]) => ({ label, detail, type: "namespace", boost: -1 }));
980
+ const expressionWords = [
981
+ ...["is", "isnot"].map((label) => ({ label, type: "keyword" })),
982
+ ...["true", "false", "null"].map((label) => ({ label, type: "constant", detail: "Vim9" })),
983
+ ...vimVariables.map((label) => ({ label, type: "variable" })),
984
+ ];
985
+ const attributeWords = ["abort", "range", "dict", "closure"].map((label) => ({ label, type: "keyword" }));
986
+ const dontComplete = new Set([
987
+ "String",
988
+ "Comment",
989
+ "RawArgs",
990
+ "VariableDefinition",
991
+ "TypeDefinition",
992
+ "FunctionName",
993
+ ]);
994
+ const word = /(?:[gslabwtv]:)?[\w#]*$/;
995
+ const wordFor = /^(?:[gslabwtv]:)?[\w#]*$/;
996
+ // The text before the word on its line, joined to the lines it carries on
997
+ // from, so `\` continuation lines count as one command.
998
+ function lineBefore(context, from) {
999
+ const doc = context.state.doc;
1000
+ let line = doc.lineAt(from);
1001
+ let text = doc.sliceString(line.from, from);
1002
+ while (/^\s*\\/.test(text) && line.number > 1) {
1003
+ line = doc.line(line.number - 1);
1004
+ text = line.text + " " + text.replace(/^\s*\\/, "");
1005
+ }
1006
+ return text;
1007
+ }
1008
+ function atCommandStart(before) {
1009
+ return /(?:^|\|)\s*:*\s*(?:(?:sil(?:ent)?|keepjumps|noautocmd|verbose|vim9cmd|legacy)!?\s+)*$/.test(before);
1010
+ }
1011
+ function inFunctionHeader(before) {
1012
+ return /^\s*:?\s*(?:fu\w*|def)!?\s+\S+\s*\(.*\)\s*(?:\w+\s+)*$/.test(before);
1013
+ }
1014
+ function inSkippedNode(context) {
1015
+ const inner = language.syntaxTree(context.state).resolveInner(context.pos, -1);
1016
+ for (let node = inner; node; node = node.parent)
1017
+ if (dontComplete.has(node.name))
1018
+ return true;
1019
+ return false;
1020
+ }
1021
+ function isVim9(doc) {
1022
+ return /^\s*vim9s/.test(doc.sliceString(0, Math.min(doc.length, 200)));
1023
+ }
1024
+ /// Offers Ex commands and snippets where a command can start, and built-in
1025
+ /// functions, `v:` variables and scope prefixes inside expressions.
1026
+ const globalCompletion = (context) => {
1027
+ if (inSkippedNode(context))
1028
+ return null;
1029
+ const match = context.matchBefore(word);
1030
+ if (!match || (match.from == match.to && !context.explicit))
1031
+ return null;
1032
+ const before = lineBefore(context, match.from);
1033
+ if (/[\w)\]}]\.$/.test(before))
1034
+ return null;
1035
+ let options;
1036
+ if (atCommandStart(before))
1037
+ options = [...snippets, ...commandOptions];
1038
+ else if (inFunctionHeader(before))
1039
+ options = attributeWords;
1040
+ else
1041
+ options = [...functionOptions, ...expressionWords, ...expressionSnippets, ...scopePrefixes];
1042
+ return { from: match.from, options, validFor: wordFor };
1043
+ };
1044
+ // The names in a file are worked out once per tree.
1045
+ const cache = new WeakMap();
1046
+ const functionNodes = new Set(["FunctionDefinition", "DefDefinition"]);
1047
+ const bindingNodes = new Set(["LetStatement", "Declaration", "ForStatement"]);
1048
+ function add(list, seen, label, type) {
1049
+ if (!seen.has(label)) {
1050
+ seen.add(label);
1051
+ list.push({ label, type });
1052
+ }
1053
+ }
1054
+ // The variables bound by a `let`, a declaration or a `for` loop.
1055
+ function boundNames(node, doc) {
1056
+ var _a;
1057
+ const target = (_a = node.getChild("VariableDefinition")) !== null && _a !== void 0 ? _a : node.getChild("ListPattern");
1058
+ if (!target)
1059
+ return [];
1060
+ const defs = target.name == "VariableDefinition" ? [target] : target.getChildren("VariableDefinition");
1061
+ return defs.map((def) => doc.sliceString(def.from, def.to));
1062
+ }
1063
+ function hasAttribute(node, doc, name) {
1064
+ return node.getChildren("FunctionAttribute").some((a) => doc.sliceString(a.from, a.to) == name);
1065
+ }
1066
+ // The arguments and locals of one function. A legacy function reads its
1067
+ // arguments as `a:name`, and a Vim9 `def` reads them by their bare names.
1068
+ function gatherFunction(node, doc, vim9) {
1069
+ const names = [];
1070
+ const seen = new Set();
1071
+ const legacy = node.name == "FunctionDefinition" && !vim9;
1072
+ const params = node.getChild("ParamList");
1073
+ if (params) {
1074
+ for (const param of params.getChildren("Parameter")) {
1075
+ const def = param.getChild("VariableDefinition");
1076
+ if (def)
1077
+ add(names, seen, (legacy ? "a:" : "") + doc.sliceString(def.from, def.to), "variable");
1078
+ }
1079
+ const spread = params.getChild("Spread");
1080
+ if (spread) {
1081
+ const def = spread.getChild("VariableDefinition");
1082
+ if (def)
1083
+ add(names, seen, doc.sliceString(def.from, def.to), "variable");
1084
+ if (legacy) {
1085
+ add(names, seen, "a:0", "variable");
1086
+ add(names, seen, "a:000", "variable");
1087
+ }
1088
+ }
1089
+ }
1090
+ if (legacy && hasAttribute(node, doc, "dict"))
1091
+ add(names, seen, "self", "variable");
1092
+ if (legacy && hasAttribute(node, doc, "range")) {
1093
+ add(names, seen, "a:firstline", "variable");
1094
+ add(names, seen, "a:lastline", "variable");
1095
+ }
1096
+ // Names with a `g:` or `s:` prefix belong to the whole file, so they are
1097
+ // gathered there instead.
1098
+ node.cursor().iterate((n) => {
1099
+ if (n.from == node.from && n.name == node.name)
1100
+ return;
1101
+ if (functionNodes.has(n.name))
1102
+ return false;
1103
+ if (!bindingNodes.has(n.name))
1104
+ return;
1105
+ for (const name of boundNames(n.node, doc)) {
1106
+ if (/^[gsbwtv]:/.test(name))
1107
+ continue;
1108
+ const bare = name.startsWith("l:") ? name.slice(2) : name;
1109
+ add(names, seen, bare, "variable");
1110
+ if (legacy)
1111
+ add(names, seen, "l:" + bare, "variable");
1112
+ }
1113
+ });
1114
+ return names;
1115
+ }
1116
+ function gatherFile(tree, doc) {
1117
+ const cached = cache.get(tree);
1118
+ if (cached)
1119
+ return cached;
1120
+ const everywhere = [];
1121
+ const topLevel = [];
1122
+ const functions = [];
1123
+ const properties = [];
1124
+ const seenEverywhere = new Set();
1125
+ const seenTop = new Set();
1126
+ const seenProperty = new Set();
1127
+ const vim9 = isVim9(doc);
1128
+ const text = (n) => doc.sliceString(n.from, n.to);
1129
+ tree.iterate({
1130
+ enter: (ref) => {
1131
+ const node = ref.node;
1132
+ if (functionNodes.has(ref.name)) {
1133
+ const name = node.getChild("FunctionName");
1134
+ if (name && !name.getChild("PropertyName"))
1135
+ add(everywhere, seenEverywhere, text(name), "function");
1136
+ functions.push({ from: node.from, to: node.to, names: gatherFunction(node, doc, vim9) });
1137
+ }
1138
+ else if (bindingNodes.has(ref.name)) {
1139
+ let inFunction = false;
1140
+ for (let p = node.parent; p; p = p.parent)
1141
+ if (functionNodes.has(p.name))
1142
+ inFunction = true;
1143
+ for (const name of boundNames(node, doc)) {
1144
+ if (/^[gs]:/.test(name))
1145
+ add(everywhere, seenEverywhere, name, "variable");
1146
+ else if (!inFunction)
1147
+ add(topLevel, seenTop, name, "variable");
1148
+ }
1149
+ }
1150
+ else if (ref.name == "ClassDefinition") {
1151
+ const name = node.getChild("TypeDefinition");
1152
+ if (name)
1153
+ add(everywhere, seenEverywhere, text(name), "class");
1154
+ }
1155
+ else if (ref.name == "PropertyName") {
1156
+ add(properties, seenProperty, text(node), "property");
1157
+ }
1158
+ else if (ref.name == "DictionaryEntry") {
1159
+ const key = node.firstChild;
1160
+ if (key && key.name == "String") {
1161
+ const inner = text(key).slice(1, -1);
1162
+ if (/^[A-Za-z_]\w*$/.test(inner))
1163
+ add(properties, seenProperty, inner, "property");
1164
+ }
1165
+ }
1166
+ },
1167
+ });
1168
+ for (const scope of functions) {
1169
+ const seen = new Set(scope.names.map((c) => c.label));
1170
+ // A Vim9 function reads the script's variables by name. In a legacy
1171
+ // function, a variable set at the top of the script without a prefix is
1172
+ // a global, and needs `g:` to be read.
1173
+ for (const c of topLevel)
1174
+ add(scope.names, seen, (vim9 ? "" : "g:") + c.label, "variable");
1175
+ }
1176
+ const result = { everywhere, topLevel, functions, properties };
1177
+ cache.set(tree, result);
1178
+ return result;
1179
+ }
1180
+ // The parameters of each lambda around `pos`.
1181
+ function lambdaParams(tree, pos, doc) {
1182
+ const names = [];
1183
+ for (let node = tree.resolveInner(pos, -1); node; node = node.parent) {
1184
+ let defs = [];
1185
+ if (node.name == "Lambda")
1186
+ defs = node.getChildren("VariableDefinition");
1187
+ else if (node.name == "ArrowFunction") {
1188
+ const params = node.getChild("ParamList");
1189
+ if (params)
1190
+ for (const param of params.getChildren("Parameter")) {
1191
+ const def = param.getChild("VariableDefinition");
1192
+ if (def)
1193
+ defs.push(def);
1194
+ }
1195
+ }
1196
+ for (const def of defs)
1197
+ names.push({ label: doc.sliceString(def.from, def.to), type: "variable" });
1198
+ }
1199
+ return names;
1200
+ }
1201
+ /// Offers the names declared in the file that are in scope at the cursor:
1202
+ /// functions, variables set with `let`, function arguments as `a:name`, and
1203
+ /// lambda parameters. After a `.` it offers the dictionary keys used in the
1204
+ /// file.
1205
+ const localCompletionSource = (context) => {
1206
+ if (inSkippedNode(context))
1207
+ return null;
1208
+ const doc = context.state.doc;
1209
+ const tree = language.syntaxTree(context.state);
1210
+ const names = gatherFile(tree, doc);
1211
+ const member = context.matchBefore(/[\w)\]}]\.\w*$/);
1212
+ if (member) {
1213
+ const from = member.from + member.text.indexOf(".") + 1;
1214
+ return { from, options: names.properties, validFor: /^\w*$/ };
1215
+ }
1216
+ const match = context.matchBefore(word);
1217
+ if (!match || (match.from == match.to && !context.explicit))
1218
+ return null;
1219
+ const pos = context.pos;
1220
+ // Functions don't nest, so the scope is the function the cursor is in.
1221
+ const scope = names.functions.find((f) => f.from < pos && pos <= f.to);
1222
+ const options = [...names.everywhere, ...lambdaParams(tree, pos, doc)];
1223
+ options.push(...(scope ? scope.names : names.topLevel));
1224
+ return { from: match.from, options, validFor: wordFor };
1225
+ };
1226
+
1227
+ // A block's body is indented one unit. Its closing word, and the words that
1228
+ // start a new part of it (`else`, `catch` and so on), line up with the opening
1229
+ // word.
1230
+ const blockPart = /^\s*(?:end\w*|en|el(?:s|se|sei|seif?)?|cat(?:c|ch)?|fina(?:l|ll|lly)?)\b/;
1231
+ function blockIndent(cx) {
1232
+ if (blockPart.test(cx.textAfter))
1233
+ return cx.baseIndent;
1234
+ return cx.baseIndent + cx.unit;
1235
+ }
1236
+ // A block folds from the end of its first line to the start of its last line,
1237
+ // so the closing word stays in view.
1238
+ function foldBlock(node, state) {
1239
+ const last = node.lastChild;
1240
+ if (!last || last.type.isError)
1241
+ return null;
1242
+ const from = state.doc.lineAt(node.from).to;
1243
+ const to = state.doc.lineAt(last.from).from - 1;
1244
+ return to > from ? { from, to } : null;
1245
+ }
1246
+ function foldInside(node) {
1247
+ const first = node.firstChild;
1248
+ const last = node.lastChild;
1249
+ return first && last && first.to < last.from ? { from: first.to, to: last.from } : null;
1250
+ }
1251
+ const blocks = "IfStatement ForStatement WhileStatement TryStatement FunctionDefinition DefDefinition ClassDefinition";
1252
+ const vimscriptLanguage = language.LRLanguage.define({
1253
+ name: "vimscript",
1254
+ parser: parser.configure({
1255
+ props: [
1256
+ highlight.styleTags({
1257
+ "let const var final unlet return call eval throw echo execute break continue": highlight.tags.keyword,
1258
+ "if elseif else endif for in endfor while endwhile try catch finally endtry": highlight.tags.controlKeyword,
1259
+ "function endfunction def enddef class endclass": highlight.tags.definitionKeyword,
1260
+ "range abort dict closure": highlight.tags.modifier,
1261
+ "is isnot": highlight.tags.operatorKeyword,
1262
+ "CommandName CommandModifier": highlight.tags.keyword,
1263
+ RawArgs: highlight.tags.special(highlight.tags.string),
1264
+ Comment: highlight.tags.lineComment,
1265
+ String: highlight.tags.string,
1266
+ Number: highlight.tags.number,
1267
+ "VariableName Option EnvironmentVariable Register": highlight.tags.variableName,
1268
+ VariableDefinition: highlight.tags.definition(highlight.tags.variableName),
1269
+ FunctionName: highlight.tags.function(highlight.tags.definition(highlight.tags.variableName)),
1270
+ "CallExpression/VariableName": highlight.tags.function(highlight.tags.variableName),
1271
+ MethodName: highlight.tags.function(highlight.tags.propertyName),
1272
+ PropertyName: highlight.tags.propertyName,
1273
+ "TypeName TypeDefinition": highlight.tags.typeName,
1274
+ "ArithOp ConcatOp": highlight.tags.arithmeticOperator,
1275
+ LogicOp: highlight.tags.logicOperator,
1276
+ CompareOp: highlight.tags.compareOperator,
1277
+ "AssignOp UpdateOp": highlight.tags.definitionOperator,
1278
+ '"->" "=>"': highlight.tags.punctuation,
1279
+ "( )": highlight.tags.paren,
1280
+ "[ ]": highlight.tags.squareBracket,
1281
+ "{ } #{": highlight.tags.brace,
1282
+ ", ;": highlight.tags.separator,
1283
+ }),
1284
+ language.indentNodeProp.add({
1285
+ [blocks]: blockIndent,
1286
+ }),
1287
+ language.foldNodeProp.add({
1288
+ [blocks]: foldBlock,
1289
+ "List Dictionary LiteralDictionary ArgList ParamList": foldInside,
1290
+ }),
1291
+ ],
1292
+ }),
1293
+ languageData: {
1294
+ commentTokens: { line: '"' },
1295
+ indentOnInput: /^\s*(?:end\w*|else|elseif|catch|finally)$/,
1296
+ closeBrackets: { brackets: ["(", "[", "{", "'"] },
1297
+ },
1298
+ });
1299
+ function vimscript() {
1300
+ return new language.LanguageSupport(vimscriptLanguage, [
1301
+ vimscriptLanguage.data.of({ autocomplete: localCompletionSource }),
1302
+ vimscriptLanguage.data.of({ autocomplete: globalCompletion }),
1303
+ ]);
1304
+ }
1305
+
1306
+ exports.globalCompletion = globalCompletion;
1307
+ exports.localCompletionSource = localCompletionSource;
1308
+ exports.snippets = snippets;
1309
+ exports.vimscript = vimscript;
1310
+ exports.vimscriptLanguage = vimscriptLanguage;