vimlrs 0.1.3

Faithful Rust port of the Vimscript (VimL) interpreter, from the Neovim C eval engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
//! GENERATED doc corpus for the LSP hover provider and the `gen-docs` binary.
//! Regenerate by re-running the authoring pipeline; do not hand-edit casually.
//!
//! Single source of truth: every implemented Vim builtin (each `f_<name>` in the
//! ported evaluator) paired with an accurate one-line description and a signature
//! derived from Neovim's `funcs[]` arg-count metadata. Editor-integration builtins
//! that are no-ops in this standalone (non-editor) interpreter are flagged
//! `(stub in standalone)` so the LSP stays honest.
//!
//! `(name, signature, doc)`, sorted by name.

/// Documented builtins: `(name, signature, one-line doc)`, sorted by name.
pub const BUILTIN_DOCS: &[(&str, &str, &str)] = &[
    ("abs", "abs({expr})", "Absolute value of {expr} (Float in -> Float out)."),
    ("add", "add({object}, {expr})", "Append {expr} to List or Blob {object}; returns {object}."),
    ("and", "and({expr1}, {expr2})", "Bitwise AND of {expr1} and {expr2}."),
    ("api_info", "api_info()", "Dict describing the Nvim API (version, functions, types)."),
    ("append", "append({lnum}, {text})", "Append {text} (String or List) below line {lnum}; 0 on success."),
    ("appendbufline", "appendbufline({buf}, {lnum}, {text})", "Append {text} below line {lnum} of buffer {buf}."),
    ("argc", "argc([{winid}])", "Number of files in the argument list."),
    ("argidx", "argidx()", "Current index into the argument list."),
    ("arglistid", "arglistid([{winnr} [, {tabnr}]])", "Identifier of the argument list used by a window."),
    ("argv", "argv([{nr} [, {winid}]])", "Argument-list entry {nr} (or the whole List)."),
    ("assert_equal", "assert_equal({expected}, {actual} [, {msg}])", "Add an error to v:errors unless {expected} == {actual}."),
    ("assert_equalfile", "assert_equalfile({fname1}, {fname2} [, {msg}])", "Add an error to v:errors unless the two files have equal contents."),
    ("assert_exception", "assert_exception({error} [, {msg}])", "Add an error to v:errors unless v:exception contains {error}."),
    ("assert_false", "assert_false({actual} [, {msg}])", "Add an error to v:errors unless {actual} is false."),
    ("assert_inrange", "assert_inrange({lower}, {upper}, {actual} [, {msg}])", "Add an error to v:errors unless {lower} <= {actual} <= {upper}."),
    ("assert_match", "assert_match({pat}, {actual} [, {msg}])", "Add an error to v:errors unless {pat} matches {actual}."),
    ("assert_notequal", "assert_notequal({expected}, {actual} [, {msg}])", "Add an error to v:errors unless {expected} != {actual}."),
    ("assert_notmatch", "assert_notmatch({pat}, {actual} [, {msg}])", "Add an error to v:errors unless {pat} does not match {actual}."),
    ("assert_report", "assert_report({msg})", "Add {msg} to v:errors unconditionally."),
    ("assert_true", "assert_true({actual} [, {msg}])", "Add an error to v:errors unless {actual} is true."),
    ("atan2", "atan2({expr1}, {expr2})", "Arc tangent of {expr1}/{expr2} in radians (-pi..pi)."),
    ("blob2list", "blob2list({blob})", "List of byte-value Numbers for each byte of {blob}."),
    ("browse", "browse({save}, {title}, {initdir}, {default})", "Prompt for a file name via a dialog (GUI)."),
    ("browsedir", "browsedir({title}, {initdir})", "Prompt for a directory via a dialog (GUI)."),
    ("bufadd", "bufadd({name})", "Add a buffer for file {name} (without loading) and return its number (stub in standalone)."),
    ("bufexists", "bufexists({buf})", "1 if buffer {buf} exists, else 0 (stub in standalone)."),
    ("buflisted", "buflisted({buf})", "1 if buffer {buf} exists and is listed, else 0 (stub in standalone)."),
    ("bufload", "bufload({buf})", "Ensure buffer {buf} is loaded (reading the file if needed) (stub in standalone)."),
    ("bufloaded", "bufloaded({buf})", "1 if buffer {buf} exists and is loaded, else 0 (stub in standalone)."),
    ("bufname", "bufname([{buf}])", "Name of buffer {buf} (default current) (stub in standalone)."),
    ("bufnr", "bufnr([{buf} [, {create}]])", "Buffer number of {buf}; optionally create it (stub in standalone)."),
    ("bufwinid", "bufwinid({buf})", "window-ID of the first window showing buffer {buf}, else -1 (stub in standalone)."),
    ("bufwinnr", "bufwinnr({buf})", "Window number of the first window showing buffer {buf}, else -1 (stub in standalone)."),
    ("byte2line", "byte2line({byte})", "Line number containing byte offset {byte}, else -1."),
    ("byteidx", "byteidx({string}, {nr} [, {utf16}])", "Byte index of the {nr}'th character in {string}."),
    ("byteidxcomp", "byteidxcomp({string}, {nr} [, {utf16}])", "Like byteidx() but counting composing characters separately."),
    ("call", "call({func}, {arglist} [, {dict}])", "Call {func} with the List {arglist} as its arguments (stub in standalone)."),
    ("chanclose", "chanclose({id} [, {stream}])", "Close channel {id} (or one of its streams) (stub in standalone)."),
    ("changenr", "changenr()", "Sequence number of the current entry in the buffer's change list (stub in standalone)."),
    ("chansend", "chansend({id}, {data})", "Send {data} to channel {id}; returns bytes written (stub in standalone)."),
    ("char2nr", "char2nr({string} [, {utf8}])", "Codepoint of the first character of {string}."),
    ("charclass", "charclass({string})", "Character class (0 white, 1 punctuation, 2 word, ...) of the first char of {string}."),
    ("charcol", "charcol({expr} [, {winid}])", "Character column for position {expr}."),
    ("charidx", "charidx({string}, {idx} [, {countcc} [, {utf16}]])", "Character index of byte {idx} in {string}."),
    ("chdir", "chdir({dir})", "Change the working directory to {dir}; returns the previous directory."),
    ("cindent", "cindent({lnum})", "C-indent amount Vim would use for line {lnum}."),
    ("clearmatches", "clearmatches([{win}])", "Clear all matches added with matchadd()/matchaddpos()."),
    ("cmdcomplete_info", "cmdcomplete_info([{what}])", "Dict of information about the current command-line completion."),
    ("col", "col({expr} [, {winid}])", "Byte column for position {expr}."),
    ("complete", "complete({startcol}, {matches})", "Set the Insert-mode completion list to {matches} starting at {startcol} (stub in standalone)."),
    ("complete_add", "complete_add({expr})", "Add {expr} to the completion list during a 'completefunc'."),
    ("complete_check", "complete_check()", "1 if completion was aborted by typed input."),
    ("complete_info", "complete_info([{what}])", "Dict of information about the current Insert-mode completion."),
    ("confirm", "confirm({msg} [, {choices} [, {default} [, {type}]]])", "Show dialog {msg} with {choices}; return the chosen button number."),
    ("copy", "copy({expr})", "Shallow copy of {expr}."),
    ("count", "count({comp}, {expr} [, {ic} [, {start}]])", "Number of times {expr} occurs in String/List/Dict {comp}."),
    ("ctxget", "ctxget([{index}])", "Dict for the {index}'th entry on the context stack."),
    ("ctxpop", "ctxpop()", "Pop and restore the top editor context from the stack (stub in standalone)."),
    ("ctxpush", "ctxpush([{types}])", "Push the editor context (of {types}) onto the context stack (stub in standalone)."),
    ("ctxset", "ctxset({context} [, {index}])", "Set the {index}'th context-stack entry from {context} (stub in standalone)."),
    ("ctxsize", "ctxsize()", "Number of entries on the context stack (stub in standalone)."),
    ("cursor", "cursor({lnum}, {col} [, {off}])", "Move the cursor to line {lnum}, column {col}."),
    ("debugbreak", "debugbreak({pid})", "Interrupt process {pid} (MS-Windows debugging helper) (stub in standalone)."),
    ("deepcopy", "deepcopy({expr} [, {noref}])", "Recursive (deep) copy of {expr}."),
    ("delete", "delete({fname} [, {flags}])", "Delete file (or, with 'd'/'rf', directory) {fname}; 0 on success."),
    ("deletebufline", "deletebufline({buf}, {first} [, {last}])", "Delete lines {first}..{last} from buffer {buf}."),
    ("dictwatcheradd", "dictwatcheradd({dict}, {pattern}, {callback})", "Register {callback} to fire when keys matching {pattern} in {dict} change."),
    ("dictwatcherdel", "dictwatcherdel({dict}, {pattern}, {callback})", "Remove a watcher previously added with dictwatcheradd()."),
    ("did_filetype", "did_filetype()", "1 if a FileType autocommand has run for the current buffer (stub in standalone)."),
    ("diff_filler", "diff_filler({lnum})", "Number of filler lines above diff line {lnum}."),
    ("diff_hlID", "diff_hlID({lnum}, {col})", "Diff highlight ID at line {lnum}, column {col}."),
    ("digraph_get", "digraph_get({chars})", "The digraph character defined for the two-character {chars}."),
    ("digraph_getlist", "digraph_getlist([{listall}])", "List of [chars, digraph] pairs for the defined digraphs."),
    ("digraph_set", "digraph_set({chars}, {digraph})", "Define {chars} as a digraph producing {digraph}; returns v:true."),
    ("digraph_setlist", "digraph_setlist({list})", "Define multiple digraphs from a List of [chars, digraph] pairs."),
    ("empty", "empty({expr})", "1 if {expr} is empty (0, '', [], {}, v:null), else 0."),
    ("environ", "environ()", "Dict of all environment variables and their values."),
    ("escape", "escape({string}, {chars})", "{string} with each character in {chars} prefixed by a backslash."),
    ("eval", "eval({string})", "Evaluate {string} as a Vim expression (inverse of string()) (stub in standalone)."),
    ("eventhandler", "eventhandler()", "1 if Vim is inside an event handler (e.g. processing a callback) (stub in standalone)."),
    ("executable", "executable({expr})", "1 if {expr} is an executable found in $PATH, else 0."),
    ("execute", "execute({command} [, {silent}])", "Execute Ex {command}(s) and return their captured output (stub in standalone)."),
    ("exepath", "exepath({expr})", "Full path of the executable {expr}, or empty if not found."),
    ("exists", "exists({expr})", "1 if variable/option/function/command {expr} exists, else 0."),
    ("expand", "expand({string} [, {nosuf} [, {list}]])", "Expand wildcards and keywords ('%', '<cfile>', '~', ...) in {string}."),
    ("expandcmd", "expandcmd({string} [, {options}])", "{string} with command-line special items ('%', '<cword>', ...) expanded."),
    ("extend", "extend({expr1}, {expr2} [, {expr3}])", "Append/merge {expr2} into List/Dict {expr1} in place; returns {expr1}."),
    ("extendnew", "extendnew({expr1}, {expr2} [, {expr3}])", "Like extend() but returns a new container, leaving {expr1} unchanged."),
    ("feedkeys", "feedkeys({string} [, {mode}])", "Push {string} into the typeahead buffer as if typed (stub in standalone)."),
    ("filecopy", "filecopy({from}, {to})", "Copy file {from} to {to}; v:true on success."),
    ("filereadable", "filereadable({file})", "1 if {file} exists and is readable, else 0."),
    ("filewritable", "filewritable({file})", "1 if {file} is writable, 2 if it is a writable directory, else 0."),
    ("filter", "filter({expr1}, {expr2})", "Keep items of {expr1} for which {expr2} is non-zero; in place."),
    ("finddir", "finddir({name} [, {path} [, {count}]])", "Find directory {name} in {path}; the {count}'th match (or List)."),
    ("findfile", "findfile({name} [, {path} [, {count}]])", "Find file {name} in {path}; the {count}'th match (or List)."),
    ("flatten", "flatten({list} [, {maxdepth}])", "Flatten nested List {list} in place up to {maxdepth}."),
    ("flattennew", "flattennew({list} [, {maxdepth}])", "Flattened copy of nested List {list}, leaving {list} unchanged."),
    ("float2nr", "float2nr({expr})", "{expr} truncated toward zero to a Number."),
    ("fmod", "fmod({expr1}, {expr2})", "Floating-point remainder of {expr1} / {expr2}."),
    ("fnameescape", "fnameescape({string})", "{string} escaped for use as a Vim command file-name argument."),
    ("fnamemodify", "fnamemodify({fname}, {mods})", "Modify file name {fname} per the :p/:h/:t/:r/:e {mods}."),
    ("foldclosed", "foldclosed({lnum})", "First line of the closed fold at {lnum}, else -1."),
    ("foldclosedend", "foldclosedend({lnum})", "Last line of the closed fold at {lnum}, else -1."),
    ("foldlevel", "foldlevel({lnum})", "Fold nesting level of line {lnum}."),
    ("foldtext", "foldtext()", "Text Vim shows for the closed fold on the current line."),
    ("foldtextresult", "foldtextresult({lnum})", "The 'foldtext' string for the fold at {lnum}."),
    ("foreach", "foreach({expr1}, {expr2})", "Apply {expr2} to each item of {expr1} for its side effects; returns {expr1}."),
    ("foreground", "foreground()", "Bring the Vim window to the foreground (GUI/clients) (stub in standalone)."),
    ("fullcommand", "fullcommand({name} [, {vim9}])", "Full Ex-command name for the abbreviation {name}."),
    ("funcref", "funcref({name} [, {arglist}] [, {dict}])", "Funcref bound by reference to {name} (ignores later redefinition)."),
    ("function", "function({name} [, {arglist}] [, {dict}])", "Funcref for builtin/user function {name}, optionally bound to args/dict."),
    ("garbagecollect", "garbagecollect([{atexit}])", "Run the cyclic-reference garbage collector (stub in standalone)."),
    ("get", "get({collection}, {key} [, {default}])", "Item {key}/{idx} of Dict/List/Blob, or {default} if absent."),
    ("getbufinfo", "getbufinfo([{buf}])", "List of dicts with information about buffers."),
    ("getbufline", "getbufline({buf}, {lnum} [, {end}])", "List of lines {lnum}..{end} from buffer {buf}."),
    ("getbufoneline", "getbufoneline({buf}, {lnum})", "Single line {lnum} from buffer {buf} as a String."),
    ("getbufvar", "getbufvar({buf}, {varname} [, {def}])", "Buffer-local variable/option {varname} from buffer {buf}."),
    ("getcellwidths", "getcellwidths()", "List of [low, high, width] cell-width overrides set with setcellwidths()."),
    ("getchangelist", "getchangelist([{buf}])", "[changelist, index] for buffer {buf}."),
    ("getchar", "getchar([{expr} [, {opts}]])", "Get one character of user input as a Number or special-key String."),
    ("getcharmod", "getcharmod()", "Bitmask of modifier keys held for the last getchar()."),
    ("getcharpos", "getcharpos({expr})", "Like getpos() but the column is a character index."),
    ("getcharsearch", "getcharsearch()", "Dict describing the last character search (f/t/F/T)."),
    ("getcharstr", "getcharstr([{expr} [, {opts}]])", "Like getchar() but always returns the character as a String."),
    ("getcmdcomplpat", "getcmdcomplpat()", "Pattern used for completion of the current command line."),
    ("getcmdcompltype", "getcmdcompltype()", "Completion type of the current command line."),
    ("getcmdline", "getcmdline()", "Current command-line contents."),
    ("getcmdpos", "getcmdpos()", "1-based byte position of the cursor in the command line."),
    ("getcmdprompt", "getcmdprompt()", "Prompt string of the current input()/command line."),
    ("getcmdscreenpos", "getcmdscreenpos()", "Screen cursor position within the command line."),
    ("getcmdtype", "getcmdtype()", "Type of the current command line (':', '/', '?', '@', '-', '=')."),
    ("getcmdwintype", "getcmdwintype()", "Type of the command-line window, or empty if none (stub in standalone)."),
    ("getcompletion", "getcompletion({pat}, {type} [, {filtered}])", "List of command-line completion candidates for {pat} of {type}."),
    ("getcompletiontype", "getcompletiontype({pat})", "Completion type Vim would use for command line {pat}."),
    ("getcurpos", "getcurpos([{winid}])", "Cursor position of a window including curswant."),
    ("getcursorcharpos", "getcursorcharpos([{winid}])", "Like getcurpos() but the column is a character index."),
    ("getcwd", "getcwd([{winnr} [, {tabnr}]])", "Current working directory (optionally of a window/tab)."),
    ("getenv", "getenv({name})", "Value of environment variable {name}, or v:null if unset."),
    ("getfontname", "getfontname([{name}])", "Name of the font currently in use (GUI) (stub in standalone)."),
    ("getfperm", "getfperm({fname})", "Permissions of {fname} as a 9-character 'rwxrwxrwx' String."),
    ("getfsize", "getfsize({fname})", "Size of file {fname} in bytes (-1 if absent, -2 if too large)."),
    ("getftime", "getftime({fname})", "Last modification time of {fname} as seconds since the epoch, else -1."),
    ("getftype", "getftype({fname})", "Type of file {fname}: 'file', 'dir', 'link', 'fifo', etc."),
    ("getjumplist", "getjumplist([{winnr} [, {tabnr}]])", "[jumplist, index] for a window."),
    ("getline", "getline({lnum} [, {end}])", "Text of line {lnum} (or List of lines {lnum}..{end}) in the current buffer."),
    ("getloclist", "getloclist({nr} [, {what}])", "List of location-list entries for window {nr}."),
    ("getmarklist", "getmarklist([{buf}])", "List of marks (global, or local to buffer {buf})."),
    ("getmatches", "getmatches([{win}])", "List of matches added with matchadd()/setmatches()."),
    ("getmousepos", "getmousepos()", "Dict with the last known mouse position."),
    ("getpid", "getpid()", "Process ID of the Vim process."),
    ("getpos", "getpos({expr})", "Position [bufnum, lnum, col, off] of {expr}."),
    ("getqflist", "getqflist([{what}])", "List of quickfix entries (or info per {what})."),
    ("getreg", "getreg([{regname} [, {list} [, {opts}]]])", "Contents of register {regname}."),
    ("getreginfo", "getreginfo([{regname}])", "Dict describing register {regname} (value, type, width)."),
    ("getregion", "getregion({pos1}, {pos2} [, {opts}])", "List of text lines for the region between {pos1} and {pos2}."),
    ("getregionpos", "getregionpos({pos1}, {pos2} [, {opts}])", "List of [start, end] position pairs for each line of a region."),
    ("getregtype", "getregtype([{regname}])", "Type of register {regname}: 'v', 'V', or blockwise."),
    ("getscriptinfo", "getscriptinfo([{opts}])", "List of dicts describing the sourced Vim scripts."),
    ("getstacktrace", "getstacktrace()", "List describing the current Vimscript call stack."),
    ("gettabinfo", "gettabinfo([{tabnr}])", "List of dicts with information about tab pages."),
    ("gettabvar", "gettabvar({tabnr}, {varname} [, {def}])", "Tab-local variable {varname} of tab {tabnr}."),
    ("gettabwinvar", "gettabwinvar({tabnr}, {winnr}, {varname} [, {def}])", "Window-local variable in window {winnr} of tab {tabnr}."),
    ("gettagstack", "gettagstack([{winnr}])", "Dict describing the tag stack of window {winnr}."),
    ("gettext", "gettext({text} [, {package}])", "Translated {text} via gettext (identity when no catalog)."),
    ("getwininfo", "getwininfo([{winid}])", "List of dicts with information about windows."),
    ("getwinpos", "getwinpos([{timeout}])", "[x, y] pixel position of the Vim window."),
    ("getwinposx", "getwinposx()", "X pixel position of the left of the Vim window, else -1 (stub in standalone)."),
    ("getwinposy", "getwinposy()", "Y pixel position of the top of the Vim window, else -1 (stub in standalone)."),
    ("getwinvar", "getwinvar({nr}, {varname} [, {def}])", "Window-local variable/option {varname} of window {nr}."),
    ("glob", "glob({expr} [, {nosuf} [, {list} [, {alllinks}]]])", "Expand file wildcards {expr}; String (or List) of matching paths."),
    ("glob2regpat", "glob2regpat({string})", "Vim regexp pattern equivalent to the file glob {string}."),
    ("globpath", "globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])", "Expand {expr} in every directory of {path}."),
    ("has", "has({feature} [, {check}])", "1 if Vim supports {feature}, else 0."),
    ("has_key", "has_key({dict}, {key})", "1 if {dict} has an entry {key}, else 0."),
    ("haslocaldir", "haslocaldir([{winnr} [, {tabnr}]])", "1 if the window/tab has a local working directory."),
    ("hasmapto", "hasmapto({what} [, {mode} [, {abbr}]])", "1 if a mapping exists whose rhs contains {what}."),
    ("highlight_exists", "highlight_exists({name})", "1 if highlight group {name} is defined (alias of hlexists())."),
    ("histadd", "histadd({history}, {item})", "Add {item} to the {history} list (cmd/search/expr/input)."),
    ("histdel", "histdel({history} [, {item}])", "Delete entries from the {history} list."),
    ("histget", "histget({history} [, {index}])", "Entry {index} from the {history} list."),
    ("histnr", "histnr({history})", "Index of the most recent entry in the {history} list."),
    ("hlID", "hlID({name})", "Numeric ID of highlight group {name} (0 if undefined)."),
    ("hlexists", "hlexists({name})", "1 if highlight group {name} is defined, else 0 (stub in standalone)."),
    ("hostname", "hostname()", "Name of the host Vim is running on."),
    ("iconv", "iconv({string}, {from}, {to})", "{string} converted from encoding {from} to {to}."),
    ("id", "id({expr})", "Unique String identifier for the container or value {expr}."),
    ("indent", "indent({lnum})", "Indent (in spaces) of line {lnum} in the current buffer."),
    ("index", "index({object}, {expr} [, {start} [, {ic}]])", "Index of first item equal to {expr} in {object}, else -1."),
    ("indexof", "indexof({object}, {expr} [, {opts}])", "Index of first item for which {expr} is true, else -1."),
    ("input", "input({prompt} [, {text} [, {completion}]])", "Prompt for and return a line of input from the user."),
    ("inputdialog", "inputdialog({prompt} [, {text} [, {cancelreturn}]])", "Like input() but using a GUI dialog when available."),
    ("inputlist", "inputlist({textlist})", "Prompt the user to pick a numbered entry from {textlist}."),
    ("inputrestore", "inputrestore()", "Restore typeahead previously saved with inputsave() (stub in standalone)."),
    ("inputsave", "inputsave()", "Save and clear pending typeahead so input() can be used (stub in standalone)."),
    ("inputsecret", "inputsecret({prompt} [, {text}])", "Like input() but the typed text is hidden."),
    ("insert", "insert({object}, {item} [, {idx}])", "Insert {item} into List/Blob {object} before index {idx} (default 0)."),
    ("interrupt", "interrupt()", "Interrupt script execution as if CTRL-C were pressed (stub in standalone)."),
    ("invert", "invert({expr})", "Bitwise complement (NOT) of {expr}."),
    ("isabsolutepath", "isabsolutepath({path})", "1 if {path} is an absolute path, else 0."),
    ("isdirectory", "isdirectory({directory})", "1 if {directory} exists and is a directory, else 0."),
    ("isinf", "isinf({expr})", "1 if {expr} is +inf, -1 if -inf, else 0."),
    ("islocked", "islocked({expr})", "1 if the variable named by {expr} is locked, else 0 (stub in standalone)."),
    ("isnan", "isnan({expr})", "1 if {expr} is a NaN Float, else 0."),
    ("items", "items({dict})", "List of [key, value] pairs in {dict}."),
    ("jobpid", "jobpid({id})", "Process ID of job {id} (stub in standalone)."),
    ("jobresize", "jobresize({id}, {width}, {height})", "Resize the pseudo-terminal of job {id} (stub in standalone)."),
    ("jobstart", "jobstart({cmd} [, {opts}])", "Start job running {cmd}; returns a job id (or <=0 on failure) (stub in standalone)."),
    ("jobstop", "jobstop({id})", "Stop job {id} (stub in standalone)."),
    ("jobwait", "jobwait({ids} [, {timeout}])", "Wait for the jobs {ids} to finish; List of exit codes."),
    ("join", "join({list} [, {sep}])", "String of {list} items joined by {sep} (default space)."),
    ("json_decode", "json_decode({string})", "Vim value decoded from JSON text {string}."),
    ("json_encode", "json_encode({expr})", "JSON text encoding of {expr}."),
    ("keys", "keys({dict})", "List of all keys in {dict}."),
    ("keytrans", "keytrans({string})", "{string} with key codes translated to readable form (e.g. <C-A>)."),
    ("last_buffer_nr", "last_buffer_nr()", "Number of the last (highest-numbered) buffer (stub in standalone)."),
    ("len", "len({expr})", "Length of String/List/Dict/Blob {expr}."),
    ("libcall", "libcall({lib}, {func}, {arg})", "Call function {func} in dynamic library {lib} (String result) (stub in standalone)."),
    ("libcallnr", "libcallnr({lib}, {func}, {arg})", "Call function {func} in dynamic library {lib} (Number result) (stub in standalone)."),
    ("line", "line({expr} [, {winid}])", "Line number for position {expr} ('.', '$', mark, ...)."),
    ("line2byte", "line2byte({lnum})", "Byte offset of the first byte of line {lnum} (1-based), else -1."),
    ("lispindent", "lispindent({lnum})", "Lisp indent amount Vim would use for line {lnum}."),
    ("list2blob", "list2blob({list})", "Blob built from the List of byte-value Numbers {list}."),
    ("list2str", "list2str({list} [, {utf8}])", "String built from the List of codepoint numbers {list}."),
    ("localtime", "localtime()", "Current time as seconds since the Unix epoch."),
    ("luaeval", "luaeval({expr} [, {expr}])", "Evaluate Lua expression {expr} and return the result."),
    ("map", "map({expr1}, {expr2})", "Replace each item of List/Dict/Blob/String {expr1} with {expr2}; in place."),
    ("maparg", "maparg({name} [, {mode} [, {abbr} [, {dict}]]])", "rhs (or Dict) of the mapping of {name} in {mode}."),
    ("mapcheck", "mapcheck({name} [, {mode} [, {abbr}]])", "rhs of a mapping that {name} could match, else empty."),
    ("maplist", "maplist([{abbr}])", "List of dicts describing all mappings."),
    ("mapnew", "mapnew({expr1}, {expr2})", "Like map() but returns a new container, leaving {expr1} unchanged."),
    ("mapset", "mapset({mode}, {abbr}, {dict})", "Restore a mapping from a maparg() dict."),
    ("match", "match({expr}, {pat} [, {start} [, {count}]])", "Byte index where {pat} matches in {expr}, else -1."),
    ("matchadd", "matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])", "Highlight {pattern} with {group}; returns the match id."),
    ("matchaddpos", "matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])", "Highlight positions {pos} with {group}; returns the match id."),
    ("matcharg", "matcharg({nr})", "['pattern', 'group'] for the {nr}'th :match command."),
    ("matchbufline", "matchbufline({buf}, {pat}, {lnum}, {end} [, {dict}])", "List of matches of {pat} in buffer {buf} lines {lnum}..{end}."),
    ("matchdelete", "matchdelete({id} [, {win}])", "Delete the match with {id}."),
    ("matchend", "matchend({expr}, {pat} [, {start} [, {count}]])", "Byte index just after the match of {pat} in {expr}, else -1."),
    ("matchfuzzy", "matchfuzzy({list}, {str} [, {dict}])", "Items of {list} fuzzy-matching {str}, best first."),
    ("matchfuzzypos", "matchfuzzypos({list}, {str} [, {dict}])", "Like matchfuzzy() plus match positions and scores."),
    ("matchlist", "matchlist({expr}, {pat} [, {start} [, {count}]])", "List of the full match and submatches of {pat} in {expr}."),
    ("matchstr", "matchstr({expr}, {pat} [, {start} [, {count}]])", "Matched substring of {pat} in {expr}, or empty string."),
    ("matchstrlist", "matchstrlist({list}, {pat} [, {dict}])", "List of dicts describing matches of {pat} across the strings in {list}."),
    ("matchstrpos", "matchstrpos({expr}, {pat} [, {start} [, {count}]])", "[match, start, end] of {pat} in {expr}."),
    ("max", "max({expr})", "Maximum value among the items of List/Dict {expr} (0 if empty)."),
    ("menu_get", "menu_get({path} [, {modes}])", "List of dicts describing the menus under {path}."),
    ("menu_info", "menu_info({name} [, {mode}])", "Dict of information about menu {name}."),
    ("min", "min({expr})", "Minimum value among the items of List/Dict {expr} (0 if empty)."),
    ("mkdir", "mkdir({name} [, {flags} [, {prot}]])", "Create directory {name} ('p' makes parents); 1 on success."),
    ("mode", "mode([{expr}])", "Current mode as a short String ('n', 'i', 'v', ...)."),
    ("msgpackdump", "msgpackdump({list} [, {type}])", "msgpack byte representation of the items in {list}."),
    ("msgpackparse", "msgpackparse({data})", "List of Vim values parsed from msgpack {data}."),
    ("nextnonblank", "nextnonblank({lnum})", "Line number of the first non-blank line at/after {lnum}, else 0."),
    ("nr2char", "nr2char({expr} [, {utf8}])", "Character whose codepoint is {expr}."),
    ("or", "or({expr1}, {expr2})", "Bitwise OR of {expr1} and {expr2}."),
    ("pathshorten", "pathshorten({path} [, {len}])", "Shorten directory components of {path} to {len} characters."),
    ("perleval", "perleval({expr})", "Evaluate Perl expression {expr} and return the result."),
    ("pow", "pow({x}, {y})", "{x} raised to the power {y} as a Float."),
    ("preinserted", "preinserted()", "Text inserted by the current 'completefunc'/preinsert, if any."),
    ("prevnonblank", "prevnonblank({lnum})", "Line number of the first non-blank line at/before {lnum}, else 0."),
    ("printf", "printf({fmt} [, {expr1} ...])", "Formatted string from printf-style {fmt} and arguments."),
    ("prompt_appendbuf", "prompt_appendbuf({buf}, {expr})", "Append {expr} to prompt-buffer {buf} above the prompt (stub in standalone)."),
    ("prompt_getinput", "prompt_getinput({buf})", "Current input line in prompt-buffer {buf} (stub in standalone)."),
    ("prompt_getprompt", "prompt_getprompt({buf})", "Prompt string of prompt-buffer {buf} (stub in standalone)."),
    ("prompt_setcallback", "prompt_setcallback({buf}, {expr})", "Set the callback invoked on Enter in prompt-buffer {buf} (stub in standalone)."),
    ("prompt_setinterrupt", "prompt_setinterrupt({buf}, {expr})", "Set the callback invoked on CTRL-C in prompt-buffer {buf} (stub in standalone)."),
    ("prompt_setprompt", "prompt_setprompt({buf}, {text})", "Set the prompt of prompt-buffer {buf} to {text} (stub in standalone)."),
    ("pum_getpos", "pum_getpos()", "Dict describing the popup menu position, or empty if hidden."),
    ("pumvisible", "pumvisible()", "1 if the Insert-mode popup menu is visible, else 0 (stub in standalone)."),
    ("py3eval", "py3eval({expr})", "Evaluate Python 3 expression {expr} and return the result."),
    ("pyeval", "pyeval({expr})", "Evaluate Python (2) expression {expr} and return the result."),
    ("pyxeval", "pyxeval({expr})", "Evaluate Python (pyx) expression {expr} and return the result."),
    ("rand", "rand([{expr}])", "Pseudo-random 32-bit Number, optionally from seed-list {expr}."),
    ("range", "range({expr} [, {max} [, {stride}]])", "List of numbers from {expr} to {max} stepping by {stride}."),
    ("readblob", "readblob({fname} [, {offset} [, {size}]])", "Blob of the (partial) contents of file {fname}."),
    ("readdir", "readdir({directory} [, {expr}])", "List of file names in {directory}, optionally filtered by {expr}."),
    ("readfile", "readfile({fname} [, {type} [, {max}]])", "List of lines read from file {fname}."),
    ("reduce", "reduce({object}, {func} [, {initial}])", "Fold {object} to a single value via {func}, starting at {initial}."),
    ("reg_executing", "reg_executing()", "Name of the register being executed (replayed), or empty (stub in standalone)."),
    ("reg_recorded", "reg_recorded()", "Name of the register last recorded into, or empty (stub in standalone)."),
    ("reg_recording", "reg_recording()", "Name of the register being recorded into, or empty (stub in standalone)."),
    ("reltime", "reltime([{start} [, {end}]])", "High-resolution time value, or an elapsed interval."),
    ("reltimefloat", "reltimefloat({time})", "reltime() value as a Float number of seconds."),
    ("reltimestr", "reltimestr({time})", "reltime() value formatted as a 'seconds.microseconds' String."),
    ("remove", "remove({object}, {idx} [, {end}])", "Remove and return item {idx} (or range {idx}..{end}) from {object}."),
    ("rename", "rename({from}, {to})", "Rename/move file {from} to {to}; 0 on success."),
    ("repeat", "repeat({expr}, {count})", "{expr} (String or List) repeated {count} times."),
    ("resolve", "resolve({filename})", "Resolve symbolic links in {filename} to its real path."),
    ("reverse", "reverse({object})", "Reverse List/Blob {object} in place; returns {object}."),
    ("rpcnotify", "rpcnotify({channel}, {event} [, {args} ...])", "Send an RPC notification {event} to {channel} (stub in standalone)."),
    ("rpcrequest", "rpcrequest({channel}, {method} [, {args} ...])", "Send a blocking RPC request {method} to {channel} and return the result (stub in standalone)."),
    ("rpcstart", "rpcstart({prog} [, {argv}])", "Deprecated: start an RPC channel to {prog} (stub in standalone)."),
    ("rpcstop", "rpcstop({channel})", "Deprecated: close RPC channel {channel} (stub in standalone)."),
    ("rubyeval", "rubyeval({expr})", "Evaluate Ruby expression {expr} and return the result."),
    ("screenattr", "screenattr({row}, {col})", "Highlight attribute id of the screen cell at {row},{col} (stub in standalone)."),
    ("screenchar", "screenchar({row}, {col})", "Codepoint of the character on the screen at {row},{col} (stub in standalone)."),
    ("screenchars", "screenchars({row}, {col})", "List of codepoints (incl. composing) at screen cell {row},{col}."),
    ("screencol", "screencol()", "Current cursor screen column (stub in standalone)."),
    ("screenpos", "screenpos({winid}, {lnum}, {col})", "Screen position of buffer position {lnum},{col}."),
    ("screenrow", "screenrow()", "Current cursor screen row (stub in standalone)."),
    ("screenstring", "screenstring({row}, {col})", "String of the character(s) at screen cell {row},{col} (stub in standalone)."),
    ("search", "search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])", "Search for {pattern}; returns the matching line number, else 0."),
    ("searchcount", "searchcount([{options}])", "Dict of search match counts for the last/used pattern."),
    ("searchdecl", "searchdecl({name} [, {global} [, {thisblock}]])", "Move to the declaration of {name}; 0 if found (stub in standalone)."),
    ("searchpair", "searchpair({start}, {middle}, {end} [, {flags} ...])", "Search for the matching {end} of a nested {start}/{end} pair."),
    ("searchpairpos", "searchpairpos({start}, {middle}, {end} [, {flags} ...])", "Like searchpair() but returns the [line, col] of the match."),
    ("searchpos", "searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])", "Like search() but returns the [line, col] of the match."),
    ("serverlist", "serverlist()", "Newline-separated list of server addresses Vim is listening on."),
    ("serverstart", "serverstart([{address}])", "Start an RPC server, returning its listen address (stub in standalone)."),
    ("serverstop", "serverstop({address})", "Stop the RPC server listening on {address} (stub in standalone)."),
    ("setbufline", "setbufline({buf}, {lnum}, {text})", "Set line {lnum} of buffer {buf} to {text}."),
    ("setbufvar", "setbufvar({buf}, {varname}, {val})", "Set buffer-local variable/option {varname} in buffer {buf} (stub in standalone)."),
    ("setcellwidths", "setcellwidths({list})", "Override the display cell width of character ranges from {list}."),
    ("setcharpos", "setcharpos({expr}, {list})", "Like setpos() but the column in {list} is a character index."),
    ("setcharsearch", "setcharsearch({dict})", "Set the last character-search state from {dict} (stub in standalone)."),
    ("setcmdline", "setcmdline({str} [, {pos}])", "Set the command line to {str} with the cursor at {pos}."),
    ("setcmdpos", "setcmdpos({pos})", "Set the cursor position in the command line to {pos}."),
    ("setcursorcharpos", "setcursorcharpos({lnum}, {col} [, {off}])", "Move the cursor to character position {lnum},{col}."),
    ("setenv", "setenv({name}, {val})", "Set environment variable {name} to {val} (v:null unsets it)."),
    ("setfperm", "setfperm({fname}, {mode})", "Set permissions of {fname} from a 9-character 'rwxrwxrwx' {mode}."),
    ("setline", "setline({lnum}, {text})", "Set line {lnum} to {text} (String or List of lines); 0 on success."),
    ("setloclist", "setloclist({nr}, {list} [, {action} [, {what}]])", "Set the location list for window {nr}."),
    ("setmatches", "setmatches({list} [, {win}])", "Restore matches from a List produced by getmatches()."),
    ("setpos", "setpos({expr}, {list})", "Set cursor/mark position {expr} from [bufnum, lnum, col, off]."),
    ("setqflist", "setqflist({list} [, {action} [, {what}]])", "Set the quickfix list."),
    ("setreg", "setreg({regname}, {value} [, {options}])", "Set register {regname} to {value} with optional type {options}."),
    ("settabvar", "settabvar({tabnr}, {varname}, {val})", "Set tab-local variable {varname} of tab {tabnr} (stub in standalone)."),
    ("settabwinvar", "settabwinvar({tabnr}, {winnr}, {varname}, {val})", "Set a window-local variable in window {winnr} of tab {tabnr} (stub in standalone)."),
    ("settagstack", "settagstack({winnr}, {dict} [, {action}])", "Set the tag stack of window {winnr} (stub in standalone)."),
    ("setwinvar", "setwinvar({nr}, {varname}, {val})", "Set window-local variable/option {varname} of window {nr} (stub in standalone)."),
    ("sha256", "sha256({string})", "SHA-256 hex digest of {string}."),
    ("shellescape", "shellescape({string} [, {special}])", "{string} quoted for safe use as a shell command argument."),
    ("shiftwidth", "shiftwidth([{col}])", "Effective 'shiftwidth' value (resolving 0 to 'tabstop')."),
    ("sign_define", "sign_define({name} [, {dict}])", "Define sign {name} with attributes; 0 on success."),
    ("sign_getdefined", "sign_getdefined([{name}])", "List of defined signs (or just {name})."),
    ("sign_getplaced", "sign_getplaced([{buf} [, {dict}]])", "List of signs placed in a buffer."),
    ("sign_jump", "sign_jump({id}, {group}, {buf})", "Jump to sign {id} of {group} in buffer {buf}."),
    ("sign_place", "sign_place({id}, {group}, {name}, {buf} [, {dict}])", "Place sign {name} in buffer {buf}; returns the sign id."),
    ("sign_placelist", "sign_placelist({list})", "Place a List of signs at once; List of ids."),
    ("sign_undefine", "sign_undefine([{name}])", "Undefine sign {name} (or all signs)."),
    ("sign_unplace", "sign_unplace({group} [, {dict}])", "Remove placed sign(s) in {group}."),
    ("sign_unplacelist", "sign_unplacelist({list})", "Remove a List of placed signs."),
    ("simplify", "simplify({filename})", "Simplify {filename} by resolving '.', '..' and doubled separators (no disk access)."),
    ("slice", "slice({expr}, {start} [, {end}])", "Sub-list/Blob/String of {expr} from {start} up to (not including) {end}."),
    ("sockconnect", "sockconnect({mode}, {address} [, {opts}])", "Connect a socket to {address} (tcp/pipe); returns a channel id (stub in standalone)."),
    ("sort", "sort({list} [, {how} [, {dict}]])", "Sort {list} in place; {how} sets comparison; returns {list}."),
    ("soundfold", "soundfold({word})", "Sound-folded (phonetic) form of {word}."),
    ("spellbadword", "spellbadword([{sentence}])", "[badword, type] of the first misspelled word at/after the cursor."),
    ("spellsuggest", "spellsuggest({word} [, {max} [, {capital}]])", "List of spelling suggestions for {word}."),
    ("split", "split({string} [, {pat} [, {keepempty}]])", "List of {string} split on {pat} (default whitespace)."),
    ("srand", "srand([{expr}])", "Initialize and return a seed List for rand()."),
    ("state", "state([{what}])", "String of characters describing Vim's current busy/blocking state (stub in standalone)."),
    ("stdioopen", "stdioopen({opts})", "Open a channel on Vim's own stdin/stdout (stub in standalone)."),
    ("stdpath", "stdpath({what})", "Standard config/data/cache/state path(s) for {what}."),
    ("str2float", "str2float({string} [, {quoted}])", "Float parsed from {string}."),
    ("str2list", "str2list({string} [, {utf8}])", "List of codepoint numbers for each character in {string}."),
    ("str2nr", "str2nr({string} [, {base}])", "Leading integer parsed from {string} in {base} (default 10)."),
    ("strcharlen", "strcharlen({string})", "Number of characters in {string}, ignoring composing characters."),
    ("strcharpart", "strcharpart({src}, {start} [, {len} [, {skipcc}]])", "Character substring of {src} from char {start} for {len} chars."),
    ("strchars", "strchars({string} [, {skipcc}])", "Number of characters in {string}, counting composing chars unless {skipcc}."),
    ("strdisplaywidth", "strdisplaywidth({string} [, {col}])", "Display cell width of {string}, honoring 'tabstop'."),
    ("strftime", "strftime({format} [, {time}])", "Format time {time} (default now) with strftime() {format}."),
    ("strgetchar", "strgetchar({str}, {index})", "Codepoint at char {index} of {str}, or -1."),
    ("stridx", "stridx({haystack}, {needle} [, {start}])", "Byte index of first {needle} in {haystack} at/after {start}, else -1."),
    ("string", "string({expr})", "String representation of {expr}, quoting embedded strings (inverse of eval())."),
    ("strlen", "strlen({string})", "Number of bytes in {string}."),
    ("strpart", "strpart({src}, {start} [, {len} [, {chars}]])", "Byte (or char) substring of {src} from {start} for {len}."),
    ("strptime", "strptime({format}, {timestring})", "Parse {timestring} per {format} into seconds since the epoch."),
    ("strridx", "strridx({haystack}, {needle} [, {start}])", "Byte index of last {needle} in {haystack} at/before {start}, else -1."),
    ("strtrans", "strtrans({string})", "{string} with unprintable characters shown as ^X / <xx>."),
    ("strutf16len", "strutf16len({string} [, {countcc}])", "Number of UTF-16 code units in {string}."),
    ("strwidth", "strwidth({string})", "Display cell width of {string} (no tab expansion)."),
    ("submatch", "submatch({nr} [, {list}])", "The {nr}'th submatch of the substitute() replacement."),
    ("substitute", "substitute({string}, {pat}, {sub}, {flags})", "{string} with matches of {pat} replaced by {sub}; {flags} 'g' replaces all."),
    ("swapfilelist", "swapfilelist()", "List of swap files found in the 'directory' directories."),
    ("swapinfo", "swapinfo({fname})", "Dict of information read from swap file {fname}."),
    ("swapname", "swapname({buf})", "Swap-file name of buffer {buf}, or empty if none (stub in standalone)."),
    ("synID", "synID({lnum}, {col}, {trans})", "Syntax ID at line {lnum}, column {col} (stub in standalone)."),
    ("synIDattr", "synIDattr({synID}, {what} [, {mode}])", "Attribute {what} of syntax ID {synID} (stub in standalone)."),
    ("synIDtrans", "synIDtrans({synID})", "Translated (effective) syntax ID for {synID} (stub in standalone)."),
    ("synconcealed", "synconcealed({lnum}, {col})", "Info about concealed text at line {lnum}, column {col}."),
    ("synstack", "synstack({lnum}, {col})", "List of syntax IDs stacked at line {lnum}, column {col}."),
    ("system", "system({cmd} [, {input}])", "Run shell {cmd}, returning its output as a String."),
    ("systemlist", "systemlist({cmd} [, {input}])", "Run shell {cmd}, returning its output as a List of lines."),
    ("tabpagebuflist", "tabpagebuflist([{arg}])", "List of buffer numbers shown in a tab page (stub in standalone)."),
    ("tabpagenr", "tabpagenr([{arg}])", "Number of the current (or last) tab page (stub in standalone)."),
    ("tabpagewinnr", "tabpagewinnr({tabnr} [, {arg}])", "Number of the current window in tab {tabnr} (stub in standalone)."),
    ("tagfiles", "tagfiles()", "List of tags files used by the current buffer."),
    ("taglist", "taglist({expr} [, {filename}])", "List of tags matching the regexp {expr}."),
    ("tempname", "tempname()", "Name of a unique, not-yet-existing temporary file."),
    ("termopen", "termopen({cmd} [, {opts}])", "Open a terminal running {cmd} in the current buffer (stub in standalone)."),
    ("test_garbagecollect_now", "test_garbagecollect_now()", "Test helper: run the garbage collector immediately (stub in standalone)."),
    ("test_write_list_log", "test_write_list_log({fname})", "Test helper: write the internal list-allocation log to {fname} (stub in standalone)."),
    ("timer_info", "timer_info([{id}])", "List of dicts describing active timers."),
    ("timer_pause", "timer_pause({timer}, {paused})", "Pause or unpause timer {timer} (stub in standalone)."),
    ("timer_start", "timer_start({time}, {callback} [, {options}])", "Start a timer firing {callback} after {time} ms; returns its id (stub in standalone)."),
    ("timer_stop", "timer_stop({timer})", "Stop timer {timer} (stub in standalone)."),
    ("timer_stopall", "timer_stopall()", "Stop all timers (stub in standalone)."),
    ("tolower", "tolower({string})", "{string} with all letters lowercased."),
    ("toupper", "toupper({string})", "{string} with all letters uppercased."),
    ("tr", "tr({src}, {fromstr}, {tostr})", "{src} with each char in {fromstr} replaced by the matching char in {tostr}."),
    ("trim", "trim({text} [, {mask} [, {dir}]])", "{text} with leading/trailing {mask} chars (default whitespace) removed."),
    ("type", "type({expr})", "Numeric type code of {expr} (0 Number, 1 String, 2 Func, 3 List, 4 Dict, ...)."),
    ("undofile", "undofile({name})", "Undo-file path Vim would use for file {name}."),
    ("undotree", "undotree([{buf}])", "Dict describing the undo tree of the buffer."),
    ("uniq", "uniq({list} [, {how} [, {dict}]])", "Remove adjacent duplicate items from sorted {list} in place."),
    ("utf16idx", "utf16idx({string}, {idx} [, {countcc} [, {charidx}]])", "UTF-16 code-unit index of byte {idx} in {string}."),
    ("values", "values({dict})", "List of all values in {dict}."),
    ("virtcol", "virtcol({expr} [, {list} [, {winid}]])", "Screen (virtual) column of position {expr}."),
    ("virtcol2col", "virtcol2col({winid}, {lnum}, {col})", "Byte index in line {lnum} of screen column {col} in window {winid}."),
    ("visualmode", "visualmode([{expr}])", "Last Visual mode used ('v', 'V', or CTRL-V) (stub in standalone)."),
    ("wait", "wait({timeout}, {condition} [, {interval}])", "Wait until {condition} is true or {timeout} ms elapse (stub in standalone)."),
    ("wildmenumode", "wildmenumode()", "1 if the wildmenu command-line completion menu is active (stub in standalone)."),
    ("wildtrigger", "wildtrigger()", "Trigger command-line ('wildchar') completion programmatically (stub in standalone)."),
    ("win_execute", "win_execute({id}, {command} [, {silent}])", "Execute {command} as if in window {id}, returning its output (stub in standalone)."),
    ("win_findbuf", "win_findbuf({bufnr})", "List of window-IDs that display buffer {bufnr}."),
    ("win_getid", "win_getid([{win} [, {tab}]])", "window-ID of window {win} in tab {tab} (stub in standalone)."),
    ("win_gettype", "win_gettype([{nr}])", "Type of window {nr} ('popup', 'command', 'autocmd', ...)."),
    ("win_gotoid", "win_gotoid({id})", "Go to the window with window-ID {id}; 1 on success (stub in standalone)."),
    ("win_id2tabwin", "win_id2tabwin({id})", "[tabnr, winnr] of window-ID {id}."),
    ("win_id2win", "win_id2win({id})", "Window number of window-ID {id}, else 0 (stub in standalone)."),
    ("win_move_separator", "win_move_separator({nr}, {offset})", "Move the vertical separator of window {nr} by {offset} (stub in standalone)."),
    ("win_move_statusline", "win_move_statusline({nr}, {offset})", "Move the status line of window {nr} by {offset} (stub in standalone)."),
    ("win_screenpos", "win_screenpos({nr})", "[row, col] screen position of the top-left of window {nr}."),
    ("win_splitmove", "win_splitmove({nr}, {target} [, {options}])", "Move window {nr} to split alongside window {target} (stub in standalone)."),
    ("winbufnr", "winbufnr({nr})", "Buffer number of window {nr}, else -1 (stub in standalone)."),
    ("wincol", "wincol()", "Cursor's screen column within its window (stub in standalone)."),
    ("windowsversion", "windowsversion()", "Microsoft Windows version string ('' on other systems) (stub in standalone)."),
    ("winheight", "winheight({nr})", "Height (in lines) of window {nr}, else -1 (stub in standalone)."),
    ("winlayout", "winlayout([{tabnr}])", "Nested List describing the window layout of a tab page."),
    ("winline", "winline()", "Cursor's screen row within its window (stub in standalone)."),
    ("winnr", "winnr([{arg}])", "Number of the current (or related) window (stub in standalone)."),
    ("winrestcmd", "winrestcmd()", "Ex command string that restores the current window sizes (stub in standalone)."),
    ("winrestview", "winrestview({dict})", "Restore the window view from a winsaveview() dict (stub in standalone)."),
    ("winsaveview", "winsaveview()", "Dict capturing the current window view (cursor, scroll)."),
    ("winwidth", "winwidth({nr})", "Width (in columns) of window {nr}, else -1 (stub in standalone)."),
    ("wordcount", "wordcount()", "Dict of byte/char/word counts for the buffer and cursor."),
    ("writefile", "writefile({object}, {fname} [, {flags}])", "Write List of lines or Blob {object} to file {fname}; 0 on success."),
    ("xor", "xor({expr1}, {expr2})", "Bitwise XOR of {expr1} and {expr2}."),
];

