vinter 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b24368a8f40b933537b9595275011f24a12e9e107f312ddf6a021dd2859408f
4
- data.tar.gz: 291c4943d43bf8d707c59436de7b2c71c4c0a3df262d3d289136d4e568e7d30d
3
+ metadata.gz: cc87fe083ad2cf26703f0ec71b7848c8417a04a6c5fb46d32192ca7c405788ca
4
+ data.tar.gz: f5df110e92c6e28e64ab5d8d6669eee580dfb03bed27b61de3c4ba39c43d1b8a
5
5
  SHA512:
6
- metadata.gz: 02ae4fea3f5fedc9bfcd1c4c3f8a06909ccf2578418f38b90582e015226966fcf0b3a9eff7f4ea71d14822533344bf5e751513706bb47c486506f9699bc0cc82
7
- data.tar.gz: a34eabed2cb6700db0569e103656d5a74c9c8f7901d90f0d37e469ed0b62cef715db66f3dade522234f59b135ab0d450e958595dec088591b14202076a87ff3c
6
+ metadata.gz: 31c5bfb4f9d843a48a51e0111bd2101c6c73392c88aea577d311c37a936d7b19eed39dace56834b97e07363dee873564f8a1d62b759a24b8b7936370776478ee
7
+ data.tar.gz: 701864470a24ad44a24ab398ce5962d21985caa86e2ce4df961fb8d8e7fa8c53b3be9778a7179a00d1842315e1a038aebbed77aea416cbd80f140ac6a6f0b8c6
data/lib/vinter/lexer.rb CHANGED
@@ -1,13 +1,590 @@
1
1
  module Vinter
2
2
  class Lexer
