├── README.md ├── import ├── vim9Language.vim └── vim9SyntaxUtil.vim ├── syntax └── vim.vim └── tools ├── GenerateImport.vim └── README.md /README.md: -------------------------------------------------------------------------------- 1 | Syntax plugin for Vim9. Work in progress. 2 | 3 | # Configuration 4 | 5 | The highlighting can be controlled via keys in the dictionary `g:vim9_syntax`: 6 | 7 | - `builtin_functions` controls whether builtin functions are highlighted (`true` by default) 8 | - `data_types` controls whether Vim9 data types in declarations are highlighted (`true` by default) 9 | - `user_types` controls whether user types are highlighted (`:help :type`; `false` by default) 10 | - `errors` controls whether some possible mistakes are highlighted 11 | - `fenced_languages` is a list of languages which should be highlighted with their own syntax when included inside fenced codeblocks (empty list by default) 12 | 13 | `g:vim9_syntax.errors` is a nested dictionary containing these keys: 14 | 15 | - `event_wrong_case` controls whether names of events in autocmds are highlighted as errors, if they don't have the same case as in the help (`false` by default) 16 | - `octal_missing_o_prefix` controls whether an octal number prefixed with `0` instead of `0o` is highlighted as an error (`false` by default) 17 | - `range_missing_space` controls whether no space between a line specifier and a command is highlighted as an error (`false` by default) 18 | - `range_missing_specifier` controls whether an implicit line specifier is highlighted as an error (`false` by default) 19 | - `strict_whitespace` controls whether missing/superfluous whitespace is highlighted as an error (`true` by default) 20 | 21 | Example of configuration: 22 | 23 | g:vim9_syntax = { 24 | builtin_functions: true, 25 | data_types: false, 26 | user_types: false, 27 | fenced_languages: ['lua', 'python'], 28 | errors: { 29 | event_wrong_case: false, 30 | octal_missing_o_prefix: false, 31 | range_missing_space: false, 32 | range_missing_specifier: false, 33 | strict_whitespace: true, 34 | } 35 | } 36 | 37 | # Requirements 38 | 39 | A recent Vim version. 40 | 41 | # Installation 42 | ## Linux 43 | 44 | Run this shell command: 45 | 46 | git clone https://github.com/lacygoill/vim9-syntax.git ~/.vim/pack/vim9-syntax/opt/vim9-syntax 47 | 48 | Then, add this line in your vimrc: 49 | 50 | packadd! vim9-syntax 51 | 52 | ## Windows 53 | 54 | Run this shell command: 55 | 56 | git clone https://github.com/lacygoill/vim9-syntax.git %USERPROFILE%\vimfiles\pack\vim9-syntax\opt\vim9-syntax 57 | 58 | Then, add this line in your vimrc: 59 | 60 | packadd! vim9-syntax 61 | 62 | -------------------------------------------------------------------------------- /import/vim9Language.vim: -------------------------------------------------------------------------------- 1 | vim9script 2 | 3 | # DO NOT EDIT THIS FILE DIRECTLY. 4 | # It is meant to be generated by ./tools/GenerateImport.vim 5 | 6 | # builtin_func {{{1 7 | 8 | const builtin_func_list: list =<< trim END 9 | abs 10 | acos 11 | add 12 | and 13 | appendbufline 14 | argc 15 | argidx 16 | arglistid 17 | argv 18 | asin 19 | assert_beeps 20 | assert_equal 21 | assert_equalfile 22 | assert_exception 23 | assert_fails 24 | assert_false 25 | assert_inrange 26 | assert_match 27 | assert_nobeep 28 | assert_notequal 29 | assert_notmatch 30 | assert_report 31 | assert_true 32 | atan 33 | atan2 34 | autocmd_add 35 | autocmd_delete 36 | autocmd_get 37 | balloon_gettext 38 | balloon_show 39 | balloon_split 40 | blob2list 41 | browsedir 42 | bufadd 43 | bufexists 44 | buffer_exists 45 | buffer_name 46 | buffer_number 47 | buflisted 48 | bufload 49 | bufloaded 50 | bufname 51 | bufnr 52 | bufwinid 53 | bufwinnr 54 | byte2line 55 | byteidx 56 | byteidxcomp 57 | ceil 58 | ch_canread 59 | ch_close 60 | ch_close_in 61 | ch_evalexpr 62 | ch_evalraw 63 | ch_getbufnr 64 | ch_getjob 65 | ch_info 66 | ch_log 67 | ch_logfile 68 | ch_open 69 | ch_read 70 | ch_readblob 71 | ch_readraw 72 | ch_sendexpr 73 | ch_sendraw 74 | ch_setoptions 75 | ch_status 76 | changenr 77 | char2nr 78 | charclass 79 | charcol 80 | charidx 81 | cindent 82 | clearmatches 83 | col 84 | complete 85 | complete_add 86 | complete_check 87 | complete_info 88 | cos 89 | cosh 90 | count 91 | cscope_connection 92 | cursor 93 | deepcopy 94 | deletebufline 95 | did_filetype 96 | diff_filler 97 | diff_hlID 98 | digraph_get 99 | digraph_getlist 100 | digraph_set 101 | digraph_setlist 102 | echoraw 103 | empty 104 | environ 105 | err_teapot 106 | escape 107 | eventhandler 108 | executable 109 | exepath 110 | exists 111 | exists_compiled 112 | exp 113 | expand 114 | expandcmd 115 | extend 116 | extendnew 117 | feedkeys 118 | file_readable 119 | filereadable 120 | filewritable 121 | finddir 122 | findfile 123 | flatten 124 | flattennew 125 | float2nr 126 | floor 127 | fmod 128 | fnameescape 129 | fnamemodify 130 | foldclosed 131 | foldclosedend 132 | foldlevel 133 | foldtext 134 | foldtextresult 135 | foreground 136 | fullcommand 137 | funcref 138 | garbagecollect 139 | get 140 | getbufinfo 141 | getbufline 142 | getbufoneline 143 | getbufvar 144 | getcellwidths 145 | getchangelist 146 | getchar 147 | getcharmod 148 | getcharpos 149 | getcharsearch 150 | getcharstr 151 | getcmdcompltype 152 | getcmdline 153 | getcmdpos 154 | getcmdscreenpos 155 | getcmdtype 156 | getcmdwintype 157 | getcompletion 158 | getcurpos 159 | getcursorcharpos 160 | getcwd 161 | getenv 162 | getfontname 163 | getfperm 164 | getfsize 165 | getftime 166 | getftype 167 | getimstatus 168 | getjumplist 169 | getline 170 | getloclist 171 | getmarklist 172 | getmatches 173 | getmousepos 174 | getmouseshape 175 | getpid 176 | getpos 177 | getqflist 178 | getreg 179 | getreginfo 180 | getregtype 181 | getscriptinfo 182 | gettabinfo 183 | gettabvar 184 | gettabwinvar 185 | gettagstack 186 | gettext 187 | getwininfo 188 | getwinpos 189 | getwinposx 190 | getwinposy 191 | getwinvar 192 | glob 193 | glob2regpat 194 | globpath 195 | has 196 | has_key 197 | haslocaldir 198 | hasmapto 199 | highlightID 200 | highlight_exists 201 | histadd 202 | histdel 203 | histget 204 | histnr 205 | hlID 206 | hlexists 207 | hlget 208 | hlset 209 | hostname 210 | iconv 211 | indent 212 | index 213 | indexof 214 | input 215 | inputdialog 216 | inputlist 217 | inputrestore 218 | inputsave 219 | inputsecret 220 | instanceof 221 | interrupt 222 | invert 223 | isabsolutepath 224 | isdirectory 225 | isinf 226 | islocked 227 | isnan 228 | items 229 | job_getchannel 230 | job_info 231 | job_setoptions 232 | job_start 233 | job_status 234 | job_stop 235 | js_decode 236 | js_encode 237 | json_decode 238 | json_encode 239 | keys 240 | keytrans 241 | last_buffer_nr 242 | len 243 | libcall 244 | libcallnr 245 | line 246 | line2byte 247 | lispindent 248 | list2blob 249 | list2str 250 | listener_add 251 | listener_flush 252 | listener_remove 253 | localtime 254 | log 255 | log10 256 | maparg 257 | mapcheck 258 | maplist 259 | mapnew 260 | mapset 261 | matchadd 262 | matchaddpos 263 | matcharg 264 | matchdelete 265 | matchend 266 | matchfuzzy 267 | matchfuzzypos 268 | matchlist 269 | matchstr 270 | matchstrpos 271 | max 272 | menu_info 273 | min 274 | mkdir 275 | nextnonblank 276 | nr2char 277 | or 278 | pathshorten 279 | popup_atcursor 280 | popup_beval 281 | popup_clear 282 | popup_close 283 | popup_create 284 | popup_dialog 285 | popup_filter_menu 286 | popup_filter_yesno 287 | popup_findecho 288 | popup_findinfo 289 | popup_findpreview 290 | popup_getoptions 291 | popup_getpos 292 | popup_hide 293 | popup_list 294 | popup_locate 295 | popup_menu 296 | popup_move 297 | popup_notification 298 | popup_setoptions 299 | popup_settext 300 | popup_show 301 | pow 302 | prevnonblank 303 | printf 304 | prompt_getprompt 305 | prompt_setcallback 306 | prompt_setinterrupt 307 | prompt_setprompt 308 | prop_add 309 | prop_add_list 310 | prop_clear 311 | prop_find 312 | prop_list 313 | prop_remove 314 | prop_type_add 315 | prop_type_change 316 | prop_type_delete 317 | prop_type_get 318 | prop_type_list 319 | pum_getpos 320 | pumvisible 321 | py3eval 322 | pyxeval 323 | rand 324 | range 325 | readblob 326 | readdir 327 | readdirex 328 | readfile 329 | reduce 330 | reg_executing 331 | reg_recording 332 | reltime 333 | reltimefloat 334 | reltimestr 335 | remote_expr 336 | remote_foreground 337 | remote_peek 338 | remote_read 339 | remote_send 340 | remote_startserver 341 | remove 342 | rename 343 | repeat 344 | resolve 345 | reverse 346 | round 347 | screenattr 348 | screenchar 349 | screenchars 350 | screencol 351 | screenpos 352 | screenrow 353 | screenstring 354 | search 355 | searchcount 356 | searchdecl 357 | searchpair 358 | searchpairpos 359 | searchpos 360 | server2client 361 | serverlist 362 | setbufline 363 | setbufvar 364 | setcellwidths 365 | setcharpos 366 | setcharsearch 367 | setcmdline 368 | setcmdpos 369 | setcursorcharpos 370 | setenv 371 | setfperm 372 | setline 373 | setloclist 374 | setmatches 375 | setpos 376 | setqflist 377 | setreg 378 | settabvar 379 | settabwinvar 380 | settagstack 381 | setwinvar 382 | sha256 383 | shellescape 384 | shiftwidth 385 | sign_define 386 | sign_getdefined 387 | sign_getplaced 388 | sign_jump 389 | sign_place 390 | sign_placelist 391 | sign_undefine 392 | sign_unplace 393 | sign_unplacelist 394 | simplify 395 | sin 396 | sinh 397 | slice 398 | sound_clear 399 | sound_playevent 400 | sound_playfile 401 | sound_stop 402 | soundfold 403 | spellbadword 404 | spellsuggest 405 | sqrt 406 | srand 407 | state 408 | str2float 409 | str2list 410 | str2nr 411 | strcharlen 412 | strcharpart 413 | strchars 414 | strdisplaywidth 415 | strftime 416 | strgetchar 417 | stridx 418 | string 419 | strlen 420 | strpart 421 | strptime 422 | strridx 423 | strtrans 424 | strutf16len 425 | strwidth 426 | submatch 427 | swapfilelist 428 | swapinfo 429 | synID 430 | synIDattr 431 | synIDtrans 432 | synconcealed 433 | synstack 434 | system 435 | systemlist 436 | tabpagebuflist 437 | tabpagenr 438 | tabpagewinnr 439 | tagfiles 440 | taglist 441 | tan 442 | tanh 443 | tempname 444 | term_dumpdiff 445 | term_dumpload 446 | term_dumpwrite 447 | term_getaltscreen 448 | term_getansicolors 449 | term_getattr 450 | term_getcursor 451 | term_getjob 452 | term_getline 453 | term_getscrolled 454 | term_getsize 455 | term_getstatus 456 | term_gettitle 457 | term_gettty 458 | term_list 459 | term_scrape 460 | term_sendkeys 461 | term_setansicolors 462 | term_setapi 463 | term_setkill 464 | term_setrestore 465 | term_setsize 466 | term_start 467 | term_wait 468 | terminalprops 469 | test_alloc_fail 470 | test_autochdir 471 | test_feedinput 472 | test_garbagecollect_now 473 | test_garbagecollect_soon 474 | test_getvalue 475 | test_gui_event 476 | test_ignore_error 477 | test_mswin_event 478 | test_null_blob 479 | test_null_channel 480 | test_null_dict 481 | test_null_function 482 | test_null_job 483 | test_null_list 484 | test_null_partial 485 | test_null_string 486 | test_option_not_set 487 | test_override 488 | test_refcount 489 | test_setmouse 490 | test_settime 491 | test_srand_seed 492 | test_unknown 493 | test_void 494 | timer_info 495 | timer_pause 496 | timer_start 497 | timer_stop 498 | timer_stopall 499 | tolower 500 | toupper 501 | tr 502 | trim 503 | trunc 504 | typename 505 | undofile 506 | undotree 507 | uniq 508 | utf16idx 509 | values 510 | virtcol 511 | virtcol2col 512 | visualmode 513 | wildmenumode 514 | win_execute 515 | win_findbuf 516 | win_getid 517 | win_gettype 518 | win_gotoid 519 | win_id2tabwin 520 | win_id2win 521 | win_move_separator 522 | win_move_statusline 523 | win_screenpos 524 | win_splitmove 525 | winbufnr 526 | wincol 527 | windowsversion 528 | winheight 529 | winlayout 530 | winline 531 | winnr 532 | winrestcmd 533 | winrestview 534 | winsaveview 535 | winwidth 536 | wordcount 537 | writefile 538 | xor 539 | debugbreak 540 | luaeval 541 | mzeval 542 | perleval 543 | pyeval 544 | rubyeval 545 | END 546 | 547 | export const builtin_func: string = builtin_func_list->join() 548 | 549 | # builtin_func_ambiguous {{{1 550 | 551 | const builtin_func_ambiguous_list: list =<< trim END 552 | append 553 | browse 554 | call 555 | chdir 556 | confirm 557 | copy 558 | delete 559 | eval 560 | execute 561 | filter 562 | function 563 | insert 564 | join 565 | map 566 | match 567 | mode 568 | sort 569 | split 570 | substitute 571 | swapname 572 | type 573 | END 574 | 575 | export const builtin_func_ambiguous: string = builtin_func_ambiguous_list->join("\\|") 576 | 577 | # collation_class {{{1 578 | 579 | const collation_class_list: list =<< trim END 580 | alnum 581 | alpha 582 | backspace 583 | blank 584 | cntrl 585 | digit 586 | escape 587 | fname 588 | graph 589 | ident 590 | keyword 591 | lower 592 | print 593 | punct 594 | return 595 | space 596 | tab 597 | upper 598 | xdigit 599 | END 600 | 601 | export const collation_class: string = collation_class_list->join("\\|") 602 | 603 | # command_address_type {{{1 604 | 605 | const command_address_type_list: list =<< trim END 606 | arguments 607 | buffers 608 | lines 609 | loaded_buffers 610 | other 611 | quickfix 612 | tabs 613 | windows 614 | END 615 | 616 | export const command_address_type: string = command_address_type_list->join("\\|") 617 | 618 | # command_can_be_before {{{1 619 | 620 | export const command_can_be_before: string = '\%([ \t\n]\@=\|\c<\%(bar\|cr\)>\)\%(\s*\%([-+*/%]=\|=\s\|=<<\|\.\.=\)\|\_s*\%(->\|[-+*/%]\%(\s\+\)\@>[^|<]\)\)\@!' 621 | 622 | # command_complete_type {{{1 623 | 624 | const command_complete_type_list: list =<< trim END 625 | arglist 626 | augroup 627 | behave 628 | breakpoint 629 | buffer 630 | color 631 | command 632 | compiler 633 | cscope 634 | customlist 635 | custom 636 | diff_buffer 637 | dir 638 | environment 639 | event 640 | expression 641 | file_in_path 642 | filetype 643 | file 644 | function 645 | help 646 | highlight 647 | history 648 | locale 649 | mapclear 650 | mapping 651 | menu 652 | messages 653 | option 654 | packadd 655 | runtime 656 | scriptnames 657 | shellcmd 658 | sign 659 | syntax 660 | syntime 661 | tag_listfiles 662 | tag 663 | user 664 | var 665 | END 666 | 667 | export const command_complete_type: string = command_complete_type_list->join("\\|") 668 | 669 | # command_modifier {{{1 670 | 671 | const command_modifier_list: list =<< trim END 672 | abo\%[veleft] 673 | bel\%[owright] 674 | bo\%[tright] 675 | bro\%[wse] 676 | conf\%[irm] 677 | hid\%[e] 678 | keepa\%[lt] 679 | keepj\%[umps] 680 | ke\%[epmarks] 681 | keepp\%[atterns] 682 | lefta\%[bove] 683 | leg\%[acy] 684 | loc\%[kmarks] 685 | noa\%[utocmd] 686 | nos\%[wapfile] 687 | rightb\%[elow] 688 | san\%[dbox] 689 | sil\%[ent] 690 | tab 691 | to\%[pleft] 692 | uns\%[ilent] 693 | verb\%[ose] 694 | vert\%[ical] 695 | vim9\%[cmd] 696 | END 697 | 698 | export const command_modifier: string = command_modifier_list->join("\\|") 699 | 700 | # command_name {{{1 701 | 702 | const command_name_list: list =<< trim END 703 | al[l] 704 | am[enu] 705 | an[oremenu] 706 | arga[dd] 707 | argded[upe] 708 | argd[elete] 709 | arge[dit] 710 | argg[lobal] 711 | argl[ocal] 712 | ar[gs] 713 | argu[ment] 714 | as[cii] 715 | aun[menu] 716 | bN[ext] 717 | bad[d] 718 | ba[ll] 719 | balt 720 | bd[elete] 721 | be[have] 722 | bf[irst] 723 | bl[ast] 724 | bm[odified] 725 | bn[ext] 726 | bp[revious] 727 | breaka[dd] 728 | breakd[el] 729 | breakl[ist] 730 | br[ewind] 731 | b[uffer] 732 | buffers 733 | bun[load] 734 | bw[ipeout] 735 | cN[ext] 736 | cNf[ile] 737 | cabo[ve] 738 | cad[dbuffer] 739 | cadde[xpr] 740 | caddf[ile] 741 | caf[ter] 742 | cal[l] 743 | cbe[fore] 744 | cbel[ow] 745 | cbo[ttom] 746 | cb[uffer] 747 | cc 748 | ccl[ose] 749 | ce[nter] 750 | cex[pr] 751 | cf[ile] 752 | cfir[st] 753 | cgetb[uffer] 754 | cgete[xpr] 755 | cg[etfile] 756 | changes 757 | che[ckpath] 758 | checkt[ime] 759 | chi[story] 760 | cla[st] 761 | cle[arjumps] 762 | cl[ist] 763 | clo[se] 764 | cme[nu] 765 | cnew[er] 766 | cn[ext] 767 | cnf[ile] 768 | cnoreme[nu] 769 | col[der] 770 | colo[rscheme] 771 | comc[lear] 772 | comp[iler] 773 | cope[n] 774 | cpf[ile] 775 | cp[revious] 776 | cq[uit] 777 | cr[ewind] 778 | cs[cope] 779 | cst[ag] 780 | cunme[nu] 781 | cw[indow] 782 | deb[ug] 783 | debugg[reedy] 784 | def 785 | defc[ompile] 786 | defe[r] 787 | delc[ommand] 788 | d[elete] 789 | delf[unction] 790 | delm[arks] 791 | diffg[et] 792 | diffo[ff] 793 | diffp[atch] 794 | diffpu[t] 795 | diffs[plit] 796 | difft[his] 797 | dif[fupdate] 798 | disa[ssemble] 799 | di[splay] 800 | dj[ump] 801 | dl[ist] 802 | dr[op] 803 | ds[earch] 804 | dsp[lit] 805 | ea[rlier] 806 | ec[ho] 807 | echoc[onsole] 808 | echoe[rr] 809 | echom[sg] 810 | echon 811 | echow[indow] 812 | e[dit] 813 | em[enu] 814 | enddef 815 | endf[unction] 816 | ene[w] 817 | ev[al] 818 | ex 819 | exe[cute] 820 | exi[t] 821 | exu[sage] 822 | f[ile] 823 | files 824 | filt[er] 825 | fin[d] 826 | fir[st] 827 | fix[del] 828 | fo[ld] 829 | foldc[lose] 830 | folddoc[losed] 831 | foldd[oopen] 832 | foldo[pen] 833 | fu[nction] 834 | go[to] 835 | gr[ep] 836 | grepa[dd] 837 | gu[i] 838 | gv[im] 839 | ha[rdcopy] 840 | h[elp] 841 | helpc[lose] 842 | helpf[ind] 843 | helpg[rep] 844 | helpt[ags] 845 | his[tory] 846 | ho[rizontal] 847 | ij[ump] 848 | il[ist] 849 | ime[nu] 850 | inoreme[nu] 851 | int[ro] 852 | is[earch] 853 | isp[lit] 854 | iunme[nu] 855 | j[oin] 856 | ju[mps] 857 | lN[ext] 858 | lNf[ile] 859 | lab[ove] 860 | laddb[uffer] 861 | lad[dexpr] 862 | laddf[ile] 863 | laf[ter] 864 | lan[guage] 865 | la[st] 866 | lat[er] 867 | lbe[fore] 868 | lbel[ow] 869 | lbo[ttom] 870 | lb[uffer] 871 | lcl[ose] 872 | lcs[cope] 873 | le[ft] 874 | lex[pr] 875 | lf[ile] 876 | lfir[st] 877 | lgetb[uffer] 878 | lgete[xpr] 879 | lg[etfile] 880 | lgr[ep] 881 | lgrepa[dd] 882 | lh[elpgrep] 883 | lhi[story] 884 | l[ist] 885 | ll 886 | lla[st] 887 | lli[st] 888 | lmak[e] 889 | lnew[er] 890 | lne[xt] 891 | lnf[ile] 892 | loadk[eymap] 893 | lo[adview] 894 | lockv[ar] 895 | lol[der] 896 | lop[en] 897 | lpf[ile] 898 | lp[revious] 899 | lr[ewind] 900 | ls 901 | lt[ag] 902 | luad[o] 903 | luaf[ile] 904 | lw[indow] 905 | mak[e] 906 | marks 907 | mat[ch] 908 | me[nu] 909 | menut[ranslate] 910 | mes[sages] 911 | mk[exrc] 912 | mks[ession] 913 | mksp[ell] 914 | mkvie[w] 915 | mkv[imrc] 916 | mzf[ile] 917 | mz[scheme] 918 | nbc[lose] 919 | nb[key] 920 | nbs[tart] 921 | new 922 | n[ext] 923 | nme[nu] 924 | nnoreme[nu] 925 | noh[lsearch] 926 | noreme[nu] 927 | nu[mber] 928 | nunme[nu] 929 | ol[dfiles] 930 | ome[nu] 931 | on[ly] 932 | onoreme[nu] 933 | opt[ions] 934 | ounme[nu] 935 | ow[nsyntax] 936 | pa[ckadd] 937 | packl[oadall] 938 | pc[lose] 939 | ped[it] 940 | pe[rl] 941 | perld[o] 942 | po[p] 943 | popu[p] 944 | pp[op] 945 | pre[serve] 946 | prev[ious] 947 | p[rint] 948 | profd[el] 949 | prof[ile] 950 | pro[mptfind] 951 | promptr[epl] 952 | ps[earch] 953 | ptN[ext] 954 | pt[ag] 955 | ptf[irst] 956 | ptj[ump] 957 | ptl[ast] 958 | ptn[ext] 959 | ptp[revious] 960 | ptr[ewind] 961 | pts[elect] 962 | pu[t] 963 | pw[d] 964 | py3 965 | py3d[o] 966 | py3f[ile] 967 | pyd[o] 968 | pyf[ile] 969 | pyx 970 | pyxd[o] 971 | pyxf[ile] 972 | qa[ll] 973 | q[uit] 974 | quita[ll] 975 | r[ead] 976 | rec[over] 977 | redi[r] 978 | red[o] 979 | redr[aw] 980 | redraws[tatus] 981 | redrawt[abline] 982 | reg[isters] 983 | res[ize] 984 | ret[ab] 985 | rew[ind] 986 | ri[ght] 987 | rub[y] 988 | rubyd[o] 989 | rubyf[ile] 990 | rund[o] 991 | ru[ntime] 992 | rv[iminfo] 993 | sN[ext] 994 | sal[l] 995 | sa[rgument] 996 | sav[eas] 997 | sbN[ext] 998 | sba[ll] 999 | sbf[irst] 1000 | sbl[ast] 1001 | sbm[odified] 1002 | sbn[ext] 1003 | sbp[revious] 1004 | sbr[ewind] 1005 | sb[uffer] 1006 | scripte[ncoding] 1007 | sc[riptnames] 1008 | scriptv[ersion] 1009 | scs[cope] 1010 | setf[iletype] 1011 | sf[ind] 1012 | sfir[st] 1013 | sh[ell] 1014 | sig[n] 1015 | si[malt] 1016 | sla[st] 1017 | sl[eep] 1018 | sm[agic] 1019 | sme[nu] 1020 | smi[le] 1021 | sn[ext] 1022 | sno[magic] 1023 | snoreme[nu] 1024 | sor[t] 1025 | so[urce] 1026 | spelld[ump] 1027 | spe[llgood] 1028 | spelli[nfo] 1029 | spellra[re] 1030 | spellr[epall] 1031 | spellu[ndo] 1032 | spellw[rong] 1033 | sp[lit] 1034 | spr[evious] 1035 | sr[ewind] 1036 | sta[g] 1037 | startg[replace] 1038 | star[tinsert] 1039 | startr[eplace] 1040 | stj[ump] 1041 | st[op] 1042 | stopi[nsert] 1043 | sts[elect] 1044 | sun[hide] 1045 | sunme[nu] 1046 | sus[pend] 1047 | sv[iew] 1048 | sw[apname] 1049 | sync[bind] 1050 | synti[me] 1051 | tN[ext] 1052 | tabN[ext] 1053 | tabc[lose] 1054 | tabe[dit] 1055 | tabf[ind] 1056 | tabfir[st] 1057 | tabl[ast] 1058 | tabm[ove] 1059 | tabnew 1060 | tabn[ext] 1061 | tabo[nly] 1062 | tabp[revious] 1063 | tabr[ewind] 1064 | tabs 1065 | ta[g] 1066 | tags 1067 | tcl 1068 | tcld[o] 1069 | tclf[ile] 1070 | te[aroff] 1071 | ter[minal] 1072 | tf[irst] 1073 | this 1074 | tj[ump] 1075 | tl[ast] 1076 | tlm[enu] 1077 | tln[oremenu] 1078 | tlu[nmenu] 1079 | tm[enu] 1080 | tn[ext] 1081 | tp[revious] 1082 | tr[ewind] 1083 | ts[elect] 1084 | tu[nmenu] 1085 | u[ndo] 1086 | undoj[oin] 1087 | undol[ist] 1088 | unh[ide] 1089 | unlo[ckvar] 1090 | unme[nu] 1091 | up[date] 1092 | ve[rsion] 1093 | vie[w] 1094 | vim9s[cript] 1095 | vi[sual] 1096 | viu[sage] 1097 | vme[nu] 1098 | vne[w] 1099 | vnoreme[nu] 1100 | vs[plit] 1101 | vunme[nu] 1102 | wN[ext] 1103 | wa[ll] 1104 | winp[os] 1105 | wi[nsize] 1106 | wn[ext] 1107 | wp[revious] 1108 | wq 1109 | wqa[ll] 1110 | w[rite] 1111 | wu[ndo] 1112 | wv[iminfo] 1113 | xa[ll] 1114 | xme[nu] 1115 | xnoreme[nu] 1116 | xr[estore] 1117 | xunme[nu] 1118 | y[ank] 1119 | addd 1120 | END 1121 | 1122 | export const command_name: string = command_name_list->join() 1123 | 1124 | # default_highlighting_group {{{1 1125 | 1126 | const default_highlighting_group_list: list =<< trim END 1127 | ColorColumn 1128 | CurSearch 1129 | Cursor 1130 | CursorColumn 1131 | CursorIM 1132 | CursorLine 1133 | CursorLineFold 1134 | CursorLineNr 1135 | CursorLineSign 1136 | DiffAdd 1137 | DiffChange 1138 | DiffDelete 1139 | DiffText 1140 | Directory 1141 | EndOfBuffer 1142 | ErrorMsg 1143 | FoldColumn 1144 | Folded 1145 | IncSearch 1146 | LineNr 1147 | LineNrAbove 1148 | LineNrBelow 1149 | MatchParen 1150 | Menu 1151 | MessageWindow 1152 | ModeMsg 1153 | MoreMsg 1154 | NonText 1155 | Normal 1156 | Pmenu 1157 | PmenuExtra 1158 | PmenuExtraSel 1159 | PmenuKind 1160 | PmenuKindSel 1161 | PmenuSbar 1162 | PmenuSel 1163 | PmenuThumb 1164 | PopupNotification 1165 | Question 1166 | QuickFixLine 1167 | Scrollbar 1168 | Search 1169 | SignColumn 1170 | SpecialKey 1171 | SpellBad 1172 | SpellCap 1173 | SpellLocal 1174 | SpellRare 1175 | StatusLine 1176 | StatusLineNC 1177 | StatusLineTerm 1178 | StatusLineTermNC 1179 | TOhtmlProgress 1180 | TabLine 1181 | TabLineFill 1182 | TabLineSel 1183 | Terminal 1184 | Title 1185 | ToolbarButton 1186 | ToolbarLine 1187 | Tooltip 1188 | User1 1189 | User2 1190 | User3 1191 | User4 1192 | User5 1193 | User6 1194 | User7 1195 | User8 1196 | User9 1197 | VertSplit 1198 | Visual 1199 | VisualNOS 1200 | WarningMsg 1201 | WildMenu 1202 | debugBreakpoint 1203 | debugPC 1204 | lCursor 1205 | END 1206 | 1207 | export const default_highlighting_group: string = default_highlighting_group_list->join() 1208 | 1209 | # event {{{1 1210 | 1211 | const event_list: list =<< trim END 1212 | BufAdd 1213 | BufCreate 1214 | BufDelete 1215 | BufEnter 1216 | BufFilePost 1217 | BufFilePre 1218 | BufHidden 1219 | BufLeave 1220 | BufNew 1221 | BufNewFile 1222 | BufRead 1223 | BufReadCmd 1224 | BufReadPost 1225 | BufReadPre 1226 | BufUnload 1227 | BufWinEnter 1228 | BufWinLeave 1229 | BufWipeout 1230 | BufWrite 1231 | BufWriteCmd 1232 | BufWritePost 1233 | BufWritePre 1234 | CmdUndefined 1235 | CmdlineChanged 1236 | CmdlineEnter 1237 | CmdlineLeave 1238 | CmdwinEnter 1239 | CmdwinLeave 1240 | ColorScheme 1241 | ColorSchemePre 1242 | CompleteChanged 1243 | CompleteDone 1244 | CompleteDonePre 1245 | CursorHold 1246 | CursorHoldI 1247 | CursorMoved 1248 | CursorMovedI 1249 | DiffUpdated 1250 | DirChanged 1251 | DirChangedPre 1252 | EncodingChanged 1253 | ExitPre 1254 | FileAppendCmd 1255 | FileAppendPost 1256 | FileAppendPre 1257 | FileChangedRO 1258 | FileChangedShell 1259 | FileChangedShellPost 1260 | FileEncoding 1261 | FileReadCmd 1262 | FileReadPost 1263 | FileReadPre 1264 | FileType 1265 | FileWriteCmd 1266 | FileWritePost 1267 | FileWritePre 1268 | FilterReadPost 1269 | FilterReadPre 1270 | FilterWritePost 1271 | FilterWritePre 1272 | FocusGained 1273 | FocusLost 1274 | FuncUndefined 1275 | GUIEnter 1276 | GUIFailed 1277 | InsertChange 1278 | InsertCharPre 1279 | InsertEnter 1280 | InsertLeave 1281 | InsertLeavePre 1282 | MenuPopup 1283 | ModeChanged 1284 | OptionSet 1285 | QuickFixCmdPost 1286 | QuickFixCmdPre 1287 | QuitPre 1288 | RemoteReply 1289 | SafeState 1290 | SafeStateAgain 1291 | SessionLoadPost 1292 | ShellCmdPost 1293 | ShellFilterPost 1294 | SigUSR1 1295 | SourceCmd 1296 | SourcePost 1297 | SourcePre 1298 | SpellFileMissing 1299 | StdinReadPost 1300 | StdinReadPre 1301 | SwapExists 1302 | Syntax 1303 | TabClosed 1304 | TabEnter 1305 | TabLeave 1306 | TabNew 1307 | TermChanged 1308 | TermResponse 1309 | TerminalOpen 1310 | TerminalWinOpen 1311 | TextChanged 1312 | TextChangedI 1313 | TextChangedP 1314 | TextChangedT 1315 | TextYankPost 1316 | User 1317 | VimEnter 1318 | VimLeave 1319 | VimLeavePre 1320 | VimResized 1321 | VimResume 1322 | VimSuspend 1323 | WinClosed 1324 | WinEnter 1325 | WinLeave 1326 | WinNew 1327 | WinResized 1328 | WinScrolled 1329 | END 1330 | 1331 | export const event: string = event_list->join() 1332 | 1333 | # ex_special_characters {{{1 1334 | 1335 | const ex_special_characters_list: list =<< trim END 1336 | abuf 1337 | afile 1338 | cWORD 1339 | cexpr 1340 | cfile 1341 | cword 1342 | sfile 1343 | slnum 1344 | stack 1345 | amatch 1346 | client 1347 | script 1348 | sflnum 1349 | END 1350 | 1351 | export const ex_special_characters: string = ex_special_characters_list->join("\\|") 1352 | 1353 | # increment_invalid {{{1 1354 | 1355 | export const increment_invalid: string = '\%(++\|--\)\%(\%(\%([bgstvw]:\)\=\h\w*\|&\%([lg]:\)\=[a-z]\{2,}\)\s*\_[[|.#]\)\@!' 1356 | 1357 | # key_name {{{1 1358 | 1359 | const key_name_list: list =<< trim END 1360 | BS 1361 | BackSpace 1362 | Bslash 1363 | CR 1364 | CSI 1365 | CursorHold 1366 | DecMouse 1367 | Del 1368 | Delete 1369 | Down 1370 | Drop 1371 | End 1372 | Enter 1373 | Esc 1374 | FocusGained 1375 | FocusLost 1376 | Help 1377 | Home 1378 | Ignore 1379 | Ins 1380 | Insert 1381 | LF 1382 | Left 1383 | LeftDrag 1384 | LeftMouse 1385 | LeftMouseNM 1386 | LeftRelease 1387 | LeftReleaseNM 1388 | LineFeed 1389 | MiddleDrag 1390 | MiddleMouse 1391 | MiddleRelease 1392 | Mouse 1393 | MouseDown 1394 | MouseMove 1395 | MouseUp 1396 | NL 1397 | NetMouse 1398 | NewLine 1399 | Nop 1400 | Nul 1401 | PageDown 1402 | PageUp 1403 | PasteEnd 1404 | PasteStart 1405 | Plug 1406 | Return 1407 | Right 1408 | RightDrag 1409 | RightMouse 1410 | RightRelease 1411 | SID 1412 | SNR 1413 | ScriptCmd 1414 | ScrollWheelDown 1415 | ScrollWheelLeft 1416 | ScrollWheelRight 1417 | ScrollWheelUp 1418 | SgrMouse 1419 | SgrMouseRelease 1420 | Space 1421 | Tab 1422 | Undo 1423 | Up 1424 | UrxvtMouse 1425 | X1Drag 1426 | X1Mouse 1427 | X1Release 1428 | X2Drag 1429 | X2Mouse 1430 | X2Release 1431 | k0 1432 | k1 1433 | k2 1434 | k3 1435 | k4 1436 | k5 1437 | k6 1438 | k7 1439 | k8 1440 | k9 1441 | kDel 1442 | kDivide 1443 | kEnd 1444 | kEnter 1445 | kHome 1446 | kInsert 1447 | kMinus 1448 | kMultiply 1449 | kPageDown 1450 | kPageUp 1451 | kPlus 1452 | kPoint 1453 | lt 1454 | xCSI 1455 | xDown 1456 | xEnd 1457 | xF1 1458 | xF2 1459 | xF3 1460 | xF4 1461 | xHome 1462 | xLeft 1463 | xRight 1464 | xUp 1465 | zEnd 1466 | zHome 1467 | F\d\{1,2} 1468 | . 1469 | END 1470 | 1471 | export const key_name: string = key_name_list->join("\\|") 1472 | 1473 | # lambda_end {{{1 1474 | 1475 | export const lambda_end: string = ')\ze\%(:.\{-}\)\=\s\+=>' 1476 | 1477 | # lambda_start {{{1 1478 | 1479 | export const lambda_start: string = '(\ze\%(\s*\h\w*\%([^(]\|\%(\' 1480 | 1481 | # legacy_autoload_invalid {{{1 1482 | 1483 | export const legacy_autoload_invalid: string = '\h\w*#\%(\w\|#\)*' 1484 | 1485 | # logical_not {{{1 1486 | 1487 | export const logical_not: string = '/\w\@10-9"^.(){}]' 1492 | 1493 | # maybe_dict_literal_key {{{1 1494 | 1495 | export const maybe_dict_literal_key: string = '/\%([{\n]\|[^ \t\n,{\\]\@1>\|\%([=!]=\|[<>]=\=\|[=!]\~\|is\|isnot\)[?#]\=\)\_s\@=\%(\s*[|<]\)\@!"' 1500 | 1501 | # option {{{1 1502 | 1503 | const option_list: list =<< trim END 1504 | aleph 1505 | al 1506 | allowrevins 1507 | ari 1508 | noallowrevins 1509 | noari 1510 | altkeymap 1511 | akm 1512 | noaltkeymap 1513 | noakm 1514 | ambiwidth 1515 | ambw 1516 | antialias 1517 | anti 1518 | noantialias 1519 | noanti 1520 | autochdir 1521 | acd 1522 | noautochdir 1523 | noacd 1524 | autoshelldir 1525 | asd 1526 | noautoshelldir 1527 | noasd 1528 | arabic 1529 | arab 1530 | noarabic 1531 | noarab 1532 | arabicshape 1533 | arshape 1534 | noarabicshape 1535 | noarshape 1536 | autoindent 1537 | ai 1538 | noautoindent 1539 | noai 1540 | autoread 1541 | ar 1542 | noautoread 1543 | noar 1544 | autowrite 1545 | aw 1546 | noautowrite 1547 | noaw 1548 | autowriteall 1549 | awa 1550 | noautowriteall 1551 | noawa 1552 | background 1553 | bg 1554 | backspace 1555 | bs 1556 | backup 1557 | bk 1558 | nobackup 1559 | nobk 1560 | backupcopy 1561 | bkc 1562 | backupdir 1563 | bdir 1564 | backupext 1565 | bex 1566 | backupskip 1567 | bsk 1568 | balloondelay 1569 | bdlay 1570 | ballooneval 1571 | beval 1572 | noballooneval 1573 | nobeval 1574 | balloonevalterm 1575 | bevalterm 1576 | noballoonevalterm 1577 | nobevalterm 1578 | balloonexpr 1579 | bexpr 1580 | belloff 1581 | bo 1582 | binary 1583 | bin 1584 | nobinary 1585 | nobin 1586 | bomb 1587 | nobomb 1588 | breakat 1589 | brk 1590 | breakindent 1591 | bri 1592 | nobreakindent 1593 | nobri 1594 | breakindentopt 1595 | briopt 1596 | browsedir 1597 | bsdir 1598 | bufhidden 1599 | bh 1600 | buflisted 1601 | bl 1602 | nobuflisted 1603 | nobl 1604 | buftype 1605 | bt 1606 | casemap 1607 | cmp 1608 | cdhome 1609 | cdh 1610 | nocdhome 1611 | nocdh 1612 | cdpath 1613 | cd 1614 | cedit 1615 | charconvert 1616 | ccv 1617 | cindent 1618 | cin 1619 | nocindent 1620 | nocin 1621 | cinkeys 1622 | cink 1623 | cinoptions 1624 | cino 1625 | cinwords 1626 | cinw 1627 | cinscopedecls 1628 | cinsd 1629 | clipboard 1630 | cb 1631 | cmdheight 1632 | ch 1633 | cmdwinheight 1634 | cwh 1635 | colorcolumn 1636 | cc 1637 | columns 1638 | co 1639 | comments 1640 | com 1641 | commentstring 1642 | cms 1643 | compatible 1644 | cp 1645 | nocompatible 1646 | nocp 1647 | complete 1648 | cpt 1649 | completefunc 1650 | cfu 1651 | completeslash 1652 | csl 1653 | completeopt 1654 | cot 1655 | completepopup 1656 | cpp 1657 | concealcursor 1658 | cocu 1659 | conceallevel 1660 | cole 1661 | confirm 1662 | cf 1663 | noconfirm 1664 | nocf 1665 | copyindent 1666 | ci 1667 | nocopyindent 1668 | noci 1669 | cpoptions 1670 | cpo 1671 | cryptmethod 1672 | cm 1673 | cscopepathcomp 1674 | cspc 1675 | cscopeprg 1676 | csprg 1677 | cscopequickfix 1678 | csqf 1679 | cscoperelative 1680 | csre 1681 | nocscoperelative 1682 | nocsre 1683 | cscopetag 1684 | cst 1685 | nocscopetag 1686 | nocst 1687 | cscopetagorder 1688 | csto 1689 | cscopeverbose 1690 | csverb 1691 | nocscopeverbose 1692 | nocsverb 1693 | cursorbind 1694 | crb 1695 | nocursorbind 1696 | nocrb 1697 | cursorcolumn 1698 | cuc 1699 | nocursorcolumn 1700 | nocuc 1701 | cursorline 1702 | cul 1703 | nocursorline 1704 | nocul 1705 | cursorlineopt 1706 | culopt 1707 | debug 1708 | define 1709 | def 1710 | delcombine 1711 | deco 1712 | nodelcombine 1713 | nodeco 1714 | dictionary 1715 | dict 1716 | diff 1717 | nodiff 1718 | dex 1719 | diffexpr 1720 | dip 1721 | diffopt 1722 | digraph 1723 | dg 1724 | nodigraph 1725 | nodg 1726 | directory 1727 | dir 1728 | display 1729 | dy 1730 | eadirection 1731 | ead 1732 | ed 1733 | edcompatible 1734 | noed 1735 | noedcompatible 1736 | emoji 1737 | emo 1738 | noemoji 1739 | noemo 1740 | encoding 1741 | enc 1742 | endoffile 1743 | eof 1744 | noendoffile 1745 | noeof 1746 | endofline 1747 | eol 1748 | noendofline 1749 | noeol 1750 | equalalways 1751 | ea 1752 | noequalalways 1753 | noea 1754 | equalprg 1755 | ep 1756 | errorbells 1757 | eb 1758 | noerrorbells 1759 | noeb 1760 | errorfile 1761 | ef 1762 | errorformat 1763 | efm 1764 | esckeys 1765 | ek 1766 | noesckeys 1767 | noek 1768 | eventignore 1769 | ei 1770 | expandtab 1771 | et 1772 | noexpandtab 1773 | noet 1774 | exrc 1775 | ex 1776 | noexrc 1777 | noex 1778 | fileencoding 1779 | fenc 1780 | fileencodings 1781 | fencs 1782 | fileformat 1783 | ff 1784 | fileformats 1785 | ffs 1786 | fileignorecase 1787 | fic 1788 | nofileignorecase 1789 | nofic 1790 | filetype 1791 | ft 1792 | fillchars 1793 | fcs 1794 | fixendofline 1795 | fixeol 1796 | nofixendofline 1797 | nofixeol 1798 | fkmap 1799 | fk 1800 | nofkmap 1801 | nofk 1802 | foldclose 1803 | fcl 1804 | foldcolumn 1805 | fdc 1806 | foldenable 1807 | fen 1808 | nofoldenable 1809 | nofen 1810 | foldexpr 1811 | fde 1812 | foldignore 1813 | fdi 1814 | foldlevel 1815 | fdl 1816 | foldlevelstart 1817 | fdls 1818 | foldmarker 1819 | fmr 1820 | foldmethod 1821 | fdm 1822 | foldminlines 1823 | fml 1824 | foldnestmax 1825 | fdn 1826 | foldopen 1827 | fdo 1828 | foldtext 1829 | fdt 1830 | formatexpr 1831 | fex 1832 | formatlistpat 1833 | flp 1834 | formatoptions 1835 | fo 1836 | formatprg 1837 | fp 1838 | fsync 1839 | fs 1840 | nofsync 1841 | nofs 1842 | gdefault 1843 | gd 1844 | nogdefault 1845 | nogd 1846 | grepformat 1847 | gfm 1848 | grepprg 1849 | gp 1850 | guicursor 1851 | gcr 1852 | guifont 1853 | gfn 1854 | guifontset 1855 | gfs 1856 | guifontwide 1857 | gfw 1858 | guiheadroom 1859 | ghr 1860 | guiligatures 1861 | gli 1862 | guioptions 1863 | go 1864 | guipty 1865 | noguipty 1866 | guitablabel 1867 | gtl 1868 | guitabtooltip 1869 | gtt 1870 | helpfile 1871 | hf 1872 | helpheight 1873 | hh 1874 | helplang 1875 | hlg 1876 | hidden 1877 | hid 1878 | nohidden 1879 | nohid 1880 | highlight 1881 | hl 1882 | history 1883 | hi 1884 | hkmap 1885 | hk 1886 | nohkmap 1887 | nohk 1888 | hkmapp 1889 | hkp 1890 | nohkmapp 1891 | nohkp 1892 | hlsearch 1893 | hls 1894 | nohlsearch 1895 | nohls 1896 | icon 1897 | noicon 1898 | iconstring 1899 | ignorecase 1900 | ic 1901 | noignorecase 1902 | noic 1903 | imactivatefunc 1904 | imaf 1905 | imactivatekey 1906 | imak 1907 | imcmdline 1908 | imc 1909 | noimcmdline 1910 | noimc 1911 | imdisable 1912 | imd 1913 | noimdisable 1914 | noimd 1915 | iminsert 1916 | imi 1917 | imsearch 1918 | ims 1919 | imstatusfunc 1920 | imsf 1921 | imstyle 1922 | imst 1923 | include 1924 | inc 1925 | includeexpr 1926 | inex 1927 | incsearch 1928 | is 1929 | noincsearch 1930 | nois 1931 | indentexpr 1932 | inde 1933 | indentkeys 1934 | indk 1935 | infercase 1936 | inf 1937 | noinfercase 1938 | noinf 1939 | insertmode 1940 | im 1941 | noinsertmode 1942 | noim 1943 | isfname 1944 | isf 1945 | isident 1946 | isi 1947 | iskeyword 1948 | isk 1949 | isprint 1950 | isp 1951 | joinspaces 1952 | js 1953 | nojoinspaces 1954 | nojs 1955 | jumpoptions 1956 | jop 1957 | key 1958 | keymap 1959 | kmp 1960 | keymodel 1961 | km 1962 | keyprotocol 1963 | kpc 1964 | keywordprg 1965 | kp 1966 | langmap 1967 | lmap 1968 | langmenu 1969 | lm 1970 | langnoremap 1971 | lnr 1972 | nolangnoremap 1973 | nolnr 1974 | langremap 1975 | lrm 1976 | nolangremap 1977 | nolrm 1978 | laststatus 1979 | ls 1980 | lazyredraw 1981 | lz 1982 | nolazyredraw 1983 | nolz 1984 | linebreak 1985 | lbr 1986 | nolinebreak 1987 | nolbr 1988 | lines 1989 | linespace 1990 | lsp 1991 | lisp 1992 | nolisp 1993 | lispoptions 1994 | lop 1995 | lispwords 1996 | lw 1997 | list 1998 | nolist 1999 | listchars 2000 | lcs 2001 | lpl 2002 | nolpl 2003 | loadplugins 2004 | noloadplugins 2005 | luadll 2006 | macatsui 2007 | nomacatsui 2008 | magic 2009 | nomagic 2010 | makeef 2011 | mef 2012 | makeencoding 2013 | menc 2014 | makeprg 2015 | mp 2016 | matchpairs 2017 | mps 2018 | matchtime 2019 | mat 2020 | maxcombine 2021 | mco 2022 | maxfuncdepth 2023 | mfd 2024 | maxmapdepth 2025 | mmd 2026 | maxmem 2027 | mm 2028 | maxmempattern 2029 | mmp 2030 | maxmemtot 2031 | mmt 2032 | menuitems 2033 | mis 2034 | mkspellmem 2035 | msm 2036 | modeline 2037 | ml 2038 | nomodeline 2039 | noml 2040 | modelineexpr 2041 | mle 2042 | nomodelineexpr 2043 | nomle 2044 | modelines 2045 | mls 2046 | modifiable 2047 | ma 2048 | nomodifiable 2049 | noma 2050 | modified 2051 | mod 2052 | nomodified 2053 | nomod 2054 | more 2055 | nomore 2056 | mouse 2057 | mousefocus 2058 | mousef 2059 | nomousefocus 2060 | nomousef 2061 | mousehide 2062 | mh 2063 | nomousehide 2064 | nomh 2065 | mousemodel 2066 | mousem 2067 | mousemoveevent 2068 | mousemev 2069 | nomousemoveevent 2070 | nomousemev 2071 | mouseshape 2072 | mouses 2073 | mousetime 2074 | mouset 2075 | mzschemedll 2076 | mzschemegcdll 2077 | mzquantum 2078 | mzq 2079 | nrformats 2080 | nf 2081 | number 2082 | nu 2083 | nonumber 2084 | nonu 2085 | numberwidth 2086 | nuw 2087 | omnifunc 2088 | ofu 2089 | opendevice 2090 | odev 2091 | noopendevice 2092 | noodev 2093 | operatorfunc 2094 | opfunc 2095 | osfiletype 2096 | oft 2097 | packpath 2098 | pp 2099 | paragraphs 2100 | para 2101 | paste 2102 | nopaste 2103 | pastetoggle 2104 | pt 2105 | pex 2106 | patchexpr 2107 | patchmode 2108 | pm 2109 | path 2110 | pa 2111 | perldll 2112 | preserveindent 2113 | pi 2114 | nopreserveindent 2115 | nopi 2116 | previewheight 2117 | pvh 2118 | previewpopup 2119 | pvp 2120 | previewwindow 2121 | nopreviewwindow 2122 | pvw 2123 | nopvw 2124 | printdevice 2125 | pdev 2126 | printencoding 2127 | penc 2128 | printexpr 2129 | pexpr 2130 | printfont 2131 | pfn 2132 | printheader 2133 | pheader 2134 | printmbcharset 2135 | pmbcs 2136 | printmbfont 2137 | pmbfn 2138 | printoptions 2139 | popt 2140 | prompt 2141 | noprompt 2142 | pumheight 2143 | ph 2144 | pumwidth 2145 | pw 2146 | pythondll 2147 | pythonhome 2148 | pythonthreedll 2149 | pythonthreehome 2150 | pyxversion 2151 | pyx 2152 | quickfixtextfunc 2153 | qftf 2154 | quoteescape 2155 | qe 2156 | readonly 2157 | ro 2158 | noreadonly 2159 | noro 2160 | redrawtime 2161 | rdt 2162 | regexpengine 2163 | re 2164 | relativenumber 2165 | rnu 2166 | norelativenumber 2167 | nornu 2168 | remap 2169 | noremap 2170 | renderoptions 2171 | rop 2172 | report 2173 | restorescreen 2174 | rs 2175 | norestorescreen 2176 | nors 2177 | revins 2178 | ri 2179 | norevins 2180 | nori 2181 | rightleft 2182 | rl 2183 | norightleft 2184 | norl 2185 | rightleftcmd 2186 | rlc 2187 | rubydll 2188 | ruler 2189 | ru 2190 | noruler 2191 | noru 2192 | rulerformat 2193 | ruf 2194 | runtimepath 2195 | rtp 2196 | scroll 2197 | scr 2198 | scrollbind 2199 | scb 2200 | noscrollbind 2201 | noscb 2202 | scrollfocus 2203 | scf 2204 | noscrollfocus 2205 | noscf 2206 | scrolljump 2207 | sj 2208 | scrolloff 2209 | so 2210 | scrollopt 2211 | sbo 2212 | sections 2213 | sect 2214 | secure 2215 | nosecure 2216 | selection 2217 | sel 2218 | selectmode 2219 | slm 2220 | sessionoptions 2221 | ssop 2222 | shell 2223 | sh 2224 | shellcmdflag 2225 | shcf 2226 | shellpipe 2227 | sp 2228 | shellquote 2229 | shq 2230 | shellredir 2231 | srr 2232 | shellslash 2233 | ssl 2234 | noshellslash 2235 | nossl 2236 | shelltemp 2237 | stmp 2238 | noshelltemp 2239 | nostmp 2240 | shelltype 2241 | st 2242 | shellxescape 2243 | sxe 2244 | shellxquote 2245 | sxq 2246 | shiftround 2247 | sr 2248 | noshiftround 2249 | nosr 2250 | shiftwidth 2251 | sw 2252 | shortmess 2253 | shm 2254 | shortname 2255 | sn 2256 | noshortname 2257 | nosn 2258 | showbreak 2259 | sbr 2260 | showcmd 2261 | sc 2262 | noshowcmd 2263 | nosc 2264 | showcmdloc 2265 | sloc 2266 | showfulltag 2267 | sft 2268 | noshowfulltag 2269 | nosft 2270 | showmatch 2271 | sm 2272 | noshowmatch 2273 | nosm 2274 | showmode 2275 | smd 2276 | noshowmode 2277 | nosmd 2278 | showtabline 2279 | stal 2280 | sidescroll 2281 | ss 2282 | sidescrolloff 2283 | siso 2284 | signcolumn 2285 | scl 2286 | smartcase 2287 | scs 2288 | nosmartcase 2289 | noscs 2290 | smartindent 2291 | si 2292 | nosmartindent 2293 | nosi 2294 | smarttab 2295 | sta 2296 | nosmarttab 2297 | nosta 2298 | smoothscroll 2299 | sms 2300 | nosmoothscroll 2301 | nosms 2302 | softtabstop 2303 | sts 2304 | spell 2305 | nospell 2306 | spellcapcheck 2307 | spc 2308 | spellfile 2309 | spf 2310 | spelllang 2311 | spl 2312 | spelloptions 2313 | spo 2314 | spellsuggest 2315 | sps 2316 | splitbelow 2317 | sb 2318 | nosplitbelow 2319 | nosb 2320 | splitkeep 2321 | spk 2322 | splitright 2323 | spr 2324 | nosplitright 2325 | nospr 2326 | startofline 2327 | sol 2328 | nostartofline 2329 | nosol 2330 | statusline 2331 | stl 2332 | suffixes 2333 | su 2334 | suffixesadd 2335 | sua 2336 | swapfile 2337 | swf 2338 | noswapfile 2339 | noswf 2340 | swapsync 2341 | sws 2342 | switchbuf 2343 | swb 2344 | synmaxcol 2345 | smc 2346 | syntax 2347 | syn 2348 | tabline 2349 | tal 2350 | tabpagemax 2351 | tpm 2352 | tabstop 2353 | ts 2354 | tagbsearch 2355 | tbs 2356 | notagbsearch 2357 | notbs 2358 | tagcase 2359 | tc 2360 | tagfunc 2361 | tfu 2362 | taglength 2363 | tl 2364 | tagrelative 2365 | tr 2366 | notagrelative 2367 | notr 2368 | tags 2369 | tag 2370 | tagstack 2371 | tgst 2372 | notagstack 2373 | notgst 2374 | tcldll 2375 | term 2376 | termbidi 2377 | tbidi 2378 | notermbidi 2379 | notbidi 2380 | termencoding 2381 | tenc 2382 | termguicolors 2383 | tgc 2384 | notermguicolors 2385 | notgc 2386 | termwinkey 2387 | twk 2388 | termwinscroll 2389 | twsl 2390 | termwinsize 2391 | tws 2392 | termwintype 2393 | twt 2394 | terse 2395 | noterse 2396 | textauto 2397 | ta 2398 | notextauto 2399 | nota 2400 | textmode 2401 | tx 2402 | notextmode 2403 | notx 2404 | textwidth 2405 | tw 2406 | thesaurus 2407 | tsr 2408 | thesaurusfunc 2409 | tsrfu 2410 | tildeop 2411 | top 2412 | notildeop 2413 | notop 2414 | timeout 2415 | to 2416 | notimeout 2417 | noto 2418 | ttimeout 2419 | nottimeout 2420 | timeoutlen 2421 | tm 2422 | ttimeoutlen 2423 | ttm 2424 | title 2425 | notitle 2426 | titlelen 2427 | titleold 2428 | titlestring 2429 | toolbar 2430 | tb 2431 | toolbariconsize 2432 | tbis 2433 | ttybuiltin 2434 | tbi 2435 | nottybuiltin 2436 | notbi 2437 | ttyfast 2438 | tf 2439 | nottyfast 2440 | notf 2441 | ttymouse 2442 | ttym 2443 | ttyscroll 2444 | tsl 2445 | ttytype 2446 | tty 2447 | undodir 2448 | udir 2449 | undofile 2450 | noundofile 2451 | udf 2452 | noudf 2453 | undolevels 2454 | ul 2455 | undoreload 2456 | ur 2457 | updatecount 2458 | uc 2459 | updatetime 2460 | ut 2461 | varsofttabstop 2462 | vsts 2463 | vartabstop 2464 | vts 2465 | verbose 2466 | vbs 2467 | verbosefile 2468 | vfile 2469 | viewdir 2470 | vdir 2471 | viewoptions 2472 | vop 2473 | viminfo 2474 | vi 2475 | viminfofile 2476 | vif 2477 | virtualedit 2478 | ve 2479 | visualbell 2480 | vb 2481 | novisualbell 2482 | novb 2483 | warn 2484 | nowarn 2485 | weirdinvert 2486 | wiv 2487 | noweirdinvert 2488 | nowiv 2489 | whichwrap 2490 | ww 2491 | wildchar 2492 | wc 2493 | wildcharm 2494 | wcm 2495 | wildignore 2496 | wig 2497 | wildignorecase 2498 | wic 2499 | nowildignorecase 2500 | nowic 2501 | wildmenu 2502 | wmnu 2503 | nowildmenu 2504 | nowmnu 2505 | wildmode 2506 | wim 2507 | wildoptions 2508 | wop 2509 | winaltkeys 2510 | wak 2511 | wincolor 2512 | wcr 2513 | window 2514 | wi 2515 | winheight 2516 | wh 2517 | winfixheight 2518 | wfh 2519 | nowinfixheight 2520 | nowfh 2521 | winfixwidth 2522 | wfw 2523 | nowinfixwidth 2524 | nowfw 2525 | winminheight 2526 | wmh 2527 | winminwidth 2528 | wmw 2529 | winptydll 2530 | winwidth 2531 | wiw 2532 | wrap 2533 | nowrap 2534 | wrapmargin 2535 | wm 2536 | wrapscan 2537 | ws 2538 | nowrapscan 2539 | nows 2540 | write 2541 | nowrite 2542 | writeany 2543 | wa 2544 | nowriteany 2545 | nowa 2546 | writebackup 2547 | wb 2548 | nowritebackup 2549 | nowb 2550 | writedelay 2551 | wd 2552 | xtermcodes 2553 | noxtermcodes 2554 | END 2555 | 2556 | export const option: string = option_list->join() 2557 | 2558 | # option_can_be_after {{{1 2559 | 2560 | export const option_can_be_after: string = '\%(\%(^\|[-+ \t!([>]\)\@1<=\|{\@1<=\)' 2561 | 2562 | # option_modifier {{{1 2563 | 2564 | export const option_modifier: string = '\%(&\%(vim\)\=\|[ =<< trim END 2573 | t_8b 2574 | t_8f 2575 | t_8u 2576 | t_AB 2577 | t_AF 2578 | t_AL 2579 | t_AU 2580 | t_BD 2581 | t_BE 2582 | t_CS 2583 | t_CV 2584 | t_Ce 2585 | t_Co 2586 | t_Cs 2587 | t_DL 2588 | t_Ds 2589 | t_EC 2590 | t_EI 2591 | t_F1 2592 | t_F2 2593 | t_F3 2594 | t_F4 2595 | t_F5 2596 | t_F6 2597 | t_F7 2598 | t_F8 2599 | t_F9 2600 | t_GP 2601 | t_IE 2602 | t_IS 2603 | t_K1 2604 | t_K3 2605 | t_K4 2606 | t_K5 2607 | t_K6 2608 | t_K7 2609 | t_K8 2610 | t_K9 2611 | t_KA 2612 | t_KB 2613 | t_KC 2614 | t_KD 2615 | t_KE 2616 | t_KF 2617 | t_KG 2618 | t_KH 2619 | t_KI 2620 | t_KJ 2621 | t_KK 2622 | t_KL 2623 | t_PE 2624 | t_PS 2625 | t_RB 2626 | t_RC 2627 | t_RF 2628 | t_RI 2629 | t_RK 2630 | t_RS 2631 | t_RT 2632 | t_RV 2633 | t_Ri 2634 | t_SC 2635 | t_SH 2636 | t_SI 2637 | t_SR 2638 | t_ST 2639 | t_Sb 2640 | t_Sf 2641 | t_Si 2642 | t_TE 2643 | t_TI 2644 | t_Te 2645 | t_Ts 2646 | t_Us 2647 | t_VS 2648 | t_WP 2649 | t_WS 2650 | t_XM 2651 | t_ZH 2652 | t_ZR 2653 | t_al 2654 | t_bc 2655 | t_cd 2656 | t_ce 2657 | t_ci 2658 | t_cl 2659 | t_cm 2660 | t_cs 2661 | t_cv 2662 | t_da 2663 | t_db 2664 | t_dl 2665 | t_ds 2666 | t_ed 2667 | t_el 2668 | t_f1 2669 | t_f2 2670 | t_f3 2671 | t_f4 2672 | t_f5 2673 | t_f6 2674 | t_f7 2675 | t_f8 2676 | t_f9 2677 | t_fd 2678 | t_fe 2679 | t_fs 2680 | t_il 2681 | t_k1 2682 | t_k2 2683 | t_k3 2684 | t_k4 2685 | t_k5 2686 | t_k6 2687 | t_k7 2688 | t_k8 2689 | t_k9 2690 | t_kB 2691 | t_kD 2692 | t_kI 2693 | t_kN 2694 | t_kP 2695 | t_kb 2696 | t_kd 2697 | t_ke 2698 | t_kh 2699 | t_kl 2700 | t_kr 2701 | t_ks 2702 | t_ku 2703 | t_le 2704 | t_mb 2705 | t_md 2706 | t_me 2707 | t_mr 2708 | t_ms 2709 | t_nd 2710 | t_op 2711 | t_se 2712 | t_so 2713 | t_sr 2714 | t_tb 2715 | t_te 2716 | t_ti 2717 | t_tp 2718 | t_ts 2719 | t_u7 2720 | t_ue 2721 | t_us 2722 | t_ut 2723 | t_vb 2724 | t_ve 2725 | t_vi 2726 | t_vs 2727 | t_xn 2728 | t_xs 2729 | END 2730 | 2731 | export const option_terminal: string = option_terminal_list->join() 2732 | 2733 | # option_terminal_special {{{1 2734 | 2735 | const option_terminal_special_list: list =<< trim END 2736 | t_#2 2737 | t_#4 2738 | t_%1 2739 | t_%i 2740 | t_&8 2741 | t_*7 2742 | t_@7 2743 | t_k; 2744 | END 2745 | 2746 | export const option_terminal_special: string = option_terminal_special_list->join("\\|") 2747 | 2748 | # option_valid {{{1 2749 | 2750 | export const option_valid: string = '\%([a-z]\{2,}\>\|t_[a-zA-Z0-9#%*:@_]\{2}\)' 2751 | 2752 | # pattern_delimiter {{{1 2753 | 2754 | export const pattern_delimiter: string = '[^-+*/%.:# \t[:alnum:]\"|]\@=.\|->\@!\%(=\s\)\@!\|[+*/%]\%(=\s\)\@!' 2755 | 2756 | # wincmd_valid {{{1 2757 | 2758 | export const wincmd_valid: string = '/\s\@1<=\%([-\]+:<=>FHJKLPRSTW^_bcdfhijklnopqrstvwxz}|]\|gF\|gT\|g]\|gf\|gt\|g}\)\_s\@=/' 2759 | -------------------------------------------------------------------------------- /import/vim9SyntaxUtil.vim: -------------------------------------------------------------------------------- 1 | vim9script 2 | 3 | # Interface {{{1 4 | export def Derive( # {{{2 5 | new_group: string, 6 | from: string, 7 | new_attrs: dict, 8 | ) 9 | # Purpose:{{{ 10 | # 11 | # Derive a new syntax group (`new_group`) from an existing one (`from`), 12 | # overriding some attributes (`new_attrs`). 13 | #}}} 14 | # Usage Examples:{{{ 15 | # 16 | # To define `CommentUnderlined` with the same attributes as `Comment`, resetting 17 | # the `term`, `cterm`, and `gui` attributes with the value `underline`: 18 | # 19 | # Derive('CommentUnderlined', 'Comment', {gui: {bold: true}, term: {bold: true}, cterm: {bold: true}}) 20 | # 21 | # To define `PopupSign` with the same attributes as `WarningMsg`, resetting the 22 | # `guibg` or `ctermbg` attributes with the colors of the `Normal` HG: 23 | # 24 | # Derive('PopupSign', 'WarningMsg', {bg: 'Normal'}) 25 | #}}} 26 | 27 | var from_def: dict = hlget(from, true)->get(0, {}) 28 | if from_def->get('cleared') 29 | return 30 | endif 31 | highlights->add(from_def->extend({name: new_group, default: true})->extend(new_attrs)) 32 | highlights->hlset() 33 | 34 | # Make sure the derived highlight groups persist even if the color scheme 35 | # changes, and the Vim syntax plugin is not re-sourced. 36 | autocmd_add([{ 37 | cmd: 'highlights->hlset()', 38 | event: 'ColorScheme', 39 | group: 'DeriveHighlightGroups', 40 | once: true, 41 | pattern: '*', 42 | replace: true, 43 | }]) 44 | enddef 45 | 46 | var highlights: list> 47 | 48 | export def HighlightUserTypes() # {{{2 49 | var buf: number = bufnr('%') 50 | 51 | # remove existing text properties to start from a clean state 52 | if prop_type_list({bufnr: buf})->index('vim9UserType') >= 0 53 | {type: 'vim9UserType', bufnr: buf, all: true} 54 | ->prop_remove(1, line('$')) 55 | endif 56 | # add property type 57 | if prop_type_get('vim9UserType', {bufnr: buf}) == {} 58 | prop_type_add('vim9UserType', {highlight: 'vim9UserType', bufnr: buf}) 59 | endif 60 | 61 | var pat: string = '\%(^\|[^|]|\)\s*\%(' 62 | # `:help :type` 63 | .. 'type' 64 | # `:help :enum` 65 | .. '\|' .. 'enum' 66 | # `:help Vim9-using-interface` 67 | # > The interface name can be used as a type: 68 | # A class can also be used as a type: 69 | # https://github.com/vim/vim/commit/eca2c5fff6f6ccad0df8824c4b4354d3f410d225 70 | .. '\|' .. '\%(export\s\+\)\=interface' 71 | .. '\|' .. '\%(\%(export\|abstract\|export\s\+abstract\)\s\+\)\=class' 72 | .. '\)\s\+\zs\u\w*' 73 | var lines: list = getline(1, '$') 74 | var user_type: string = lines 75 | ->copy() 76 | ->map((_, line: string) => line->matchstr(pat)) 77 | ->filter((_, type: string): bool => type != '') 78 | ->sort() 79 | ->uniq() 80 | ->join('\|') 81 | if user_type == '' 82 | return 83 | endif 84 | 85 | user_type = $'\zs\%({user_type}\)\ze' 86 | # def Func(obj1: UserType, obj2: UserType): UserType 87 | # ^------^ ^------^ ^------^ 88 | # var Lambda = (): UserType => ... 89 | # ^------^ 90 | user_type = $':\s\+{user_type}\%([,) \t]\|$\)' 91 | # var x: list 92 | # ^------^ 93 | .. $'\|<{user_type}>' 94 | # var x: func(..., UserType, ...) 95 | # ^------^ 96 | .. $'\|func(\%(\%(\.\.\.\|?\)\=\w*,\s*\)*{user_type}\%(,\s*\%(\.\.\.\|?\)\=\w*\)*)' 97 | 98 | # let's find out the positions of all the user types 99 | var pos: list> 100 | # iterate over the lines of the buffer 101 | for [lnum: number, line: string] in lines->items() 102 | var old_start: number = -1 103 | # iterate over user types on a given line 104 | while true 105 | # look for a user type name 106 | var [_, start: number, end: number] = 107 | matchstrpos(line, user_type, old_start + 1) 108 | 109 | # bail out if there aren't (anymore) 110 | if start == -1 111 | break 112 | endif 113 | 114 | # remember where the last user type started (useful in the next 115 | # iteration to find the next user type on the same line) 116 | old_start = start 117 | 118 | # ignore a user type inside a comment or a string 119 | if InCommentOrString(lnum + 1, start) 120 | continue 121 | endif 122 | 123 | # save position of text property 124 | pos->add([lnum + 1, start, lnum + 1, end + 1]) 125 | endwhile 126 | endfor 127 | 128 | # finally, add text properties 129 | prop_add_list({bufnr: buf, type: 'vim9UserType'}, pos) 130 | enddef 131 | # }}}1 132 | # Util {{{1 133 | def InCommentOrString(lnum: number, col: number): bool # {{{2 134 | return synstack(lnum, col) 135 | ->indexof((_, id: number): bool => 136 | synIDattr(id, 'name') =~ '\ccomment\|string\|heredoc') >= 0 137 | enddef 138 | 139 | -------------------------------------------------------------------------------- /tools/GenerateImport.vim: -------------------------------------------------------------------------------- 1 | vim9script noclear 2 | 3 | if $MYVIMRC != '' 4 | var sfile: string = expand(':t') 5 | var msg: list =<< trim eval END 6 | This script must be sourced without any custom configuration: 7 | 8 | $ vim -Nu NONE -S {sfile} 9 | END 10 | popup_notification(msg, {pos: 'center'}) 11 | finish 12 | endif 13 | 14 | # Declarations {{{1 15 | 16 | const ABBREV_CMDS: list =<< trim END 17 | abbreviate 18 | abclear 19 | cabbrev 20 | cabclear 21 | cnoreabbrev 22 | cunabbrev 23 | iabbrev 24 | iabclear 25 | inoreabbrev 26 | iunabbrev 27 | noreabbrev 28 | unabbreviate 29 | END 30 | 31 | const CONTROL_FLOW_CMDS: list =<< trim END 32 | if 33 | else 34 | elseif 35 | endif 36 | for 37 | endfor 38 | while 39 | endwhile 40 | try 41 | catch 42 | finally 43 | throw 44 | endtry 45 | return 46 | break 47 | continue 48 | finish 49 | END 50 | 51 | const DECLARE_CMDS: list =<< trim END 52 | const 53 | final 54 | unlet 55 | var 56 | END 57 | 58 | const DEPRECATED_CMDS: list =<< trim END 59 | append 60 | change 61 | insert 62 | k 63 | let 64 | mode 65 | open 66 | t 67 | xit 68 | END 69 | 70 | const DO_CMDS: list =<< trim END 71 | argdo 72 | bufdo 73 | cdo 74 | cfdo 75 | ldo 76 | lfdo 77 | tabdo 78 | windo 79 | END 80 | 81 | # :vim9cmd echo getcompletion('*map', 'command')->filter((_, v) => v =~ '^[a-z]' && v != 'loadkeymap') 82 | const MAPPING_CMDS: list =<< trim END 83 | map 84 | cmap 85 | imap 86 | lmap 87 | nmap 88 | omap 89 | smap 90 | tmap 91 | vmap 92 | xmap 93 | cnoremap 94 | inoremap 95 | lnoremap 96 | nnoremap 97 | noremap 98 | onoremap 99 | snoremap 100 | tnoremap 101 | vnoremap 102 | xnoremap 103 | cunmap 104 | iunmap 105 | lunmap 106 | nunmap 107 | ounmap 108 | sunmap 109 | tunmap 110 | unmap 111 | vunmap 112 | xunmap 113 | cmapclear 114 | imapclear 115 | lmapclear 116 | mapclear 117 | nmapclear 118 | omapclear 119 | smapclear 120 | tmapclear 121 | vmapclear 122 | xmapclear 123 | END 124 | 125 | # :helpgrep ^:\%({command}\|{cmd}\) 126 | const MODIFIER_CMDS: list =<< trim END 127 | aboveleft 128 | belowright 129 | botright 130 | browse 131 | confirm 132 | hide 133 | keepalt 134 | keepjumps 135 | keepmarks 136 | keeppatterns 137 | leftabove 138 | legacy 139 | lockmarks 140 | noautocmd 141 | noswapfile 142 | rightbelow 143 | sandbox 144 | silent 145 | tab 146 | topleft 147 | unsilent 148 | verbose 149 | vertical 150 | vim9cmd 151 | END 152 | 153 | const OOP: list =<< trim END 154 | class 155 | endclass 156 | interface 157 | endinterface 158 | enum 159 | endenum 160 | abstract 161 | public 162 | static 163 | type 164 | END 165 | 166 | const VARIOUS_SPECIAL_CMDS: list =<< trim END 167 | augroup 168 | autocmd 169 | command 170 | cd 171 | chdir 172 | lcd 173 | lchdir 174 | tcd 175 | tchdir 176 | copy 177 | digraphs 178 | doautoall 179 | doautocmd 180 | echohl 181 | export 182 | filetype 183 | global 184 | vglobal 185 | highlight 186 | import 187 | lua 188 | mark 189 | move 190 | normal 191 | python 192 | python3 193 | pythonx 194 | set 195 | setglobal 196 | setlocal 197 | substitute 198 | syntax 199 | vimgrep 200 | vimgrepadd 201 | lvimgrep 202 | lvimgrepadd 203 | wincmd 204 | z 205 | END 206 | 207 | const SPECIAL_CMDS: list = 208 | ABBREV_CMDS 209 | + CONTROL_FLOW_CMDS 210 | + DECLARE_CMDS 211 | + DEPRECATED_CMDS 212 | + DO_CMDS 213 | + MAPPING_CMDS 214 | + MODIFIER_CMDS 215 | + OOP 216 | + VARIOUS_SPECIAL_CMDS 217 | 218 | # Util Functions {{{1 219 | def Shorten( #{{{2 220 | to_shorten: list, 221 | for_match: bool = false 222 | ): list 223 | 224 | var shortened: list 225 | for cmd: string in to_shorten 226 | var len: number 227 | for l: number in strcharlen(cmd)->range()->reverse() 228 | if l == 0 229 | continue 230 | endif 231 | if cmd->slice(0, l)->fullcommand() != cmd 232 | len = l 233 | break 234 | endif 235 | endfor 236 | if len == cmd->strcharlen() - 1 237 | shortened->add(cmd) 238 | else 239 | shortened->add(printf( 240 | '%s%s[%s]', 241 | cmd[: len], 242 | for_match ? '\%' : '', 243 | cmd[len + 1 :] 244 | )) 245 | endif 246 | endfor 247 | return shortened 248 | enddef 249 | 250 | def AppendSection(what: string, match_rule = false) #{{{2 251 | # `match_rule` is on when we want the import file to join the items in a heredoc 252 | # with `\|`, instead of a space; which is necessary for `:syntax match` rules. 253 | 254 | # The `:if` block decides whether we want to write a simple string or a heredoc. 255 | # For some tokens, we just want to write a (possibly complex) regex:{{{ 256 | # 257 | # export const command_can_be_before: string = '...' 258 | #}}} 259 | # For other tokens, we want to write a (possibly long) list of names, via a heredoc:{{{ 260 | # 261 | # const builtin_func_list: list =<< trim END 262 | # abs 263 | # acos 264 | # add 265 | # ... 266 | # END 267 | # export const builtin_func: string = builtin_func_list->join() 268 | # 269 | # A heredoc makes it easier to review a list and check whether it contains 270 | # anything wrong. In particular if it's sorted. 271 | #}}} 272 | 273 | var lines: list = ['', '# ' .. what .. ' {{' .. '{1', ''] 274 | if what->eval()->typename() =~ '^list' 275 | lines += ['const ' .. what .. '_list: list =<< trim END'] 276 | + eval(what) 277 | # to suppress `E741: Value is locked: map() argument` 278 | ->copy() 279 | ->map((_, v: string): string => ' ' .. v) 280 | + ['END', ''] 281 | + ['export const ' .. what .. ': string = ' 282 | .. what .. '_list->join(' .. (match_rule ? '"\\|"' : '') .. ')'] 283 | else 284 | lines->add('export const ' .. what .. ': string = ' .. eval(what)->string()) 285 | endif 286 | lines->writefile(IMPORT_FILE, 'a') 287 | enddef 288 | 289 | #}}}1 290 | # Exported Variables {{{1 291 | # regexes {{{2 292 | # command_can_be_before {{{3 293 | 294 | # This regex should make sure that we're in a position where an Ex command could 295 | # appear right before. 296 | # Warning: Do *not* consume any token.{{{ 297 | # 298 | # Only use lookarounds to assert something about the current position. 299 | # If you consume a token, and it turns out that it's indeed a command, then – 300 | # to highlight it – you'll need to include a syntax group: 301 | # 302 | # set option=value 303 | # ^^^ 304 | # vim9Set ⊂ vim9MayBeCmd 305 | # 306 | # This creates a stack which might be problematic for a group defined with 307 | # `nextgroup=`. Suppose that `B ⊂ A`: 308 | # 309 | # BBB 310 | # AAAAAAAAA 311 | # 312 | # And you want `C` to match after `B`, so you define the latter like this: 313 | # 314 | # syntax ... B ... nextgroup=C 315 | # 316 | # If `C` goes beyond `A`, Vim will extend the latter: 317 | # 318 | # BBBCCCCCC 319 | # AAAAAAAAAAAA 320 | # ^^^ 321 | # extended 322 | # 323 | # That's because Vim wants `C` to be contained in `A`, just like its neighbor 324 | # `B`. But that fails if `B` has consumed the end of `A`: 325 | # 326 | # BBB 327 | # AAAAAAAAA 328 | # ^ 329 | # ✘ 330 | # 331 | # Here, Vim won't match `C` after `B`, because it would need to extend `A`; but 332 | # it can't, because it has reached its end: there's nothing left to extend. 333 | # 334 | # In practice, it means that you wouldn't be able to highlight arguments of 335 | # complex commands (like `:autocmd` or `:syntax`). There might be some 336 | # workarounds, but they come with their own pitfalls, and add too much 337 | # complexity. 338 | #}}} 339 | 340 | const command_can_be_before: string = 341 | # after a command, we know there must be a whitespace or a newline 342 | '\%(' 343 | .. '[ \t\n]\@=' 344 | .. '\|' 345 | # Special Case: An Ex command in the rhs of a mapping, right after `` or ``. 346 | .. '\c<\%(bar\|cr\)>' 347 | .. '\)' 348 | # but there must *not* be a binary operator 349 | # Warning: Try not to break the highlighting of a command whose first argument is the register `=`.{{{ 350 | # 351 | # That's why it's important to match a space after `=`; so that `:put` is 352 | # correctly highlighted when used to put an expression: 353 | # 354 | # put =1 + 2 355 | # 356 | # But not when used as a variable name: 357 | # 358 | # var put: number 359 | # put = 1 + 2 360 | #}}} 361 | .. '\%(' 362 | .. '\s*\%([-+*/%]=\|=\s\|=<<\|\.\.=\)' 363 | .. '\|' 364 | .. '\_s*\%(' 365 | .. '->' 366 | .. '\|' 367 | .. '[-+*/%]' 368 | # Need to match at least 1 space to avoid breaking the highlighting of a pattern passed as argument to a command.{{{ 369 | # 370 | # Example: 371 | # 372 | # catch /pattern/ 373 | # 374 | # This does mean that the pattern can't start with a space, but IMO it's a 375 | # corner case which doesn't warrant a fix (at least for now). We can still 376 | # write `\s` instead. 377 | # 378 | # ✘ 379 | # v 380 | # catch / pattern/ 381 | # catch /\spattern/ 382 | # ^^ 383 | # ✔ 384 | # 385 | # Or, if we *really* want a space, and not a tab, we can write `[ ]`. 386 | # 387 | # catch /[ ]pattern/ 388 | # ^^^ 389 | #}}} 390 | .. '\%(\s\+\)\@>' 391 | # necessary to be able to match `source` in `source % | eval 0` or `source % eval 0` 392 | .. '[^|<]' 393 | .. '\)' 394 | .. '\)\@!' 395 | 396 | # increment_invalid {{{3 397 | 398 | # This regex should match an increment/decrement operator used with an invalid expression.{{{ 399 | # 400 | # For example: 401 | # 402 | # ++Func() 403 | # ^----^ 404 | # ✘ 405 | #}}} 406 | 407 | const increment_invalid: string = '\%(++\|--\)' 408 | # let's assert what should *not* be matched 409 | .. '\%(' 410 | # that is, anything that is valid 411 | .. '\%(' 412 | # a simple variable identifier (`++name`) 413 | .. '\%([bgstvw]:\)\=\h\w*' 414 | # or an option name (`++&shiftwidth`) 415 | .. '\|' 416 | .. '&\%([lg]:\)\=[a-z]\{2,}' 417 | .. '\)' 418 | # it must be at the end of a line, or followed by a bracket/bar/dot/number sign{{{ 419 | # 420 | # # bracket 421 | # v 422 | # ++list[0] 423 | # ^-----^ 424 | # ✔ 425 | # 426 | # # bar 427 | # v 428 | # ++name | ... 429 | # 430 | # # dot 431 | # v 432 | # ++dict.key 433 | # ^------^ 434 | # ✔ 435 | # 436 | # # number sign 437 | # v 438 | # ++num # inline comment 439 | # ^---^ 440 | # ✔ 441 | # 442 | # We don't try to describe what follows the bracket or dot, because it seems 443 | # too complex. IOW, our regex is not perfect, but should be good enough 444 | # most of the time. 445 | #}}} 446 | .. '\s*\_[[|.#]' 447 | .. '\)\@!' 448 | 449 | # lambda_start, lambda_end {{{3 450 | 451 | # closing paren of arguments: 452 | # 453 | # var Lambda = (a, b) => a + b 454 | # ^ 455 | 456 | const lambda_end: string = ')' 457 | # start a lookbehind to assert the presence of the necessary arrow 458 | .. '\ze' 459 | # there could be a return type before 460 | .. '\%(:.\{-}\)\=' 461 | # the arrow 462 | # var Lambda = (a, b) => a + b 463 | # ^^ 464 | .. '\s\+=>' 465 | 466 | # opening paren of arguments: 467 | # 468 | # var Lambda = (a, b) => a + b 469 | # ^ 470 | const lambda_start: string = '(' 471 | # start a lookbehind to assert the presence of arguments 472 | .. '\ze' 473 | # start a group to make the arguments optional 474 | .. '\%(' 475 | # first argument 476 | .. '\s*\h\w*' 477 | # what follows can be complex 478 | .. '\%(' 479 | # for now, we just say that it's not an opening paren 480 | .. '[^(]' 481 | .. '\|' 482 | # or if it is, it must be preceded by `func` (used as a type) 483 | .. '\%(\map((_, v) => ... 499 | # ^ 500 | # ✔ 501 | # 502 | # ✘ 503 | # v 504 | # (l1 + l2)->map((_, v) => 0) 505 | # ^ 506 | # ✔ 507 | # 508 | # ✘ 509 | # v-------------v 510 | # Foo(name)->Bar((v) => v) 511 | # ^------^ 512 | # ✔ 513 | # 514 | # ✘ 515 | # v--------v 516 | # substitute(a, b, (m) => '', '') 517 | # ^^^ 518 | # ✔ 519 | # 520 | # range(123)->map((..._) => v + 1) 521 | # ^--^ 522 | # should be highlighted as an argument 523 | # 524 | # Also: 525 | # 526 | # echo ((): number => 0)() 527 | # ^----^ 528 | # this should be highlighted as a data type 529 | # 530 | # This is a special case, because the lambda has no arguments, and is contained 531 | # inside another syntax item (`vim9OperParen`). 532 | #}}} 533 | 534 | # legacy autoload invalid {{{3 535 | 536 | # In a Vim9 autoload script, when declaring an autoload function, we cannot 537 | # write `path#to#script#Func()`; `:export` must be used instead: 538 | # 539 | # ✘ 540 | # def path#to#script#Func() 541 | # 542 | # ✔ 543 | # export def Func() 544 | # 545 | # Let's highlight the old way as an error. 546 | # 547 | # --- 548 | # 549 | # Note that we use the `*` quantifier at the end, and not `+`. 550 | # That's because in legacy, it is allowed for an autoload 551 | # function name to be empty: 552 | # 553 | # def path#to#script#() 554 | # ^ 555 | # 556 | # We want to catch the error no matter what. 557 | 558 | const legacy_autoload_invalid: string = '\h\w*#\%(\w\|#\)*' 559 | 560 | # logical_not {{{3 561 | 562 | # This regex should match most binary operators. 563 | 564 | const logical_not: string = '/' 565 | # Don't highlight `!` when used after a command name:{{{ 566 | # 567 | # packadd! 568 | # ^ 569 | # 570 | # Note that we still want to highlight `!` when preceded by a paren: 571 | # 572 | # echo 'aaa' .. (!empty(...) ? ... : ...) 573 | # ^^ 574 | # }}} 575 | .. '\w\@10-9"^.(){}]' 589 | 590 | # maybe_dict_literal_key {{{3 591 | 592 | # This should match a sequence of non-whitespace which could be written where 593 | # a literal key in a dictionary is expected. 594 | # It should not match a valid key, because we want to highlight possible errors. 595 | 596 | const maybe_dict_literal_key: string = '/' 597 | # Start of positive lookbehind.{{{ 598 | # 599 | # Actually, it's not entirely correct. This would be simpler and better: 600 | # 601 | # \%([\n{,]\s*\)\@<= 602 | # 603 | # But it would also be more expensive (10x last time I checked). 604 | # Which doesn't seem like a big deal, because the regex is not used that 605 | # often; but still, for the moment, let's try an optimized regex. 606 | # 607 | # --- 608 | # 609 | # As an example, this lookbehind prevents the highlighting of `2` here: 610 | # 611 | # var d = { 612 | # key: 1 ? 2: 3 613 | # } 614 | # 615 | # But not here: 616 | # 617 | # var d = { 618 | # key: 1 ? 2: 3 619 | # } 620 | # 621 | # Note that both of these snippets are wrong, because `:` should be preceded 622 | # by a space. Still, this is a common temporary mistake; when it occurs, it 623 | # might be distracting to see a token (like a number) wrongly highlighted as 624 | # a string. 625 | #}}} 626 | .. '\%(' 627 | # there must be the start of a line or the start of a dictionary before a key 628 | .. '[{\n]' 629 | .. '\|' 630 | # Or there must be some space.{{{ 631 | # 632 | # But if there is, it should not preceded by a non-whitespace, unless it's a 633 | # comma (separating items), a curly brace (start of dictionary), or a 634 | # backslash (continuation line). 635 | #}}} 636 | .. '[^ \t\n,{\\]\@1>' 662 | # comparison operators 663 | .. '\|' .. '\%(' .. '[=!]=\|[<>]=\=\|[=!]\~\|is\|isnot' .. '\)' 664 | # optional modifier to respect or ignore the case 665 | .. '[?#]\=' 666 | .. '\)' 667 | # there must be a whitespace after 668 | .. '\_s\@=' 669 | # There should be an expression after.{{{ 670 | # 671 | # But an expression cannot start with a bar, nor with `<`. 672 | # It's most probably a special argument to some command: 673 | # 674 | # v 675 | # Cmd + | eval 0 676 | # nnoremap Cmd + eval 0 677 | # ^ 678 | #}}} 679 | .. '\%(\s*[|<]\)\@!' 680 | .. '"' 681 | 682 | # pattern_delimiter {{{3 683 | 684 | const pattern_delimiter: string = 685 | # let's discard invalid delimiters 686 | '[^' 687 | # Warning: keep this part at the start, so that `-` is not parsed as in `a-z`. 688 | # Ambiguity with `->` method call.{{{ 689 | # 690 | # Suppose you have a variable named `g`, to which you apply a method call: 691 | # 692 | # this is not the global command 693 | # ✘ 694 | # v 695 | # g->substitute('-', '', '') 696 | # ^ ^ 697 | # ✘ ✘ 698 | # those are not delimiters around a pattern 699 | # 700 | # `g` would be confused with the global command, and the dashes with delimiters 701 | # around its pattern. 702 | #}}} 703 | .. '-' 704 | # Ambiguity with assignment operators.{{{ 705 | # 706 | # Example: 707 | # 708 | # var s: number = 40 709 | # 710 | # pat rep flags 711 | # v---v vvv vv 712 | # s /= 20 / 2 / 2 713 | # ^ ^ ^ 714 | # delimiters 715 | # 716 | # The last line could be wrongly highlighted as a substitution command. 717 | # In reality, it's a number assignment which does this: 718 | # 719 | # s /= 20 / 2 / 2 720 | # ⇔ 721 | # s /= 10 / 2 722 | # ⇔ 723 | # s /= 5 724 | # ⇔ 725 | # s = s / 5 726 | # ⇔ 727 | # s = 40 / 5 728 | # ⇔ 729 | # s = 8 730 | #}}} 731 | .. '+*/%.' 732 | # Ambiguity with `:` used as separator between namespace and variable name.{{{ 733 | # 734 | # g:pattern:command 735 | # g:variable 736 | # 737 | # See `:help vim9-gotchas`. 738 | # 739 | # Don't try to be smart and find a fix for this. 740 | # It's trickier than it seems. 741 | # For example: 742 | # 743 | # g:a+b:command 744 | # ^ 745 | # 746 | # This is a valid global command, because there is no ambiguity with a global 747 | # variable; thanks to `+` which is a non word character. 748 | # But watch this: 749 | # 750 | # g:name = {key: 'value'} 751 | # ^---------^ 752 | # this is not a pattern 753 | # 754 | # I don't think it's possible for a simple regex to determine the nature of what 755 | # follows `g:`: a pattern vs a variable name. 756 | #}}} 757 | .. ':' 758 | # Not reliable:{{{ 759 | # 760 | # $ vim -Nu NONE +'vim9cmd g #pat# ls' 761 | # Pattern not found: pat˜ 762 | # ✔ 763 | # 764 | # $ vim -Nu NONE +'vim9cmd filter #pat# ls' 765 | # E476: Invalid command: vim9 filter #pat# ls˜ 766 | # ✘ 767 | # 768 | # Besides, let's be consistent; if in legacy, the comment leader doesn't 769 | # work, that should remain true in Vim9. 770 | #}}} 771 | .. '#' 772 | # a delimiter cannot be a whitespace (obviously) 773 | .. ' \t' 774 | # `:help pattern-delimiter` 775 | # In Vim9, `"` is still not a valid delimiter:{{{ 776 | # 777 | # ['aba bab']->repeat(3)->setline(1) 778 | # silent! substitute/nowhere// 779 | # :% s"b"B"g 780 | # E486: Pattern not found: nowhere˜ 781 | #}}} 782 | .. '[:alnum:]\"|' 783 | # end of assertion 784 | .. ']\@=' 785 | # now we have the guarantee that the next character (whatever it is) is a valid delimiter 786 | .. '.' 787 | # We still want to support a few delimiters (especially the popular `/`).{{{ 788 | # 789 | # But for these, we need to make sure that the start of the pattern won't 790 | # cause any trouble. Mainly, we need to assert that it can't be confused 791 | # with an assignment operator (nor a method call). 792 | #}}} 793 | # We could support `.`, but we don't, because it's too tricky.{{{ 794 | # 795 | # .. '\|' .. '\.\%(\.=\s\)\@!' 796 | # 797 | # Test against this: 798 | # 799 | # s.key ..= 'xxx' 800 | # ^ ^^ 801 | # 802 | # `s` would be wrongly matched as `:substitute`, and the dots as its pattern delimiters. 803 | # In reality, `s` is a dictionary. 804 | #}}} 805 | .. '\|' .. '->\@!\%(=\s\)\@!' 806 | .. '\|' .. '[+*/%]\%(=\s\)\@!' 807 | 808 | # option_can_be_after {{{3 809 | 810 | # This regex should make sure that we're in a position where a Vim option could 811 | # appear right after. 812 | 813 | const option_can_be_after: string = '\%(\%(' 814 | .. '^' 815 | .. '\|' 816 | .. '[' 817 | # Support the increment and decrement operators (`--` and `++`).{{{ 818 | # 819 | # Example: 820 | # 821 | # ++&l:foldlevel 822 | # ^^ 823 | #}}} 824 | .. '-+' 825 | .. ' \t!([' 826 | # Support an option after `` or `Bar`.{{{ 827 | # 828 | # Example: 829 | # 830 | # nnoremap &operatorfunc = Opfuncg@ 831 | # ^-----------^ 832 | #}}} 833 | .. '>' 834 | .. ']' 835 | .. '\)\@1<=' 836 | .. '\|' 837 | # support an expression in an `eval` heredoc 838 | .. '{\@1<=' 839 | .. '\)' 840 | 841 | # option_modifier {{{3 842 | 843 | # This regex should make sure that we're in a position where a Vim option could 844 | # appear right after. 845 | 846 | const option_modifier: string = 847 | '\%(' 848 | .. '&\%(vim\)\=' 849 | .. '\|' 850 | .. '[ set wrap eval 0 + 0 855 | # ^ 856 | # this is not a modifier which applies to 'wrap'; 857 | # this is the start of the Vim keycode 858 | #}}} 859 | .. '\%(\_s\||\)\@=' 860 | 861 | # option_sigil {{{3 862 | 863 | # sigil to refer to option value 864 | 865 | const option_sigil: string = '&\%([gl]:\)\=' 866 | 867 | # option_valid {{{3 868 | 869 | # This regex should make sure that we're matching valid characters for a Vim 870 | # option name. 871 | 872 | const option_valid: string = '\%(' 873 | # name of regular option 874 | .. '[a-z]\{2,}\>' 875 | .. '\|' 876 | # name of terminal option 877 | .. 't_[a-zA-Z0-9#%*:@_]\{2}' 878 | .. '\)' 879 | 880 | # wincmd_valid {{{3 881 | 882 | # This regex should make sure that we're giving a valid argument to `:wincmd`. 883 | 884 | def WincmdValid(): string 885 | var cmds: list = getcompletion('^w', 'help') 886 | ->filter((_, v: string): bool => v =~ '^CTRL-W_..\=$') 887 | ->map((_, v: string) => v->matchstr('CTRL-W_\zs.*')) 888 | ->sort() 889 | ->uniq() 890 | 891 | var one_char_cmds: list = cmds 892 | ->copy() 893 | ->filter((_, v: string): bool => v->len() == 1) 894 | var two_char_cmds: list = cmds 895 | ->copy() 896 | ->filter((_, v: string): bool => v->len() == 2) 897 | 898 | # `|` is missing 899 | one_char_cmds->add('|') 900 | 901 | for problematic: string in ['-', ']'] 902 | one_char_cmds->remove(one_char_cmds->index(problematic)) 903 | endfor 904 | 905 | return '/' 906 | .. '\s\@1<=' 907 | .. '\%(' 908 | # when including back the valid `-` and `]` commands, 909 | # we need to make sure they don't break the regex 910 | .. '[' .. '-\]' .. one_char_cmds->join('') .. ']' 911 | .. '\|' 912 | .. two_char_cmds->join('\|') 913 | .. '\)' 914 | .. '\_s\@=' 915 | .. '/' 916 | enddef 917 | 918 | const wincmd_valid: string = WincmdValid() 919 | #}}}2 920 | # names {{{2 921 | # builtin_func {{{3 922 | 923 | def Ambiguous(): list 924 | var cmds: list = getcompletion('', 'command') 925 | ->filter((_, v: string): bool => v =~ '^[a-z]') 926 | var funcs: list = getcompletion('', 'function') 927 | ->map((_, v: string) => v->substitute('()\=', '', '$')) 928 | var ambiguous: list 929 | for func: string in funcs 930 | if cmds->index(func) != -1 931 | ambiguous->add(func) 932 | endif 933 | endfor 934 | return ambiguous 935 | enddef 936 | 937 | const ambiguous: list = Ambiguous() 938 | 939 | const builtin_func: list = getcompletion('', 'function') 940 | # keep only builtin functions 941 | ->filter((_, v: string): bool => v[0] =~ '[a-z]' && v !~ '#') 942 | # remove noisy trailing parens 943 | ->map((_, v: string) => v->substitute('()\=$', '', '')) 944 | # if a function name can also be parsed as an Ex command, remove it 945 | ->filter((_, v: string): bool => ambiguous->index(v) == - 1) 946 | # those functions are missing because they don't work in our Vim build: 947 | # https://github.com/vim/vim/commit/90c2353365c5da40dec01b09e1f482983cf7f55d 948 | + ['debugbreak', 949 | 'luaeval', 950 | 'mzeval', 951 | 'perleval', 952 | 'pyeval', 953 | 'rubyeval'] 954 | 955 | # builtin_func_ambiguous {{{3 956 | 957 | # Functions whose names can be confused with Ex commands. 958 | # E.g. `:eval` vs `eval()`. 959 | const builtin_func_ambiguous: list = ambiguous 960 | 961 | # collation_class {{{3 962 | 963 | const collation_class: list = 964 | getcompletion('[:', 'help') 965 | ->filter((_, v: string): bool => v =~ '^\[:') 966 | ->map((_, v: string) => v->trim('[]:')) 967 | ->sort() 968 | 969 | # command_address_type {{{3 970 | 971 | const command_address_type: list = getcompletion('command -addr=', 'cmdline') 972 | 973 | # command_complete_type {{{3 974 | 975 | const command_complete_type: list = getcompletion('command -complete=', 'cmdline') 976 | # https://github.com/lacygoill/vim9-syntax/issues/4 977 | ->sort((i: string, j: string): number => j->stridx(i) == 0 ? 1 : -1) 978 | 979 | # command_modifier {{{3 980 | 981 | const command_modifier: list = MODIFIER_CMDS->Shorten(true) 982 | 983 | # command_name {{{3 984 | 985 | def CommandName(): list 986 | var to_shorten: list = getcompletion('', 'command') 987 | ->filter((_, v: string): bool => v =~ '^[a-z]') 988 | for cmd: string in SPECIAL_CMDS 989 | var i: number = to_shorten->index(cmd) 990 | if i == -1 991 | continue 992 | endif 993 | to_shorten->remove(i) 994 | endfor 995 | 996 | var shortened: list = to_shorten->Shorten() 997 | 998 | # this one is missing from `getcompletion()` 999 | shortened->add('addd') 1000 | 1001 | return shortened 1002 | enddef 1003 | 1004 | const command_name: list = CommandName() 1005 | 1006 | # default_highlighting_group {{{3 1007 | 1008 | def DefaultHighlightingGroup(): list 1009 | var completions: list = getcompletion('hl-', 'help') 1010 | ->map((_, v: string) => v->substitute('^hl-', '', '')) 1011 | for name: string in ['Ignore', 'Conceal', 'User1..9'] 1012 | var i: number = completions->index(name) 1013 | completions->remove(i) 1014 | endfor 1015 | completions += range(2, 8)->map((_, v: number): string => 'User' .. v) 1016 | return completions->sort() 1017 | enddef 1018 | 1019 | const default_highlighting_group: list = DefaultHighlightingGroup() 1020 | 1021 | # event {{{3 1022 | 1023 | const event: list = getcompletion('', 'event') 1024 | 1025 | # ex_special_characters {{{3 1026 | 1027 | # `:help cmdline-special` 1028 | const ex_special_characters: list = 1029 | getcompletion(':<', 'help')[1 :] 1030 | ->map((_, v: string) => v->trim(':<>')) 1031 | 1032 | # key_name {{{3 1033 | 1034 | def KeyName(): list 1035 | var completions: list = getcompletion('set <', 'cmdline') 1036 | ->map((_, v: string) => v->trim('<>')) 1037 | ->filter((_, v: string): bool => v !~ '^t_' && v !~ '^F\d\+$') 1038 | 1039 | # `Nop` and `SID` are missing 1040 | completions->add('Nop')->add('SID') 1041 | # for some reason, `Tab` is suggested twice 1042 | completions->remove(completions->index('Tab')) 1043 | # those keys are special, and need to be handled with dedicated rules 1044 | completions->remove(completions->index('Bar')) 1045 | completions->remove(completions->index('Cmd')) 1046 | 1047 | return completions->sort() 1048 | + ['F\d\{1,2}'] 1049 | # 1050 | # ^^^ 1051 | # Need a broad pattern to support special characters:{{{ 1052 | # 1053 | # 1054 | # ^ 1055 | # 1056 | # ^ 1057 | # 1058 | # ^ 1059 | # 1060 | # ^ 1061 | # 1062 | # ^ 1063 | #}}} 1064 | + ['.'] 1065 | enddef 1066 | 1067 | const key_name: list = KeyName() 1068 | 1069 | # option {{{3 1070 | 1071 | def Option(): list 1072 | var helptags: list 1073 | readfile($VIMRUNTIME .. '/doc/options.txt') 1074 | ->join() 1075 | ->substitute('\*''[a-z]\{2,\}''\*', 1076 | (m: list): string => !!helptags->add(m[0]) ? '' : '', 'g') 1077 | 1078 | var deprecated: list =<< trim END 1079 | *'biosk'* 1080 | *'bioskey'* 1081 | *'consk'* 1082 | *'conskey'* 1083 | *'fe'* 1084 | *'nobiosk'* 1085 | *'nobioskey'* 1086 | *'noconsk'* 1087 | *'noconskey'* 1088 | END 1089 | 1090 | for opt: string in deprecated 1091 | var i: number = helptags->index(opt) 1092 | if i == -1 1093 | continue 1094 | endif 1095 | helptags->remove(i) 1096 | endfor 1097 | 1098 | return helptags 1099 | ->map((_, v: string) => v->trim("*'")) 1100 | enddef 1101 | 1102 | const option: list = Option() 1103 | 1104 | # option_terminal {{{3 1105 | 1106 | # terminal options with only word characters 1107 | const option_terminal: list = 1108 | # getting all terminal options is trickier than it seems; 1109 | # let's use 2 sources to cover as much ground as possible 1110 | (getcompletion('t_', 'option') + getcompletion('t_', 'help')) 1111 | ->filter((_, v: string): bool => v =~ '^t_\w\w$') 1112 | ->sort() 1113 | ->uniq() 1114 | 1115 | # option_terminal_special {{{3 1116 | 1117 | # terminal options with at least 1 non-word character 1118 | const option_terminal_special: list = 1119 | (getcompletion('t_', 'option') + getcompletion('t_', 'help')) 1120 | ->map((_, v: string) => v->trim("'")) 1121 | ->filter((_, v: string): bool => v =~ '\W') 1122 | ->sort() 1123 | ->uniq() 1124 | #}}}1 1125 | 1126 | const IMPORT_FILE: string = expand(':p:h:h') .. '/import/vim9Language.vim' 1127 | var header: list =<< trim eval END 1128 | vim9script 1129 | 1130 | # DO NOT EDIT THIS FILE DIRECTLY. 1131 | # It is meant to be generated by ./tools/{expand(':p:t')} 1132 | END 1133 | header->writefile(IMPORT_FILE) 1134 | 1135 | AppendSection('builtin_func') 1136 | AppendSection('builtin_func_ambiguous', true) 1137 | AppendSection('collation_class', true) 1138 | AppendSection('command_address_type', true) 1139 | AppendSection('command_can_be_before') 1140 | AppendSection('command_complete_type', true) 1141 | AppendSection('command_modifier', true) 1142 | AppendSection('command_name') 1143 | AppendSection('default_highlighting_group') 1144 | AppendSection('event') 1145 | AppendSection('ex_special_characters', true) 1146 | AppendSection('increment_invalid') 1147 | AppendSection('key_name', true) 1148 | AppendSection('lambda_end') 1149 | AppendSection('lambda_start') 1150 | AppendSection('legacy_autoload_invalid') 1151 | AppendSection('logical_not') 1152 | AppendSection('mark_valid') 1153 | AppendSection('maybe_dict_literal_key') 1154 | AppendSection('most_operators') 1155 | AppendSection('option') 1156 | AppendSection('option_can_be_after') 1157 | AppendSection('option_modifier') 1158 | AppendSection('option_sigil') 1159 | AppendSection('option_terminal') 1160 | AppendSection('option_terminal_special', true) 1161 | AppendSection('option_valid') 1162 | AppendSection('pattern_delimiter') 1163 | AppendSection('wincmd_valid') 1164 | 1165 | execute 'edit ' .. IMPORT_FILE 1166 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | This script must be used to generate/update the import file: 2 | 3 | import/vim9Language.vim 4 | 5 | To do so, run this shell command while in the `tools/` directory: 6 | 7 | $ vim -Nu NONE -S GenerateImport.vim 8 | --------------------------------------------------------------------------------