/// Vim help-style chapter for each documented builtin: `(name, category)`.
/// Names not present here fall into "Functional & Misc".
pub const BUILTIN_CATEGORY: &[(&str, &str)] = &[
    ("abs", "Number & Float"),
    ("add", "List manipulation"),
    ("and", "Number & Float"),
    ("api_info", "Functional & Misc"),
    ("append", "Files, Buffers & Lines"),
    ("appendbufline", "Files, Buffers & Lines"),
    ("argc", "Functional & Misc"),
    ("argidx", "Functional & Misc"),
    ("arglistid", "Functional & Misc"),
    ("argv", "Functional & Misc"),
    ("assert_equal", "Functional & Misc"),
    ("assert_equalfile", "Functional & Misc"),
    ("assert_exception", "Functional & Misc"),
    ("assert_false", "Functional & Misc"),
    ("assert_inrange", "Functional & Misc"),
    ("assert_match", "Functional & Misc"),
    ("assert_notequal", "Functional & Misc"),
    ("assert_notmatch", "Functional & Misc"),
    ("assert_report", "Functional & Misc"),
    ("assert_true", "Functional & Misc"),
    ("atan2", "Number & Float"),
    ("blob2list", "List manipulation"),
    ("browse", "Files, Buffers & Lines"),
    ("browsedir", "Files, Buffers & Lines"),
    ("bufadd", "Files, Buffers & Lines"),
    ("bufexists", "Files, Buffers & Lines"),
    ("buflisted", "Files, Buffers & Lines"),
    ("bufload", "Files, Buffers & Lines"),
    ("bufloaded", "Files, Buffers & Lines"),
    ("bufname", "Files, Buffers & Lines"),
    ("bufnr", "Files, Buffers & Lines"),
    ("bufwinid", "Files, Buffers & Lines"),
    ("bufwinnr", "Files, Buffers & Lines"),
    ("byte2line", "Files, Buffers & Lines"),
    ("byteidx", "String manipulation"),
    ("byteidxcomp", "String manipulation"),
    ("call", "Functional & Misc"),
    ("chanclose", "System & Environment"),
    ("changenr", "Files, Buffers & Lines"),
    ("chansend", "System & Environment"),
    ("char2nr", "String manipulation"),
    ("charclass", "String manipulation"),
    ("charcol", "Files, Buffers & Lines"),
    ("charidx", "String manipulation"),
    ("chdir", "Files, Buffers & Lines"),
    ("cindent", "Files, Buffers & Lines"),
    ("clearmatches", "Functional & Misc"),
    ("cmdcomplete_info", "Functional & Misc"),
    ("col", "Files, Buffers & Lines"),
    ("complete", "Functional & Misc"),
    ("complete_add", "Functional & Misc"),
    ("complete_check", "Functional & Misc"),
    ("complete_info", "Functional & Misc"),
    ("confirm", "Functional & Misc"),
    ("copy", "List manipulation"),
    ("count", "List manipulation"),
    ("ctxget", "Functional & Misc"),
    ("ctxpop", "Functional & Misc"),
    ("ctxpush", "Functional & Misc"),
    ("ctxset", "Functional & Misc"),
    ("ctxsize", "Functional & Misc"),
    ("cursor", "Functional & Misc"),
    ("debugbreak", "Functional & Misc"),
    ("deepcopy", "List manipulation"),
    ("delete", "Files, Buffers & Lines"),
    ("deletebufline", "Files, Buffers & Lines"),
    ("dictwatcheradd", "Dictionary manipulation"),
    ("dictwatcherdel", "Dictionary manipulation"),
    ("did_filetype", "Functional & Misc"),
    ("diff_filler", "Functional & Misc"),
    ("diff_hlID", "Functional & Misc"),
    ("digraph_get", "String manipulation"),
    ("digraph_getlist", "String manipulation"),
    ("digraph_set", "String manipulation"),
    ("digraph_setlist", "String manipulation"),
    ("empty", "Variables & Type"),
    ("environ", "System & Environment"),
    ("escape", "String manipulation"),
    ("eval", "Functional & Misc"),
    ("eventhandler", "Functional & Misc"),
    ("executable", "Files, Buffers & Lines"),
    ("execute", "Functional & Misc"),
    ("exepath", "Files, Buffers & Lines"),
    ("exists", "Variables & Type"),
    ("expand", "Files, Buffers & Lines"),
    ("expandcmd", "String manipulation"),
    ("extend", "Dictionary manipulation"),
    ("extendnew", "Dictionary manipulation"),
    ("feedkeys", "Functional & Misc"),
    ("filecopy", "Files, Buffers & Lines"),
    ("filereadable", "Files, Buffers & Lines"),
    ("filewritable", "Files, Buffers & Lines"),
    ("filter", "Functional & Misc"),
    ("finddir", "Files, Buffers & Lines"),
    ("findfile", "Files, Buffers & Lines"),
    ("flatten", "List manipulation"),
    ("flattennew", "List manipulation"),
    ("float2nr", "Number & Float"),
    ("fmod", "Number & Float"),
    ("fnameescape", "String manipulation"),
    ("fnamemodify", "Files, Buffers & Lines"),
    ("foldclosed", "Functional & Misc"),
    ("foldclosedend", "Functional & Misc"),
    ("foldlevel", "Functional & Misc"),
    ("foldtext", "Functional & Misc"),
    ("foldtextresult", "Functional & Misc"),
    ("foreach", "List manipulation"),
    ("foreground", "Functional & Misc"),
    ("fullcommand", "Functional & Misc"),
    ("funcref", "Variables & Type"),
    ("function", "Variables & Type"),
    ("garbagecollect", "Variables & Type"),
    ("get", "Dictionary manipulation"),
    ("getbufinfo", "Files, Buffers & Lines"),
    ("getbufline", "Files, Buffers & Lines"),
    ("getbufoneline", "Files, Buffers & Lines"),
    ("getbufvar", "Files, Buffers & Lines"),
    ("getcellwidths", "Functional & Misc"),
    ("getchangelist", "Files, Buffers & Lines"),
    ("getchar", "Functional & Misc"),
    ("getcharmod", "Functional & Misc"),
    ("getcharpos", "Functional & Misc"),
    ("getcharsearch", "Functional & Misc"),
    ("getcharstr", "Functional & Misc"),
    ("getcmdcomplpat", "Functional & Misc"),
    ("getcmdcompltype", "Functional & Misc"),
    ("getcmdline", "Functional & Misc"),
    ("getcmdpos", "Functional & Misc"),
    ("getcmdprompt", "Functional & Misc"),
    ("getcmdscreenpos", "Functional & Misc"),
    ("getcmdtype", "Functional & Misc"),
    ("getcmdwintype", "Functional & Misc"),
    ("getcompletion", "Functional & Misc"),
    ("getcompletiontype", "Functional & Misc"),
    ("getcurpos", "Functional & Misc"),
    ("getcursorcharpos", "Functional & Misc"),
    ("getcwd", "Files, Buffers & Lines"),
    ("getenv", "System & Environment"),
    ("getfontname", "Files, Buffers & Lines"),
    ("getfperm", "Files, Buffers & Lines"),
    ("getfsize", "Files, Buffers & Lines"),
    ("getftime", "Files, Buffers & Lines"),
    ("getftype", "Files, Buffers & Lines"),
    ("getjumplist", "Functional & Misc"),
    ("getline", "Files, Buffers & Lines"),
    ("getloclist", "Functional & Misc"),
    ("getmarklist", "Functional & Misc"),
    ("getmatches", "Functional & Misc"),
    ("getmousepos", "Functional & Misc"),
    ("getpid", "System & Environment"),
    ("getpos", "Functional & Misc"),
    ("getqflist", "Functional & Misc"),
    ("getreg", "Functional & Misc"),
    ("getreginfo", "Functional & Misc"),
    ("getregion", "Functional & Misc"),
    ("getregionpos", "Functional & Misc"),
    ("getregtype", "Functional & Misc"),
    ("getscriptinfo", "Functional & Misc"),
    ("getstacktrace", "Functional & Misc"),
    ("gettabinfo", "Functional & Misc"),
    ("gettabvar", "Functional & Misc"),
    ("gettabwinvar", "Functional & Misc"),
    ("gettagstack", "Functional & Misc"),
    ("gettext", "String manipulation"),
    ("getwininfo", "Functional & Misc"),
    ("getwinpos", "Functional & Misc"),
    ("getwinposx", "Functional & Misc"),
    ("getwinposy", "Functional & Misc"),
    ("getwinvar", "Functional & Misc"),
    ("glob", "Files, Buffers & Lines"),
    ("glob2regpat", "Files, Buffers & Lines"),
    ("globpath", "Files, Buffers & Lines"),
    ("has", "Functional & Misc"),
    ("has_key", "Dictionary manipulation"),
    ("haslocaldir", "Files, Buffers & Lines"),
    ("hasmapto", "Functional & Misc"),
    ("highlight_exists", "Functional & Misc"),
    ("histadd", "Functional & Misc"),
    ("histdel", "Functional & Misc"),
    ("histget", "Functional & Misc"),
    ("histnr", "Functional & Misc"),
    ("hlID", "Functional & Misc"),
    ("hlexists", "Functional & Misc"),
    ("hostname", "System & Environment"),
    ("iconv", "String manipulation"),
    ("id", "Functional & Misc"),
    ("indent", "Files, Buffers & Lines"),
    ("index", "List manipulation"),
    ("indexof", "List manipulation"),
    ("input", "Functional & Misc"),
    ("inputdialog", "Functional & Misc"),
    ("inputlist", "Functional & Misc"),
    ("inputrestore", "Functional & Misc"),
    ("inputsave", "Functional & Misc"),
    ("inputsecret", "Functional & Misc"),
    ("insert", "List manipulation"),
    ("interrupt", "Functional & Misc"),
    ("invert", "Number & Float"),
    ("isabsolutepath", "Files, Buffers & Lines"),
    ("isdirectory", "Files, Buffers & Lines"),
    ("isinf", "Number & Float"),
    ("islocked", "Variables & Type"),
    ("isnan", "Number & Float"),
    ("items", "Dictionary manipulation"),
    ("jobpid", "System & Environment"),
    ("jobresize", "System & Environment"),
    ("jobstart", "System & Environment"),
    ("jobstop", "System & Environment"),
    ("jobwait", "System & Environment"),
    ("join", "String manipulation"),
    ("json_decode", "System & Environment"),
    ("json_encode", "System & Environment"),
    ("keys", "Dictionary manipulation"),
    ("keytrans", "String manipulation"),
    ("last_buffer_nr", "Files, Buffers & Lines"),
    ("len", "Variables & Type"),
    ("libcall", "System & Environment"),
    ("libcallnr", "System & Environment"),
    ("line", "Files, Buffers & Lines"),
    ("line2byte", "Files, Buffers & Lines"),
    ("lispindent", "Files, Buffers & Lines"),
    ("list2blob", "List manipulation"),
    ("list2str", "String manipulation"),
    ("localtime", "System & Environment"),
    ("luaeval", "System & Environment"),
    ("map", "Functional & Misc"),
    ("maparg", "Functional & Misc"),
    ("mapcheck", "Functional & Misc"),
    ("maplist", "Functional & Misc"),
    ("mapnew", "List manipulation"),
    ("mapset", "Functional & Misc"),
    ("match", "String manipulation"),
    ("matchadd", "Functional & Misc"),
    ("matchaddpos", "Functional & Misc"),
    ("matcharg", "Functional & Misc"),
    ("matchbufline", "String manipulation"),
    ("matchdelete", "Functional & Misc"),
    ("matchend", "String manipulation"),
    ("matchfuzzy", "String manipulation"),
    ("matchfuzzypos", "String manipulation"),
    ("matchlist", "String manipulation"),
    ("matchstr", "String manipulation"),
    ("matchstrlist", "String manipulation"),
    ("matchstrpos", "String manipulation"),
    ("max", "List manipulation"),
    ("menu_get", "Functional & Misc"),
    ("menu_info", "Functional & Misc"),
    ("min", "List manipulation"),
    ("mkdir", "Files, Buffers & Lines"),
    ("mode", "Functional & Misc"),
    ("msgpackdump", "System & Environment"),
    ("msgpackparse", "System & Environment"),
    ("nextnonblank", "Files, Buffers & Lines"),
    ("nr2char", "String manipulation"),
    ("or", "Number & Float"),
    ("pathshorten", "Files, Buffers & Lines"),
    ("perleval", "System & Environment"),
    ("pow", "Number & Float"),
    ("preinserted", "Functional & Misc"),
    ("prevnonblank", "Files, Buffers & Lines"),
    ("printf", "String manipulation"),
    ("prompt_appendbuf", "Functional & Misc"),
    ("prompt_getinput", "Functional & Misc"),
    ("prompt_getprompt", "Functional & Misc"),
    ("prompt_setcallback", "Functional & Misc"),
    ("prompt_setinterrupt", "Functional & Misc"),
    ("prompt_setprompt", "Functional & Misc"),
    ("pum_getpos", "Functional & Misc"),
    ("pumvisible", "Functional & Misc"),
    ("py3eval", "System & Environment"),
    ("pyeval", "System & Environment"),
    ("pyxeval", "System & Environment"),
    ("rand", "Number & Float"),
    ("range", "List manipulation"),
    ("readblob", "Files, Buffers & Lines"),
    ("readdir", "Files, Buffers & Lines"),
    ("readfile", "Files, Buffers & Lines"),
    ("reduce", "List manipulation"),
    ("reg_executing", "Functional & Misc"),
    ("reg_recorded", "Functional & Misc"),
    ("reg_recording", "Functional & Misc"),
    ("reltime", "System & Environment"),
    ("reltimefloat", "System & Environment"),
    ("reltimestr", "System & Environment"),
    ("remove", "List manipulation"),
    ("rename", "Files, Buffers & Lines"),
    ("repeat", "String manipulation"),
    ("resolve", "Files, Buffers & Lines"),
    ("reverse", "List manipulation"),
    ("rpcnotify", "System & Environment"),
    ("rpcrequest", "System & Environment"),
    ("rpcstart", "System & Environment"),
    ("rpcstop", "System & Environment"),
    ("rubyeval", "System & Environment"),
    ("screenattr", "Functional & Misc"),
    ("screenchar", "Functional & Misc"),
    ("screenchars", "Functional & Misc"),
    ("screencol", "Functional & Misc"),
    ("screenpos", "Functional & Misc"),
    ("screenrow", "Functional & Misc"),
    ("screenstring", "Functional & Misc"),
    ("search", "Functional & Misc"),
    ("searchcount", "Functional & Misc"),
    ("searchdecl", "Functional & Misc"),
    ("searchpair", "Functional & Misc"),
    ("searchpairpos", "Functional & Misc"),
    ("searchpos", "Functional & Misc"),
    ("serverlist", "System & Environment"),
    ("serverstart", "System & Environment"),
    ("serverstop", "System & Environment"),
    ("setbufline", "Files, Buffers & Lines"),
    ("setbufvar", "Files, Buffers & Lines"),
    ("setcellwidths", "Functional & Misc"),
    ("setcharpos", "Functional & Misc"),
    ("setcharsearch", "Functional & Misc"),
    ("setcmdline", "Functional & Misc"),
    ("setcmdpos", "Functional & Misc"),
    ("setcursorcharpos", "Functional & Misc"),
    ("setenv", "System & Environment"),
    ("setfperm", "Files, Buffers & Lines"),
    ("setline", "Files, Buffers & Lines"),
    ("setloclist", "Functional & Misc"),
    ("setmatches", "Functional & Misc"),
    ("setpos", "Functional & Misc"),
    ("setqflist", "Functional & Misc"),
    ("setreg", "Functional & Misc"),
    ("settabvar", "Functional & Misc"),
    ("settabwinvar", "Functional & Misc"),
    ("settagstack", "Functional & Misc"),
    ("setwinvar", "Functional & Misc"),
    ("sha256", "String manipulation"),
    ("shellescape", "String manipulation"),
    ("shiftwidth", "Functional & Misc"),
    ("sign_define", "Functional & Misc"),
    ("sign_getdefined", "Functional & Misc"),
    ("sign_getplaced", "Functional & Misc"),
    ("sign_jump", "Functional & Misc"),
    ("sign_place", "Functional & Misc"),
    ("sign_placelist", "Functional & Misc"),
    ("sign_undefine", "Functional & Misc"),
    ("sign_unplace", "Functional & Misc"),
    ("sign_unplacelist", "Functional & Misc"),
    ("simplify", "Files, Buffers & Lines"),
    ("slice", "List manipulation"),
    ("sockconnect", "System & Environment"),
    ("sort", "List manipulation"),
    ("soundfold", "String manipulation"),
    ("spellbadword", "Functional & Misc"),
    ("spellsuggest", "Functional & Misc"),
    ("split", "String manipulation"),
    ("srand", "Number & Float"),
    ("state", "Functional & Misc"),
    ("stdioopen", "System & Environment"),
    ("stdpath", "System & Environment"),
    ("str2float", "String manipulation"),
    ("str2list", "String manipulation"),
    ("str2nr", "String manipulation"),
    ("strcharlen", "String manipulation"),
    ("strcharpart", "String manipulation"),
    ("strchars", "String manipulation"),
    ("strdisplaywidth", "String manipulation"),
    ("strftime", "System & Environment"),
    ("strgetchar", "String manipulation"),
    ("stridx", "String manipulation"),
    ("string", "String manipulation"),
    ("strlen", "String manipulation"),
    ("strpart", "String manipulation"),
    ("strptime", "System & Environment"),
    ("strridx", "String manipulation"),
    ("strtrans", "String manipulation"),
    ("strutf16len", "String manipulation"),
    ("strwidth", "String manipulation"),
    ("submatch", "String manipulation"),
    ("substitute", "String manipulation"),
    ("swapfilelist", "Files, Buffers & Lines"),
    ("swapinfo", "Files, Buffers & Lines"),
    ("swapname", "Files, Buffers & Lines"),
    ("synID", "Functional & Misc"),
    ("synIDattr", "Functional & Misc"),
    ("synIDtrans", "Functional & Misc"),
    ("synconcealed", "Functional & Misc"),
    ("synstack", "Functional & Misc"),
    ("system", "System & Environment"),
    ("systemlist", "System & Environment"),
    ("tabpagebuflist", "Functional & Misc"),
    ("tabpagenr", "Functional & Misc"),
    ("tabpagewinnr", "Functional & Misc"),
    ("tagfiles", "Functional & Misc"),
    ("taglist", "Functional & Misc"),
    ("tempname", "Files, Buffers & Lines"),
    ("termopen", "System & Environment"),
    ("test_garbagecollect_now", "Functional & Misc"),
    ("test_write_list_log", "Functional & Misc"),
    ("timer_info", "Functional & Misc"),
    ("timer_pause", "Functional & Misc"),
    ("timer_start", "Functional & Misc"),
    ("timer_stop", "Functional & Misc"),
    ("timer_stopall", "Functional & Misc"),
    ("tolower", "String manipulation"),
    ("toupper", "String manipulation"),
    ("tr", "String manipulation"),
    ("trim", "String manipulation"),
    ("type", "Variables & Type"),
    ("undofile", "Files, Buffers & Lines"),
    ("undotree", "Files, Buffers & Lines"),
    ("uniq", "List manipulation"),
    ("utf16idx", "String manipulation"),
    ("values", "Dictionary manipulation"),
    ("virtcol", "Files, Buffers & Lines"),
    ("virtcol2col", "Files, Buffers & Lines"),
    ("visualmode", "Functional & Misc"),
    ("wait", "Functional & Misc"),
    ("wildmenumode", "Functional & Misc"),
    ("wildtrigger", "Functional & Misc"),
    ("win_execute", "Functional & Misc"),
    ("win_findbuf", "Functional & Misc"),
    ("win_getid", "Functional & Misc"),
    ("win_gettype", "Functional & Misc"),
    ("win_gotoid", "Functional & Misc"),
    ("win_id2tabwin", "Functional & Misc"),
    ("win_id2win", "Functional & Misc"),
    ("win_move_separator", "Functional & Misc"),
    ("win_move_statusline", "Functional & Misc"),
    ("win_screenpos", "Functional & Misc"),
    ("win_splitmove", "Functional & Misc"),
    ("winbufnr", "Files, Buffers & Lines"),
    ("wincol", "Functional & Misc"),
    ("windowsversion", "System & Environment"),
    ("winheight", "Functional & Misc"),
    ("winlayout", "Functional & Misc"),
    ("winline", "Functional & Misc"),
    ("winnr", "Functional & Misc"),
    ("winrestcmd", "Functional & Misc"),
    ("winrestview", "Functional & Misc"),
    ("winsaveview", "Functional & Misc"),
    ("winwidth", "Functional & Misc"),
    ("wordcount", "Functional & Misc"),
    ("writefile", "Files, Buffers & Lines"),
    ("xor", "Number & Float"),
];