3
+ BUILTINS = [
4
+ "abs(",
5
+ "acos(",
6
+ "add(",
7
+ "and(",
8
+ "append(",
9
+ "appendbufline(",
10
+ "argc(",
11
+ "argidx(",
12
+ "arglistid(",
13
+ "argv(",
14
+ "argv(",
15
+ "asin(",
16
+ "assert_beeps(",
17
+ "assert_equal(",
18
+ "assert_equalfile(",
19
+ "assert_exception(",
20
+ "assert_fails(",
21
+ "assert_false(",
22
+ "assert_inrange(",
23
+ "assert_match(",
24
+ "assert_nobeep(",
25
+ "assert_notequal(",
26
+ "assert_notmatch(",
27
+ "assert_report(",
28
+ "assert_true(",
29
+ "atan(",
30
+ "atan2(",
31
+ "autocmd_add(",
32
+ "autocmd_delete(",
33
+ "autocmd_get(",
34
+ "balloon_gettext(",
35
+ "balloon_show(",
36
+ "balloon_split(",
37
+ "bindtextdomain(",
38
+ "blob2list(",
39
+ "browse(",
40
+ "browsedir(",
41
+ "bufadd(",
42
+ "bufexists(",
43
+ "buflisted(",
44
+ "bufload(",
45
+ "bufloaded(",
46
+ "bufname(",
47
+ "bufnr(",
48
+ "bufwinid(",
49
+ "bufwinnr(",
50
+ "byte2line(",
51
+ "byteidx(",
52
+ "byteidxcomp(",
53
+ "call(",
54
+ "ceil(",
55
+ "ch_canread(",
56
+ "ch_close(",
57
+ "ch_close_in(",
58
+ "ch_evalexpr(",
59
+ "ch_evalraw(",
60
+ "ch_getbufnr(",
61
+ "ch_getjob(",
62
+ "ch_info(",
63
+ "ch_log(",
64
+ "ch_logfile(",
65
+ "ch_open(",
66
+ "ch_read(",
67
+ "ch_readblob(",
68
+ "ch_readraw(",
69
+ "ch_sendexpr(",
70
+ "ch_sendraw(",
71
+ "ch_setoptions(",
72
+ "ch_status(",
73
+ "changenr(",
74
+ "char2nr(",
75
+ "charclass(",
76
+ "charcol(",
77
+ "charidx(",
78
+ "chdir(",
79
+ "cindent(",
80
+ "clearmatches(",
81
+ "col(",
82
+ "complete(",
83
+ "complete_add(",
84
+ "complete_check(",
85
+ "complete_info(",
86
+ "confirm(",
87
+ "copy(",
88
+ "cos(",
89
+ "cosh(",
90
+ "count(",
91
+ "cscope_connection(",
92
+ "cursor(",
93
+ "cursor(",
94
+ "debugbreak(",
95
+ "deepcopy(",
96
+ "delete(",
97
+ "deletebufline(",
98
+ "did_filetype(",
99
+ "diff(",
100
+ "diff_filler(",
101
+ "diff_hlID(",
102
+ "digraph_get(",
103
+ "digraph_getlist(",
104
+ "digraph_set(",
105
+ "digraph_setlist(",
106
+ "echoraw(",
107
+ "empty(",
108
+ "environ(",
109
+ "err_teapot(",
110
+ "escape(",
111
+ "eval(",
112
+ "eventhandler(",
113
+ "executable(",
114
+ "execute(",
115
+ "exepath(",
116
+ "exists(",
117
+ "exists_compiled(",
118
+ "exp(",
119
+ "expand(",
120
+ "expandcmd(",
121
+ "extend(",
122
+ "extendnew(",
123
+ "feedkeys(",
124
+ "filecopy(",
125
+ "filereadable(",
126
+ "filewritable(",
127
+ "filter(",
128
+ "finddir(",
129
+ "findfile(",
130
+ "flatten(",
131
+ "flattennew(",
132
+ "float2nr(",
133
+ "floor(",
134
+ "fmod(",
135
+ "fnameescape(",
136
+ "fnamemodify(",
137
+ "foldclosed(",
138
+ "foldclosedend(",
139
+ "foldlevel(",
140
+ "foldtext(",
141
+ "foldtextresult(",
142
+ "foreach(",
143
+ "foreground(",
144
+ "fullcommand(",
145
+ "funcref(",
146
+ "function(",
147
+ "garbagecollect(",
148
+ "get(",
149
+ "get(",
150
+ "get(",
151
+ "getbufinfo(",
152
+ "getbufline(",
153
+ "getbufoneline(",
154
+ "getbufvar(",
155
+ "getcellwidths(",
156
+ "getchangelist(",
157
+ "getchar(",
158
+ "getcharmod(",
159
+ "getcharpos(",
160
+ "getcharsearch(",
161
+ "getcharstr(",
162
+ "getcmdcompltype(",
163
+ "getcmdline(",
164
+ "getcmdpos(",
165
+ "getcmdscreenpos(",
166
+ "getcmdtype(",
167
+ "getcmdwintype(",
168
+ "getcompletion(",
169
+ "getcurpos(",
170
+ "getcursorcharpos(",
171
+ "getcwd(",
172
+ "getenv(",
173
+ "getfontname(",
174
+ "getfperm(",
175
+ "getfsize(",
176
+ "getftime(",
177
+ "getftype(",
178
+ "getimstatus(",
179
+ "getjumplist(",
180
+ "getline(",
181
+ "getline(",
182
+ "getloclist(",
183
+ "getloclist(",
184
+ "getmarklist(",
185
+ "getmatches(",
186
+ "getmousepos(",
187
+ "getmouseshape(",
188
+ "getpid(",
189
+ "getpos(",
190
+ "getqflist(",
191
+ "getqflist(",
192
+ "getreg(",
193
+ "getreginfo(",
194
+ "getregion(",
195
+ "getregionpos(",
196
+ "getregtype(",
197
+ "getscriptinfo(",
198
+ "gettabinfo(",
199
+ "gettabvar(",
200
+ "gettabwinvar(",
201
+ "gettagstack(",
202
+ "gettext(",
203
+ "getwininfo(",
204
+ "getwinpos(",
205
+ "getwinposx(",
206
+ "getwinposy(",
207
+ "getwinvar(",
208
+ "glob(",
209
+ "glob2regpat(",
210
+ "globpath(",
211
+ "has(",
212
+ "has_key(",
213
+ "haslocaldir(",
214
+ "hasmapto(",
215
+ "histadd(",
216
+ "histdel(",
217
+ "histget(",
218
+ "histnr(",
219
+ "hlID(",
220
+ "hlexists(",
221
+ "hlget(",
222
+ "hlset(",
223
+ "hostname(",
224
+ "iconv(",
225
+ "id(",
226
+ "indent(",
227
+ "index(",
228
+ "indexof(",
229
+ "input(",
230
+ "inputdialog(",
231
+ "inputlist(",
232
+ "inputrestore(",
233
+ "inputsave(",
234
+ "inputsecret(",
235
+ "insert(",
236
+ "instanceof(",
237
+ "interrupt(",
238
+ "invert(",
239
+ "isabsolutepath(",
240
+ "isdirectory(",
241
+ "isinf(",
242
+ "islocked(",
243
+ "isnan(",
244
+ "items(",
245
+ "job_getchannel(",
246
+ "job_info(",
247
+ "job_setoptions(",
248
+ "job_start(",
249
+ "job_status(",
250
+ "job_stop(",
251
+ "join(",
252
+ "js_decode(",
253
+ "js_encode(",
254
+ "json_decode(",
255
+ "json_encode(",
256
+ "keys(",
257
+ "keytrans(",
258
+ "len(",
259
+ "libcall(",
260
+ "libcallnr(",
261
+ "line(",
262
+ "line2byte(",
263
+ "lispindent(",
264
+ "list2blob(",
265
+ "list2str(",
266
+ "listener_add(",
267
+ "listener_flush(",
268
+ "listener_remove(",
269
+ "localtime(",
270
+ "log(",
271
+ "log10(",
272
+ "luaeval(",
273
+ "map(",
274
+ "maparg(",
275
+ "mapcheck(",
276
+ "maplist(",
277
+ "mapnew(",
278
+ "mapset(",
279
+ "match(",
280
+ "matchadd(",
281
+ "matchaddpos(",
282
+ "matcharg(",
283
+ "matchbufline(",
284
+ "matchdelete(",
285
+ "matchend(",
286
+ "matchfuzzy(",
287
+ "matchfuzzypos(",
288
+ "matchlist(",
289
+ "matchstr(",
290
+ "matchstrlist(",
291
+ "matchstrpos(",
292
+ "max(",
293
+ "menu_info(",
294
+ "min(",
295
+ "mkdir(",
296
+ "mode(",
297
+ "mzeval(",
298
+ "nextnonblank(",
299
+ "nr2char(",
300
+ "or(",
301
+ "pathshorten(",
302
+ "perleval(",
303
+ "popup_atcursor(",
304
+ "popup_beval(",
305
+ "popup_clear(",
306
+ "popup_close(",
307
+ "popup_create(",
308
+ "popup_dialog(",
309
+ "popup_filter_menu(",
310
+ "popup_filter_yesno(",
311
+ "popup_findecho(",
312
+ "popup_findinfo(",
313
+ "popup_findpreview(",
314
+ "popup_getoptions(",
315
+ "popup_getpos(",
316
+ "popup_hide(",
317
+ "popup_list(",
318
+ "popup_locate(",
319
+ "popup_menu(",
320
+ "popup_move(",
321
+ "popup_notification(",
322
+ "popup_setbuf(",
323
+ "popup_setoptions(",
324
+ "popup_settext(",
325
+ "popup_show(",
326
+ "pow(",
327
+ "prevnonblank(",
328
+ "printf(",
329
+ "prompt_getprompt(",
330
+ "prompt_setcallback(",
331
+ "prompt_setinterrupt(",
332
+ "prompt_setprompt(",
333
+ "prop_add(",
334
+ "prop_add_list(",
335
+ "prop_clear(",
336
+ "prop_find(",
337
+ "prop_list(",
338
+ "prop_remove(",
339
+ "prop_type_add(",
340
+ "prop_type_change(",
341
+ "prop_type_delete(",
342
+ "prop_type_get(",
343
+ "prop_type_list(",
344
+ "pum_getpos(",
345
+ "pumvisible(",
346
+ "py3eval(",
347
+ "pyeval(",
348
+ "pyxeval(",
349
+ "rand(",
350
+ "range(",
351
+ "readblob(",
352
+ "readdir(",
353
+ "readdirex(",
354
+ "readfile(",
355
+ "reduce(",
356
+ "reg_executing(",
357
+ "reg_recording(",
358
+ "reltime(",
359
+ "reltimefloat(",
360
+ "reltimestr(",
361
+ "remote_expr(",
362
+ "remote_foreground(",
363
+ "remote_peek(",
364
+ "remote_read(",
365
+ "remote_send(",
366
+ "remote_startserver(",
367
+ "remove(",
368
+ "remove(",
369
+ "remove(",
370
+ "rename(",
371
+ "repeat(",
372
+ "resolve(",
373
+ "reverse(",
374
+ "round(",
375
+ "rubyeval(",
376
+ "screenattr(",
377
+ "screenchar(",
378
+ "screenchars(",
379
+ "screencol(",
380
+ "screenpos(",
381
+ "screenrow(",
382
+ "screenstring(",
383
+ "search(",
384
+ "searchcount(",
385
+ "searchdecl(",
386
+ "searchpair(",
387
+ "searchpairpos(",
388
+ "searchpos(",
389
+ "server2client(",
390
+ "serverlist(",
391
+ "setbufline(",
392
+ "setbufvar(",
393
+ "setcellwidths(",
394
+ "setcharpos(",
395
+ "setcharsearch(",
396
+ "setcmdline(",
397
+ "setcmdpos(",
398
+ "setcursorcharpos(",
399
+ "setenv(",
400
+ "setfperm(",
401
+ "setline(",
402
+ "setloclist(",
403
+ "setloclist(",
404
+ "setmatches(",
405
+ "setpos(",
406
+ "setqflist(",
407
+ "setqflist(",
408
+ "setreg(",
409
+ "settabvar(",
410
+ "settabwinvar(",
411
+ "settagstack(",
412
+ "setwinvar(",
413
+ "sha256(",
414
+ "shellescape(",
415
+ "shiftwidth(",
416
+ "showdefinition(",
417
+ "sign_define(",
418
+ "sign_define(",
419
+ "sign_getdefined(",
420
+ "sign_getplaced(",
421
+ "sign_jump(",
422
+ "sign_place(",
423
+ "sign_placelist(",
424
+ "sign_undefine(",
425
+ "sign_undefine(",
426
+ "sign_unplace(",
427
+ "sign_unplacelist(",
428
+ "simplify(",
429
+ "sin(",
430
+ "sinh(",
431
+ "slice(",
432
+ "sort(",
433
+ "sound_clear(",
434
+ "sound_playevent(",
435
+ "sound_playfile(",
436
+ "sound_stop(",
437
+ "soundfold(",
438
+ "spellbadword(",
439
+ "spellsuggest(",
440
+ "split(",
441
+ "sqrt(",
442
+ "srand(",
443
+ "state(",
444
+ "str2float(",
445
+ "str2list(",
446
+ "str2nr(",
447
+ "strcharlen(",
448
+ "strcharpart(",
449
+ "strchars(",
450
+ "strdisplaywidth(",
451
+ "strftime(",
452
+ "strgetchar(",
453
+ "stridx(",
454
+ "string(",
455
+ "strlen(",
456
+ "strpart(",
457
+ "strptime(",
458
+ "strridx(",
459
+ "strtrans(",
460
+ "strutf16len(",
461
+ "strwidth(",
462
+ "submatch(",
463
+ "substitute(",
464
+ "swapfilelist(",
465
+ "swapinfo(",
466
+ "swapname(",
467
+ "synID(",
468
+ "synIDattr(",
469
+ "synIDtrans(",
470
+ "synconcealed(",
471
+ "synstack(",
472
+ "system(",
473
+ "systemlist(",
474
+ "tabpagebuflist(",
475
+ "tabpagenr(",
476
+ "tabpagewinnr(",
477
+ "tagfiles(",
478
+ "taglist(",
479
+ "tan(",
480
+ "tanh(",
481
+ "tempname(",
482
+ "term_dumpdiff(",
483
+ "term_dumpload(",
484
+ "term_dumpwrite(",
485
+ "term_getaltscreen(",
486
+ "term_getansicolors(",
487
+ "term_getattr(",
488
+ "term_getcursor(",
489
+ "term_getjob(",
490
+ "term_getline(",
491
+ "term_getscrolled(",
492
+ "term_getsize(",
493
+ "term_getstatus(",
494
+ "term_gettitle(",
495
+ "term_gettty(",
496
+ "term_list(",
497
+ "term_scrape(",
498
+ "term_sendkeys(",
499
+ "term_setansicolors(",
500
+ "term_setapi(",
501
+ "term_setkill(",
502
+ "term_setrestore(",
503
+ "term_setsize(",
504
+ "term_start(",
505
+ "term_wait(",
506
+ "terminalprops(",
507
+ "test_alloc_fail(",
508
+ "test_autochdir(",
509
+ "test_feedinput(",
510
+ "test_garbagecollect_now(",
511
+ "test_garbagecollect_soon(",
512
+ "test_getvalue(",
513
+ "test_gui_event(",
514
+ "test_ignore_error(",
515
+ "test_mswin_event(",
516
+ "test_null_blob(",
517
+ "test_null_channel(",
518
+ "test_null_dict(",
519
+ "test_null_function(",
520
+ "test_null_job(",
521
+ "test_null_list(",
522
+ "test_null_partial(",
523
+ "test_null_string(",
524
+ "test_option_not_set(",
525
+ "test_override(",
526
+ "test_refcount(",
527
+ "test_setmouse(",
528
+ "test_settime(",
529
+ "test_srand_seed(",
530
+ "test_unknown(",
531
+ "test_void(",
532
+ "timer_info(",
533
+ "timer_pause(",
534
+ "timer_start(",
535
+ "timer_stop(",
536
+ "timer_stopall(",
537
+ "tolower(",
538
+ "toupper(",
539
+ "tr(",
540
+ "trim(",
541
+ "trunc(",
542
+ "type(",
543
+ "typename(",
544
+ "undofile(",
545
+ "undotree(",
546
+ "uniq(",
547
+ "utf16idx(",
548
+ "values(",
549
+ "virtcol(",
550
+ "virtcol2col(",
551
+ "visualmode(",
552
+ "wildmenumode(",
553
+ "win_execute(",
554
+ "win_findbuf(",
555
+ "win_getid(",
556
+ "win_gettype(",
557
+ "win_gotoid(",
558
+ "win_id2tabwin(",
559
+ "win_id2win(",
560
+ "win_move_separator(",
561
+ "win_move_statusline(",
562
+ "win_screenpos(",
563
+ "win_splitmove(",
564
+ "winbufnr(",
565
+ "wincol(",
566
+ "windowsversion(",
567
+ "winheight(",
568
+ "winlayout(",
569
+ "winline(",
570
+ "winnr(",
571
+ "winrestcmd(",
572
+ "winrestview(",
573
+ "winsaveview(",
574
+ "winwidth(",
575
+ "wordcount(",
576
+ "writefile(",
577
+ "xor("
578
+ ]
3
579
  TOKEN_TYPES = {
4
580
  # Vim9 specific keywords
5
- keyword: /\b(if|else|elseif|endif|while|endwhile|for|endfor|def|enddef|function|endfunction|endfunc|return|const|var|final|import|export|class|extends|static|enum|type|vim9script|scriptencoding|abort|autocmd|echom|echoerr|echohl|echomsg|let|unlet|execute|exec|continue|break|try|catch|finally|endtry|throw|runtime|silent|delete|command|call|set|setlocal|syntax|sleep|source|nnoremap|nmap|inoremap|imap|vnoremap|vmap|xnoremap|xmap|cnoremap|cmap|noremap|map|var)\b/,
581
+ keyword: /\b(if|else|elseif|endif|while|endwhile|for|endfor|def|enddef|function|endfunction|endfunc|return|const|var|final|import|export|class|extends|static|enum|vim9script|scriptencoding|abort|autocmd|echom|echoerr|echohl|echomsg|let|unlet|continue|break|try|catch|finally|endtry|throw|runtime|silent|delete|command|call|set|setlocal|syntax|sleep|source|nnoremap|nmap|inoremap|imap|vnoremap|vmap|xnoremap|xmap|cnoremap|cmap|noremap|var)\b/,
6
582
  encodings: /\b(latin1|iso|koi8|macroman|cp437|cp737|cp775|cp850|cp852|cp855|cp857|cp860|cp861|cp862|cp863|cp865|cp866|cp869|cp874|cp1250|cp1251|cp1253|cp1254|cp1255|cp1256|cp1257|cp1258|cp932|euc\-jp|sjis|cp949|euc\-kr|cp936|euc\-cn|cp950|big5|euc\-tw|utf\-8|ucs\-2|ucs\-21e|utf\-16|utf\-16le|ucs\-4|ucs\-4le|ansi|japan|korea|prc|chinese|taiwan|utf8|unicode|ucs2be|ucs\-2be|ucs\-4be|utf\-32|utf\-32le)\b/,
7
- vimfuncs: /\b(win_execute|win_findbuf|win_getid|win_gettype|win_gotoid|win_id2tabwin|win_id2win|win_move_separator|win_move_statusline|win_screenpos|win_splitmove|setbufline)\b/,
8
- builtin_funcs: /\b(highlight|hi|exe|normal!|normal)\b/,
583
+ #builtin_funcs: /\b(highlight||normal!|normal|filter|match|extend|redraw!|setbufline)\b/,
584
+ type: /\b(number|list|dict|void|string)\b/,
585
+ builtin_funcs: /\b(#{Regexp.union(BUILTINS).source})\b/,
9
586
  # Identifiers can include # and special characters
10
- identifier: /\b[a-zA-Z_][a-zA-Z0-9_#]*\b/,
587
+ heredoc: /=<</,
11
588
  # Single-character operators
12
589
  operator: /[\+\-\*\/=%<>!&\|\.]/,
13
590
  # Multi-character operators handled separately
@@ -15,8 +592,9 @@ module Vinter
15
592
  # Handle both single and double quoted strings
16
593
  # string: /"(\\"|[^"])*"|'(\\'|[^'])*'/,
17
594
  register_access: /@[a-zA-Z0-9":.%#=*+~_\/\-]/,
595
+ identifier: /\b[a-zA-Z_][a-zA-Z0-9_#]*/,
18
596
  # Vim9 comments use #
19
- comment: /(#|").*/,
597
+ comment: /^(?: (?! g:).)*#.*/,
20
598
  whitespace: /\s+/,
21
599
  brace_open: /\{/,
22
600
  brace_close: /\}/,
@@ -29,7 +607,7 @@ module Vinter
29
607
  comma: /,/,
30
608
  backslash: /\\/,
31
609
  question_mark: /\?/,
32
- command_separator: /\|/
610
+ command_separator: /\|/,
33
611
  }
34
612
 
35
613
  CONTINUATION_OPERATORS = %w(. .. + - * / = == ==# ==? != > < >= <= && || ? : -> =>)
@@ -51,7 +629,7 @@ module Vinter
51
629
  }
52
630
 
53
631
  return true if recent_tokens.any? { |t|
54
- t && t[:type] == :identifier && ['match', 'region', 'keyword'].include?(t[:value])
632
+ t && t[:type] == :identifier && ['region', 'keyword'].include?(t[:value])
55
633
  }
56
634
 
57
635
  # Check for comparison operators that often use regex
@@ -90,22 +668,22 @@ module Vinter
90
668
  end
91
669
 
92
670
  # If we're at the start of a line and it begins with a quote
93
- if line_start && chunk.start_with?('"')
94
- # Find the end of the line
95
- line_end = find_unescaped_newline(chunk) || chunk.length
96
- comment_text = chunk[0...line_end]
97
-
98
- @tokens << {
99
- type: :comment,
100
- value: comment_text,
101
- line: @line_num,
102
- column: @column
103
- }
104
-
105
- @position += comment_text.length
106
- @column += comment_text.length
107
- next
108
- end
671
+ #if line_start && chunk.start_with?('"')
672
+ ## Find the end of the line
673
+ #line_end = find_unescaped_newline(chunk) || chunk.length
674
+ #comment_text = chunk[0...line_end]
675
+
676
+ #@tokens << {
677
+ #type: :comment,
678
+ #value: comment_text,
679
+ #line: @line_num,
680
+ #column: @column
681
+ #}
682
+
683
+ #@position += comment_text.length
684
+ #@column += comment_text.length
685
+ #next
686
+ #end
109
687
 
110
688
  # --- Interpolated String Handling ---
111
689
  if chunk.start_with?("$'")
@@ -270,7 +848,7 @@ module Vinter
270
848
  end
271
849
 
272
850
  # Check for keywords first, before other token types
273
- if match = chunk.match(/\A\b(if|else|elseif|endif|while|endwhile|for|endfor|def|enddef|function|endfunction|endfunc|return|const|var|final|import|export|class|extends|static|enum|type|vim9script|abort|autocmd|echoerr|echohl|echomsg|let|unlet|var|execute|setlocal|syntax|highlight|sleep|source)\b/)
851
+ if match = chunk.match(/\A\b(if|else|elseif|endif|while|endwhile|for|endfor|def|enddef|function|endfunction|endfunc|return|const|var|final|import|export|class|extends|static|enum|vim9script|abort|autocmd|echoerr|echohl|echomsg|let|unlet|var|setlocal|syntax|highlight|sleep|source)\b/)
274
852
  @tokens << {
275
853
  type: :keyword,
276
854
  value: match[0],
@@ -375,7 +953,7 @@ module Vinter
375
953
 
376
954
 
377
955
  # Handle global variables with g: prefix
378
- if match = chunk.match(/\Ag:[a-zA-Z_][a-zA-Z0-9_]*/)
956
+ if match = chunk.match(/\Ag:[a-zA-Z_][\w#]*/)
379
957
  @tokens << {
380
958
  type: :global_variable,
381
959
  value: match[0],