@exercism/codemirror-lang-vimscript 0.0.0-stage → 1.0.1

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