/// Ordered category chapters for the reference page. Builtins are grouped into
/// these in order; any uncategorized implemented builtin lands in
/// "Functional & Misc" (the catch-all) and is never dropped.
pub const BUILTIN_CHAPTERS: &[&str] = &[
    "String manipulation",
    "List manipulation",
    "Dictionary manipulation",
    "Variables & Type",
    "Number & Float",
    "Files, Buffers & Lines",
    "System & Environment",
    "Functional & Misc",
];

/// Ex-command words the Phase-3 statement parser recognizes: `(name, doc)`.
pub const EX_COMMANDS: &[(&str, &str)] = &[
    (
        "echo",
        ":echo {expr} — evaluate and display {expr} (space-separated).",
    ),
    (
        "echon",
        ":echon {expr} — like :echo but without a trailing newline.",
    ),
    (
        "echomsg",
        ":echomsg {expr} — display {expr} and save it in the message history.",
    ),
    (
        "let",
        ":let {var} = {expr} — assign the value of {expr} to {var}.",
    ),
    (
        "call",
        ":call {func}({args}) — call a function and discard its return value.",
    ),
    (
        "eval",
        ":eval {expr} — evaluate {expr} for its side effects.",
    ),
];

/// Predefined `v:` constants: `(name, doc)`.
pub const V_VARS: &[(&str, &str)] = &[
    (
        "v:true",
        "Boolean true; numeric value 1, string value \"v:true\".",
    ),
    (
        "v:false",
        "Boolean false; numeric value 0, string value \"v:false\".",
    ),
    (
        "v:null",
        "Null value; behaves like an empty string in most contexts.",
    ),
];

/// Supported `:set` options: `(canonical, abbreviation, kind, default, doc)`.
pub const OPTION_DOCS: &[(&str, &str, &str, i64, &str)] = &[
    (
        "ignorecase",
        "ic",
        "Bool",
        0,
        "Ignore case in search patterns.",
    ),
    (
        "smartcase",
        "scs",
        "Bool",
        0,
        "Override 'ignorecase' when the pattern has uppercase letters.",
    ),
    (
        "magic",
        "magic",
        "Bool",
        1,
        "Use 'magic' regexp special-character meanings.",
    ),
    (
        "expandtab",
        "et",
        "Bool",
        0,
        "Insert spaces instead of a <Tab>.",
    ),
    (
        "number",
        "nu",
        "Bool",
        0,
        "Show line numbers in the left margin.",
    ),
    (
        "relativenumber",
        "rnu",
        "Bool",
        0,
        "Show line numbers relative to the cursor.",
    ),
    (
        "wrap",
        "wrap",
        "Bool",
        1,
        "Wrap long lines to fit the window width.",
    ),
    (
        "hlsearch",
        "hls",
        "Bool",
        0,
        "Highlight all matches of the last search pattern.",
    ),
    (
        "incsearch",
        "is",
        "Bool",
        0,
        "Show the match for the search pattern as it is typed.",
    ),
    (
        "autoindent",
        "ai",
        "Bool",
        0,
        "Copy the indent of the current line to a new line.",
    ),
    (
        "tabstop",
        "ts",
        "Number",
        8,
        "Number of spaces a <Tab> counts for.",
    ),
    (
        "shiftwidth",
        "sw",
        "Number",
        8,
        "Number of spaces used for each step of (auto)indent.",
    ),
    (
        "softtabstop",
        "sts",
        "Number",
        0,
        "Number of spaces a <Tab> counts for while editing.",
    ),
    (
        "textwidth",
        "tw",
        "Number",
        0,
        "Maximum text width; longer lines are broken (0 = off).",
    ),
    (
        "scrolloff",
        "so",
        "Number",
        0,
        "Minimum lines kept above and below the cursor.",
    ),
];

/// Look up the hover doc for `name`, formatting it as the LSP markdown body:
/// a fenced `vim` signature block followed by the one-line description.
pub fn hover_markdown(name: &str) -> Option<String> {
    if let Some((_, sig, doc)) = BUILTIN_DOCS.iter().find(|(n, _, _)| *n == name) {
        return Some(format!("```vim\n{sig}\n```\n\n{doc}"));
    }
    if let Some((_, doc)) = EX_COMMANDS.iter().find(|(n, _)| *n == name) {
        return Some((*doc).to_string());
    }
    if let Some((_, doc)) = V_VARS.iter().find(|(n, _)| *n == name) {
        return Some((*doc).to_string());
    }
    None
}

/// Chapter for `name`, defaulting to the "Functional & Misc" catch-all.
pub fn category_of(name: &str) -> &'static str {
    BUILTIN_CATEGORY
        .iter()
        .find(|(n, _)| *n == name)
        .map(|(_, c)| *c)
        .unwrap_or("Functional & Misc")
}