@fresh-editor/fresh-editor 0.2.12 → 0.2.13

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +10 -0
  3. package/package.json +1 -1
  4. package/plugins/audit_mode.ts +79 -58
  5. package/plugins/check-types.sh +1 -0
  6. package/plugins/clangd-lsp.ts +9 -6
  7. package/plugins/clangd_support.ts +12 -8
  8. package/plugins/code-tour.ts +15 -10
  9. package/plugins/config-schema.json +40 -3
  10. package/plugins/csharp_support.ts +15 -10
  11. package/plugins/css-lsp.ts +9 -6
  12. package/plugins/diagnostics_panel.ts +25 -18
  13. package/plugins/examples/README.md +1 -2
  14. package/plugins/examples/async_demo.ts +28 -28
  15. package/plugins/examples/bookmarks.ts +34 -32
  16. package/plugins/examples/buffer_query_demo.ts +20 -20
  17. package/plugins/examples/hello_world.ts +46 -10
  18. package/plugins/examples/virtual_buffer_demo.ts +16 -12
  19. package/plugins/find_references.ts +7 -5
  20. package/plugins/git_blame.ts +13 -9
  21. package/plugins/git_explorer.ts +9 -6
  22. package/plugins/git_find_file.ts +7 -5
  23. package/plugins/git_grep.ts +3 -2
  24. package/plugins/git_gutter.ts +15 -10
  25. package/plugins/git_log.ts +27 -18
  26. package/plugins/go-lsp.ts +9 -6
  27. package/plugins/html-lsp.ts +9 -6
  28. package/plugins/java-lsp.ts +9 -6
  29. package/plugins/json-lsp.ts +9 -6
  30. package/plugins/latex-lsp.ts +9 -6
  31. package/plugins/lib/finder.ts +1 -0
  32. package/plugins/lib/fresh.d.ts +139 -14
  33. package/plugins/live_grep.ts +3 -2
  34. package/plugins/markdown_compose.ts +33 -23
  35. package/plugins/markdown_source.ts +15 -10
  36. package/plugins/marksman-lsp.ts +9 -6
  37. package/plugins/merge_conflict.ts +33 -22
  38. package/plugins/odin-lsp.ts +9 -6
  39. package/plugins/path_complete.ts +3 -2
  40. package/plugins/pkg.ts +70 -48
  41. package/plugins/python-lsp.ts +9 -6
  42. package/plugins/rust-lsp.ts +102 -6
  43. package/plugins/search_replace.ts +32 -21
  44. package/plugins/templ-lsp.ts +9 -6
  45. package/plugins/test_i18n.ts +3 -2
  46. package/plugins/theme_editor.i18n.json +28 -14
  47. package/plugins/theme_editor.ts +1230 -495
  48. package/plugins/typescript-lsp.ts +9 -6
  49. package/plugins/vi_mode.ts +487 -297
  50. package/plugins/welcome.ts +9 -6
  51. package/plugins/zig-lsp.ts +9 -6
@@ -324,132 +324,157 @@ function handleMotionWithOperator(motionAction: string): void {
324
324
  // ============================================================================
325
325
 
326
326
  // Navigation (all support count prefix, e.g., 5j moves down 5 lines)
327
- globalThis.vi_left = function (): void {
327
+ function vi_left() : void {
328
328
  executeWithCount("move_left");
329
- };
329
+ }
330
+ registerHandler("vi_left", vi_left);
330
331
 
331
- globalThis.vi_down = function (): void {
332
+ function vi_down() : void {
332
333
  executeWithCount("move_down");
333
- };
334
+ }
335
+ registerHandler("vi_down", vi_down);
334
336
 
335
- globalThis.vi_up = function (): void {
337
+ function vi_up() : void {
336
338
  executeWithCount("move_up");
337
- };
339
+ }
340
+ registerHandler("vi_up", vi_up);
338
341
 
339
- globalThis.vi_right = function (): void {
342
+ function vi_right() : void {
340
343
  executeWithCount("move_right");
341
- };
344
+ }
345
+ registerHandler("vi_right", vi_right);
342
346
 
343
- globalThis.vi_word = function (): void {
347
+ function vi_word() : void {
344
348
  executeWithCount("move_word_right");
345
- };
349
+ }
350
+ registerHandler("vi_word", vi_word);
346
351
 
347
- globalThis.vi_word_back = function (): void {
352
+ function vi_word_back() : void {
348
353
  executeWithCount("move_word_left");
349
- };
354
+ }
355
+ registerHandler("vi_word_back", vi_word_back);
350
356
 
351
- globalThis.vi_word_end = function (): void {
357
+ function vi_word_end() : void {
352
358
  // Move to end of word - for count, repeat the whole operation
353
359
  const count = consumeCount();
354
360
  for (let i = 0; i < count; i++) {
355
361
  editor.executeAction("move_word_right");
356
362
  editor.executeAction("move_left");
357
363
  }
358
- };
364
+ }
365
+ registerHandler("vi_word_end", vi_word_end);
359
366
 
360
- globalThis.vi_line_start = function (): void {
367
+ function vi_line_start() : void {
361
368
  consumeCount(); // Count doesn't apply to line start
362
369
  editor.executeAction("move_line_start");
363
- };
370
+ }
371
+ registerHandler("vi_line_start", vi_line_start);
364
372
 
365
- globalThis.vi_line_end = function (): void {
373
+ function vi_line_end() : void {
366
374
  consumeCount(); // Count doesn't apply to line end
367
375
  editor.executeAction("move_line_end");
368
- };
376
+ }
377
+ registerHandler("vi_line_end", vi_line_end);
369
378
 
370
- globalThis.vi_first_non_blank = function (): void {
379
+ function vi_first_non_blank() : void {
371
380
  consumeCount(); // Count doesn't apply
372
381
  editor.executeAction("move_line_start");
373
382
  // TODO: skip whitespace
374
- };
383
+ }
384
+ registerHandler("vi_first_non_blank", vi_first_non_blank);
375
385
 
376
- globalThis.vi_doc_start = function (): void {
386
+ function vi_doc_start() : void {
377
387
  consumeCount(); // Count doesn't apply
378
388
  editor.executeAction("move_document_start");
379
- };
389
+ }
390
+ registerHandler("vi_doc_start", vi_doc_start);
380
391
 
381
- globalThis.vi_doc_end = function (): void {
392
+ function vi_doc_end() : void {
382
393
  consumeCount(); // Count doesn't apply
383
394
  editor.executeAction("move_document_end");
384
- };
395
+ }
396
+ registerHandler("vi_doc_end", vi_doc_end);
385
397
 
386
- globalThis.vi_page_down = function (): void {
398
+ function vi_page_down() : void {
387
399
  executeWithCount("page_down");
388
- };
400
+ }
401
+ registerHandler("vi_page_down", vi_page_down);
389
402
 
390
- globalThis.vi_page_up = function (): void {
403
+ function vi_page_up() : void {
391
404
  executeWithCount("page_up");
392
- };
405
+ }
406
+ registerHandler("vi_page_up", vi_page_up);
393
407
 
394
- globalThis.vi_matching_bracket = function (): void {
408
+ function vi_matching_bracket() : void {
395
409
  editor.executeAction("go_to_matching_bracket");
396
- };
410
+ }
411
+ registerHandler("vi_matching_bracket", vi_matching_bracket);
397
412
 
398
413
  // Mode switching
399
- globalThis.vi_insert_before = function (): void {
414
+ function vi_insert_before() : void {
400
415
  switchMode("insert");
401
- };
416
+ }
417
+ registerHandler("vi_insert_before", vi_insert_before);
402
418
 
403
- globalThis.vi_insert_after = function (): void {
419
+ function vi_insert_after() : void {
404
420
  editor.executeAction("move_right");
405
421
  switchMode("insert");
406
- };
422
+ }
423
+ registerHandler("vi_insert_after", vi_insert_after);
407
424
 
408
- globalThis.vi_insert_line_start = function (): void {
425
+ function vi_insert_line_start() : void {
409
426
  editor.executeAction("move_line_start");
410
427
  switchMode("insert");
411
- };
428
+ }
429
+ registerHandler("vi_insert_line_start", vi_insert_line_start);
412
430
 
413
- globalThis.vi_insert_line_end = function (): void {
431
+ function vi_insert_line_end() : void {
414
432
  editor.executeAction("move_line_end");
415
433
  switchMode("insert");
416
- };
434
+ }
435
+ registerHandler("vi_insert_line_end", vi_insert_line_end);
417
436
 
418
- globalThis.vi_open_below = function (): void {
437
+ function vi_open_below() : void {
419
438
  editor.executeAction("move_line_end");
420
439
  editor.executeAction("insert_newline");
421
440
  switchMode("insert");
422
- };
441
+ }
442
+ registerHandler("vi_open_below", vi_open_below);
423
443
 
424
- globalThis.vi_open_above = function (): void {
444
+ function vi_open_above() : void {
425
445
  editor.executeAction("move_line_start");
426
446
  editor.executeAction("insert_newline");
427
447
  editor.executeAction("move_up");
428
448
  switchMode("insert");
429
- };
449
+ }
450
+ registerHandler("vi_open_above", vi_open_above);
430
451
 
431
- globalThis.vi_escape = function (): void {
452
+ function vi_escape() : void {
432
453
  switchMode("normal");
433
- };
454
+ }
455
+ registerHandler("vi_escape", vi_escape);
434
456
 
435
457
  // Operators
436
- globalThis.vi_delete_operator = function (): void {
458
+ function vi_delete_operator() : void {
437
459
  state.pendingOperator = "d";
438
460
  switchMode("operator-pending");
439
- };
461
+ }
462
+ registerHandler("vi_delete_operator", vi_delete_operator);
440
463
 
441
- globalThis.vi_change_operator = function (): void {
464
+ function vi_change_operator() : void {
442
465
  state.pendingOperator = "c";
443
466
  switchMode("operator-pending");
444
- };
467
+ }
468
+ registerHandler("vi_change_operator", vi_change_operator);
445
469
 
446
- globalThis.vi_yank_operator = function (): void {
470
+ function vi_yank_operator() : void {
447
471
  state.pendingOperator = "y";
448
472
  switchMode("operator-pending");
449
- };
473
+ }
474
+ registerHandler("vi_yank_operator", vi_yank_operator);
450
475
 
451
476
  // Line operations (dd, cc, yy) - support count prefix (3dd = delete 3 lines)
452
- globalThis.vi_delete_line = function (): void {
477
+ function vi_delete_line() : void {
453
478
  const count = consumeCount();
454
479
  state.lastChange = { type: "line-op", action: "delete_line", count };
455
480
  if (count === 1) {
@@ -458,9 +483,10 @@ globalThis.vi_delete_line = function (): void {
458
483
  editor.executeActions([{ action: "delete_line", count }]);
459
484
  }
460
485
  switchMode("normal");
461
- };
486
+ }
487
+ registerHandler("vi_delete_line", vi_delete_line);
462
488
 
463
- globalThis.vi_change_line = function (): void {
489
+ function vi_change_line() : void {
464
490
  const count = consumeCount();
465
491
  state.lastChange = { type: "line-op", action: "change_line", count };
466
492
  editor.executeAction("move_line_start");
@@ -471,9 +497,10 @@ globalThis.vi_change_line = function (): void {
471
497
  editor.deleteRange(editor.getActiveBufferId(), start, end);
472
498
  }
473
499
  switchMode("insert");
474
- };
500
+ }
501
+ registerHandler("vi_change_line", vi_change_line);
475
502
 
476
- globalThis.vi_yank_line = function (): void {
503
+ function vi_yank_line() : void {
477
504
  const count = consumeCount();
478
505
  // select_line selects current line and moves cursor to next line
479
506
  if (count === 1) {
@@ -489,28 +516,32 @@ globalThis.vi_yank_line = function (): void {
489
516
  state.lastYankWasLinewise = true;
490
517
  editor.setStatus(editor.t("status.yanked_lines", { count: String(count) }));
491
518
  switchMode("normal");
492
- };
519
+ }
520
+ registerHandler("vi_yank_line", vi_yank_line);
493
521
 
494
522
  // Single character operations - support count prefix (3x = delete 3 chars)
495
- globalThis.vi_delete_char = function (): void {
523
+ function vi_delete_char() : void {
496
524
  const count = consumeCount();
497
525
  state.lastChange = { type: "simple", action: "delete_forward", count };
498
526
  executeWithCount("delete_forward", count);
499
- };
527
+ }
528
+ registerHandler("vi_delete_char", vi_delete_char);
500
529
 
501
- globalThis.vi_delete_char_before = function (): void {
530
+ function vi_delete_char_before() : void {
502
531
  const count = consumeCount();
503
532
  state.lastChange = { type: "simple", action: "delete_backward", count };
504
533
  executeWithCount("delete_backward", count);
505
- };
534
+ }
535
+ registerHandler("vi_delete_char_before", vi_delete_char_before);
506
536
 
507
- globalThis.vi_replace_char = function (): void {
537
+ function vi_replace_char() : void {
508
538
  // TODO: implement character replacement (need to read next char)
509
539
  editor.setStatus(editor.t("status.replace_not_implemented"));
510
- };
540
+ }
541
+ registerHandler("vi_replace_char", vi_replace_char);
511
542
 
512
543
  // Substitute (delete char and enter insert mode)
513
- globalThis.vi_substitute = function (): void {
544
+ function vi_substitute() : void {
514
545
  const count = consumeCount();
515
546
  state.lastChange = { type: "simple", action: "substitute", count };
516
547
  if (count > 1) {
@@ -519,10 +550,11 @@ globalThis.vi_substitute = function (): void {
519
550
  editor.executeAction("delete_forward");
520
551
  }
521
552
  switchMode("insert");
522
- };
553
+ }
554
+ registerHandler("vi_substitute", vi_substitute);
523
555
 
524
556
  // Delete to end of line
525
- globalThis.vi_delete_to_end = function (): void {
557
+ function vi_delete_to_end() : void {
526
558
  state.lastChange = { type: "operator-motion", operator: "d", motion: "move_line_end" };
527
559
  const start = editor.getCursorPosition();
528
560
  editor.executeAction("move_line_end");
@@ -530,10 +562,11 @@ globalThis.vi_delete_to_end = function (): void {
530
562
  if (start !== null && end !== null && end > start) {
531
563
  editor.deleteRange(editor.getActiveBufferId(), start, end);
532
564
  }
533
- };
565
+ }
566
+ registerHandler("vi_delete_to_end", vi_delete_to_end);
534
567
 
535
568
  // Change to end of line
536
- globalThis.vi_change_to_end = function (): void {
569
+ function vi_change_to_end() : void {
537
570
  state.lastChange = { type: "operator-motion", operator: "c", motion: "move_line_end" };
538
571
  const start = editor.getCursorPosition();
539
572
  editor.executeAction("move_line_end");
@@ -542,10 +575,11 @@ globalThis.vi_change_to_end = function (): void {
542
575
  editor.deleteRange(editor.getActiveBufferId(), start, end);
543
576
  }
544
577
  switchMode("insert");
545
- };
578
+ }
579
+ registerHandler("vi_change_to_end", vi_change_to_end);
546
580
 
547
581
  // Clipboard
548
- globalThis.vi_paste_after = function (): void {
582
+ function vi_paste_after() : void {
549
583
  if (state.lastYankWasLinewise) {
550
584
  // Line-wise paste: go to next line start and paste there
551
585
  // The yanked text includes trailing \n which pushes subsequent lines down
@@ -559,9 +593,10 @@ globalThis.vi_paste_after = function (): void {
559
593
  editor.executeAction("move_right");
560
594
  editor.executeAction("paste");
561
595
  }
562
- };
596
+ }
597
+ registerHandler("vi_paste_after", vi_paste_after);
563
598
 
564
- globalThis.vi_paste_before = function (): void {
599
+ function vi_paste_before() : void {
565
600
  if (state.lastYankWasLinewise) {
566
601
  // Line-wise paste: paste at current line start
567
602
  // The yanked text includes trailing \n which pushes current line down
@@ -573,19 +608,22 @@ globalThis.vi_paste_before = function (): void {
573
608
  // Character-wise paste: insert at cursor
574
609
  editor.executeAction("paste");
575
610
  }
576
- };
611
+ }
612
+ registerHandler("vi_paste_before", vi_paste_before);
577
613
 
578
614
  // Undo/Redo
579
- globalThis.vi_undo = function (): void {
615
+ function vi_undo() : void {
580
616
  editor.executeAction("undo");
581
- };
617
+ }
618
+ registerHandler("vi_undo", vi_undo);
582
619
 
583
- globalThis.vi_redo = function (): void {
620
+ function vi_redo() : void {
584
621
  editor.executeAction("redo");
585
- };
622
+ }
623
+ registerHandler("vi_redo", vi_redo);
586
624
 
587
625
  // Repeat last change (. command)
588
- globalThis.vi_repeat = async function (): Promise<void> {
626
+ async function vi_repeat() : Promise<void> {
589
627
  if (!state.lastChange) {
590
628
  editor.setStatus(editor.t("status.no_change_to_repeat"));
591
629
  return;
@@ -680,106 +718,128 @@ globalThis.vi_repeat = async function (): Promise<void> {
680
718
  break;
681
719
  }
682
720
  }
683
- };
721
+ }
722
+ registerHandler("vi_repeat", vi_repeat);
684
723
 
685
724
  // Join lines
686
- globalThis.vi_join = function (): void {
725
+ function vi_join() : void {
687
726
  editor.executeAction("move_line_end");
688
727
  editor.executeAction("delete_forward");
689
728
  editor.executeAction("insert_text_at_cursor");
690
- };
729
+ }
730
+ registerHandler("vi_join", vi_join);
691
731
 
692
732
  // Search
693
- globalThis.vi_search_forward = function (): void {
733
+ function vi_search_forward() : void {
694
734
  editor.executeAction("search");
695
- };
735
+ }
736
+ registerHandler("vi_search_forward", vi_search_forward);
696
737
 
697
- globalThis.vi_search_backward = function (): void {
738
+ function vi_search_backward() : void {
698
739
  // Use same search dialog, user can search backward manually
699
740
  editor.executeAction("search");
700
- };
741
+ }
742
+ registerHandler("vi_search_backward", vi_search_backward);
701
743
 
702
- globalThis.vi_find_next = function (): void {
744
+ function vi_find_next() : void {
703
745
  editor.executeAction("find_next");
704
- };
746
+ }
747
+ registerHandler("vi_find_next", vi_find_next);
705
748
 
706
- globalThis.vi_find_prev = function (): void {
749
+ function vi_find_prev() : void {
707
750
  editor.executeAction("find_previous");
708
- };
751
+ }
752
+ registerHandler("vi_find_prev", vi_find_prev);
709
753
 
710
754
  // Center view
711
- globalThis.vi_center_cursor = function (): void {
755
+ function vi_center_cursor() : void {
712
756
  editor.executeAction("center_cursor");
713
- };
757
+ }
758
+ registerHandler("vi_center_cursor", vi_center_cursor);
714
759
 
715
760
  // Half page movements
716
- globalThis.vi_half_page_down = function (): void {
761
+ function vi_half_page_down() : void {
717
762
  // Approximate half page with multiple down movements
718
763
  const count = consumeCount();
719
764
  editor.executeActions([{ action: "move_down", count: 10 * count }]);
720
- };
765
+ }
766
+ registerHandler("vi_half_page_down", vi_half_page_down);
721
767
 
722
- globalThis.vi_half_page_up = function (): void {
768
+ function vi_half_page_up() : void {
723
769
  const count = consumeCount();
724
770
  editor.executeActions([{ action: "move_up", count: 10 * count }]);
725
- };
771
+ }
772
+ registerHandler("vi_half_page_up", vi_half_page_up);
726
773
 
727
774
  // ============================================================================
728
775
  // Count Prefix (digit keys 1-9, and 0 after initial digit)
729
776
  // ============================================================================
730
777
 
731
778
  // Digit handlers for count prefix
732
- globalThis.vi_digit_1 = function (): void { accumulateCount(1); };
733
- globalThis.vi_digit_2 = function (): void { accumulateCount(2); };
734
- globalThis.vi_digit_3 = function (): void { accumulateCount(3); };
735
- globalThis.vi_digit_4 = function (): void { accumulateCount(4); };
736
- globalThis.vi_digit_5 = function (): void { accumulateCount(5); };
737
- globalThis.vi_digit_6 = function (): void { accumulateCount(6); };
738
- globalThis.vi_digit_7 = function (): void { accumulateCount(7); };
739
- globalThis.vi_digit_8 = function (): void { accumulateCount(8); };
740
- globalThis.vi_digit_9 = function (): void { accumulateCount(9); };
779
+ function vi_digit_1() : void { accumulateCount(1); }
780
+ registerHandler("vi_digit_1", vi_digit_1);
781
+ function vi_digit_2() : void { accumulateCount(2); }
782
+ registerHandler("vi_digit_2", vi_digit_2);
783
+ function vi_digit_3() : void { accumulateCount(3); }
784
+ registerHandler("vi_digit_3", vi_digit_3);
785
+ function vi_digit_4() : void { accumulateCount(4); }
786
+ registerHandler("vi_digit_4", vi_digit_4);
787
+ function vi_digit_5() : void { accumulateCount(5); }
788
+ registerHandler("vi_digit_5", vi_digit_5);
789
+ function vi_digit_6() : void { accumulateCount(6); }
790
+ registerHandler("vi_digit_6", vi_digit_6);
791
+ function vi_digit_7() : void { accumulateCount(7); }
792
+ registerHandler("vi_digit_7", vi_digit_7);
793
+ function vi_digit_8() : void { accumulateCount(8); }
794
+ registerHandler("vi_digit_8", vi_digit_8);
795
+ function vi_digit_9() : void { accumulateCount(9); }
796
+ registerHandler("vi_digit_9", vi_digit_9);
741
797
 
742
798
  // 0 is special: if count is already started, it appends; otherwise it's "go to line start"
743
- globalThis.vi_digit_0_or_line_start = function (): void {
799
+ function vi_digit_0_or_line_start() : void {
744
800
  if (state.count !== null) {
745
801
  accumulateCount(0);
746
802
  } else {
747
803
  editor.executeAction("move_line_start");
748
804
  }
749
- };
805
+ }
806
+ registerHandler("vi_digit_0_or_line_start", vi_digit_0_or_line_start);
750
807
 
751
808
  // 0 in operator-pending mode: if count is started, append; otherwise apply operator to line start
752
- globalThis.vi_op_digit_0_or_line_start = function (): void {
809
+ function vi_op_digit_0_or_line_start() : void {
753
810
  if (state.count !== null) {
754
811
  accumulateCount(0);
755
812
  } else {
756
813
  handleMotionWithOperator("move_line_start");
757
814
  }
758
- };
815
+ }
816
+ registerHandler("vi_op_digit_0_or_line_start", vi_op_digit_0_or_line_start);
759
817
 
760
818
  // ============================================================================
761
819
  // Visual Mode
762
820
  // ============================================================================
763
821
 
764
822
  // Enter character-wise visual mode
765
- globalThis.vi_visual_char = function (): void {
823
+ function vi_visual_char() : void {
766
824
  state.visualAnchor = editor.getCursorPosition();
767
825
  // Select current character to start visual selection
768
826
  editor.executeAction("select_right");
769
827
  switchMode("visual");
770
- };
828
+ }
829
+ registerHandler("vi_visual_char", vi_visual_char);
771
830
 
772
831
  // Enter line-wise visual mode
773
- globalThis.vi_visual_line = function (): void {
832
+ function vi_visual_line() : void {
774
833
  state.visualAnchor = editor.getCursorPosition();
775
834
  // Select current line
776
835
  editor.executeAction("move_line_start");
777
836
  editor.executeAction("select_line");
778
837
  switchMode("visual-line");
779
- };
838
+ }
839
+ registerHandler("vi_visual_line", vi_visual_line);
780
840
 
781
841
  // Toggle between visual and visual-line modes
782
- globalThis.vi_visual_toggle_line = function (): void {
842
+ function vi_visual_toggle_line() : void {
783
843
  if (state.mode === "visual") {
784
844
  // Switch to line mode - extend selection to full lines
785
845
  editor.executeAction("select_line");
@@ -792,10 +852,11 @@ globalThis.vi_visual_toggle_line = function (): void {
792
852
  editor.setEditorMode("vi-visual");
793
853
  editor.setStatus(getModeIndicator("visual"));
794
854
  }
795
- };
855
+ }
856
+ registerHandler("vi_visual_toggle_line", vi_visual_toggle_line);
796
857
 
797
858
  // Enter visual block mode (Ctrl-v)
798
- globalThis.vi_visual_block = async function (): Promise<void> {
859
+ async function vi_visual_block() : Promise<void> {
799
860
  // Store anchor position for block selection
800
861
  state.visualAnchor = editor.getCursorPosition();
801
862
 
@@ -811,190 +872,222 @@ globalThis.vi_visual_block = async function (): Promise<void> {
811
872
  // Select current character to start
812
873
  editor.executeAction("select_right");
813
874
  switchMode("visual-block");
814
- };
875
+ }
876
+ registerHandler("vi_visual_block", vi_visual_block);
815
877
 
816
878
  // Visual block mode motions - these extend the rectangular selection
817
- globalThis.vi_vblock_left = function (): void {
879
+ function vi_vblock_left() : void {
818
880
  executeWithCount("select_left");
819
- };
881
+ }
882
+ registerHandler("vi_vblock_left", vi_vblock_left);
820
883
 
821
- globalThis.vi_vblock_down = function (): void {
884
+ function vi_vblock_down() : void {
822
885
  executeWithCount("select_down");
823
- };
886
+ }
887
+ registerHandler("vi_vblock_down", vi_vblock_down);
824
888
 
825
- globalThis.vi_vblock_up = function (): void {
889
+ function vi_vblock_up() : void {
826
890
  executeWithCount("select_up");
827
- };
891
+ }
892
+ registerHandler("vi_vblock_up", vi_vblock_up);
828
893
 
829
- globalThis.vi_vblock_right = function (): void {
894
+ function vi_vblock_right() : void {
830
895
  executeWithCount("select_right");
831
- };
896
+ }
897
+ registerHandler("vi_vblock_right", vi_vblock_right);
832
898
 
833
- globalThis.vi_vblock_line_start = function (): void {
899
+ function vi_vblock_line_start() : void {
834
900
  consumeCount();
835
901
  editor.executeAction("select_line_start");
836
- };
902
+ }
903
+ registerHandler("vi_vblock_line_start", vi_vblock_line_start);
837
904
 
838
- globalThis.vi_vblock_line_end = function (): void {
905
+ function vi_vblock_line_end() : void {
839
906
  consumeCount();
840
907
  editor.executeAction("select_line_end");
841
- };
908
+ }
909
+ registerHandler("vi_vblock_line_end", vi_vblock_line_end);
842
910
 
843
911
  // Visual block delete - delete the selected block
844
- globalThis.vi_vblock_delete = function (): void {
912
+ function vi_vblock_delete() : void {
845
913
  editor.executeAction("cut");
846
914
  state.lastYankWasLinewise = false;
847
915
  switchMode("normal");
848
- };
916
+ }
917
+ registerHandler("vi_vblock_delete", vi_vblock_delete);
849
918
 
850
919
  // Visual block change - delete and enter insert mode
851
- globalThis.vi_vblock_change = function (): void {
920
+ function vi_vblock_change() : void {
852
921
  editor.executeAction("cut");
853
922
  switchMode("insert");
854
- };
923
+ }
924
+ registerHandler("vi_vblock_change", vi_vblock_change);
855
925
 
856
926
  // Visual block yank
857
- globalThis.vi_vblock_yank = function (): void {
927
+ function vi_vblock_yank() : void {
858
928
  editor.executeAction("copy");
859
929
  state.lastYankWasLinewise = false;
860
930
  // Move cursor to start of selection
861
931
  editor.executeAction("move_left");
862
932
  switchMode("normal");
863
- };
933
+ }
934
+ registerHandler("vi_vblock_yank", vi_vblock_yank);
864
935
 
865
936
  // Exit visual block mode
866
- globalThis.vi_vblock_escape = function (): void {
937
+ function vi_vblock_escape() : void {
867
938
  switchMode("normal");
868
- };
939
+ }
940
+ registerHandler("vi_vblock_escape", vi_vblock_escape);
869
941
 
870
942
  // Toggle from visual block to other visual modes
871
- globalThis.vi_vblock_toggle_char = function (): void {
943
+ function vi_vblock_toggle_char() : void {
872
944
  // Switch to character visual mode
873
945
  state.mode = "visual";
874
946
  editor.setEditorMode("vi-visual");
875
947
  editor.setStatus(getModeIndicator("visual"));
876
- };
948
+ }
949
+ registerHandler("vi_vblock_toggle_char", vi_vblock_toggle_char);
877
950
 
878
- globalThis.vi_vblock_toggle_line = function (): void {
951
+ function vi_vblock_toggle_line() : void {
879
952
  // Switch to line visual mode
880
953
  editor.executeAction("select_line");
881
954
  state.mode = "visual-line";
882
955
  editor.setEditorMode("vi-visual-line");
883
956
  editor.setStatus(getModeIndicator("visual-line"));
884
- };
957
+ }
958
+ registerHandler("vi_vblock_toggle_line", vi_vblock_toggle_line);
885
959
 
886
960
  // Visual mode motions - these extend the selection
887
- globalThis.vi_vis_left = function (): void {
961
+ function vi_vis_left() : void {
888
962
  executeWithCount("select_left");
889
- };
963
+ }
964
+ registerHandler("vi_vis_left", vi_vis_left);
890
965
 
891
- globalThis.vi_vis_down = function (): void {
966
+ function vi_vis_down() : void {
892
967
  executeWithCount("select_down");
893
- };
968
+ }
969
+ registerHandler("vi_vis_down", vi_vis_down);
894
970
 
895
- globalThis.vi_vis_up = function (): void {
971
+ function vi_vis_up() : void {
896
972
  executeWithCount("select_up");
897
- };
973
+ }
974
+ registerHandler("vi_vis_up", vi_vis_up);
898
975
 
899
- globalThis.vi_vis_right = function (): void {
976
+ function vi_vis_right() : void {
900
977
  executeWithCount("select_right");
901
- };
978
+ }
979
+ registerHandler("vi_vis_right", vi_vis_right);
902
980
 
903
- globalThis.vi_vis_word = function (): void {
981
+ function vi_vis_word() : void {
904
982
  executeWithCount("select_word_right");
905
- };
983
+ }
984
+ registerHandler("vi_vis_word", vi_vis_word);
906
985
 
907
- globalThis.vi_vis_word_back = function (): void {
986
+ function vi_vis_word_back() : void {
908
987
  executeWithCount("select_word_left");
909
- };
988
+ }
989
+ registerHandler("vi_vis_word_back", vi_vis_word_back);
910
990
 
911
- globalThis.vi_vis_word_end = function (): void {
991
+ function vi_vis_word_end() : void {
912
992
  const count = consumeCount();
913
993
  for (let i = 0; i < count; i++) {
914
994
  editor.executeAction("select_word_right");
915
995
  editor.executeAction("select_left");
916
996
  }
917
- };
997
+ }
998
+ registerHandler("vi_vis_word_end", vi_vis_word_end);
918
999
 
919
- globalThis.vi_vis_line_start = function (): void {
1000
+ function vi_vis_line_start() : void {
920
1001
  consumeCount();
921
1002
  editor.executeAction("select_line_start");
922
- };
1003
+ }
1004
+ registerHandler("vi_vis_line_start", vi_vis_line_start);
923
1005
 
924
- globalThis.vi_vis_line_end = function (): void {
1006
+ function vi_vis_line_end() : void {
925
1007
  consumeCount();
926
1008
  editor.executeAction("select_line_end");
927
- };
1009
+ }
1010
+ registerHandler("vi_vis_line_end", vi_vis_line_end);
928
1011
 
929
- globalThis.vi_vis_doc_start = function (): void {
1012
+ function vi_vis_doc_start() : void {
930
1013
  consumeCount();
931
1014
  editor.executeAction("select_document_start");
932
- };
1015
+ }
1016
+ registerHandler("vi_vis_doc_start", vi_vis_doc_start);
933
1017
 
934
- globalThis.vi_vis_doc_end = function (): void {
1018
+ function vi_vis_doc_end() : void {
935
1019
  consumeCount();
936
1020
  editor.executeAction("select_document_end");
937
- };
1021
+ }
1022
+ registerHandler("vi_vis_doc_end", vi_vis_doc_end);
938
1023
 
939
1024
  // Visual line mode motions - extend selection by whole lines
940
- globalThis.vi_vline_down = function (): void {
1025
+ function vi_vline_down() : void {
941
1026
  executeWithCount("select_down");
942
1027
  // Ensure full line selection
943
1028
  editor.executeAction("select_line_end");
944
- };
1029
+ }
1030
+ registerHandler("vi_vline_down", vi_vline_down);
945
1031
 
946
- globalThis.vi_vline_up = function (): void {
1032
+ function vi_vline_up() : void {
947
1033
  executeWithCount("select_up");
948
1034
  // Ensure full line selection
949
1035
  editor.executeAction("select_line_start");
950
- };
1036
+ }
1037
+ registerHandler("vi_vline_up", vi_vline_up);
951
1038
 
952
1039
  // Visual mode operators - act on selection
953
- globalThis.vi_vis_delete = function (): void {
1040
+ function vi_vis_delete() : void {
954
1041
  const wasLinewise = state.mode === "visual-line";
955
1042
  editor.executeAction("cut");
956
1043
  state.lastYankWasLinewise = wasLinewise;
957
1044
  switchMode("normal");
958
- };
1045
+ }
1046
+ registerHandler("vi_vis_delete", vi_vis_delete);
959
1047
 
960
- globalThis.vi_vis_change = function (): void {
1048
+ function vi_vis_change() : void {
961
1049
  editor.executeAction("cut");
962
1050
  switchMode("insert");
963
- };
1051
+ }
1052
+ registerHandler("vi_vis_change", vi_vis_change);
964
1053
 
965
- globalThis.vi_vis_yank = function (): void {
1054
+ function vi_vis_yank() : void {
966
1055
  const wasLinewise = state.mode === "visual-line";
967
1056
  editor.executeAction("copy");
968
1057
  state.lastYankWasLinewise = wasLinewise;
969
1058
  // Move cursor to start of selection (vim behavior)
970
1059
  editor.executeAction("move_left");
971
1060
  switchMode("normal");
972
- };
1061
+ }
1062
+ registerHandler("vi_vis_yank", vi_vis_yank);
973
1063
 
974
1064
  // Exit visual mode without doing anything
975
- globalThis.vi_vis_escape = function (): void {
1065
+ function vi_vis_escape() : void {
976
1066
  switchMode("normal");
977
- };
1067
+ }
1068
+ registerHandler("vi_vis_escape", vi_vis_escape);
978
1069
 
979
1070
  // ============================================================================
980
1071
  // Text Objects (iw, aw, i", a", etc.)
981
1072
  // ============================================================================
982
1073
 
983
1074
  // Enter text-object mode with "inner" modifier
984
- globalThis.vi_text_object_inner = function (): void {
1075
+ function vi_text_object_inner() : void {
985
1076
  state.pendingTextObject = "inner";
986
1077
  state.mode = "text-object";
987
1078
  editor.setEditorMode("vi-text-object");
988
1079
  editor.setStatus(getModeIndicator("text-object"));
989
- };
1080
+ }
1081
+ registerHandler("vi_text_object_inner", vi_text_object_inner);
990
1082
 
991
1083
  // Enter text-object mode with "around" modifier
992
- globalThis.vi_text_object_around = function (): void {
1084
+ function vi_text_object_around() : void {
993
1085
  state.pendingTextObject = "around";
994
1086
  state.mode = "text-object";
995
1087
  editor.setEditorMode("vi-text-object");
996
1088
  editor.setStatus(getModeIndicator("text-object"));
997
- };
1089
+ }
1090
+ registerHandler("vi_text_object_around", vi_text_object_around);
998
1091
 
999
1092
  // Apply text object selection and then the pending operator
1000
1093
  async function applyTextObject(objectType: string): Promise<void> {
@@ -1255,20 +1348,29 @@ function findMatchingPair(text: string, pos: number, openChar: string, closeChar
1255
1348
  }
1256
1349
 
1257
1350
  // Text object handlers
1258
- globalThis.vi_to_word = async function (): Promise<void> { await applyTextObject("word"); };
1259
- globalThis.vi_to_WORD = async function (): Promise<void> { await applyTextObject("WORD"); };
1260
- globalThis.vi_to_dquote = async function (): Promise<void> { await applyTextObject("\""); };
1261
- globalThis.vi_to_squote = async function (): Promise<void> { await applyTextObject("'"); };
1262
- globalThis.vi_to_backtick = async function (): Promise<void> { await applyTextObject("`"); };
1263
- globalThis.vi_to_paren = async function (): Promise<void> { await applyTextObject("("); };
1264
- globalThis.vi_to_brace = async function (): Promise<void> { await applyTextObject("{"); };
1265
- globalThis.vi_to_bracket = async function (): Promise<void> { await applyTextObject("["); };
1266
- globalThis.vi_to_angle = async function (): Promise<void> { await applyTextObject("<"); };
1351
+ async function vi_to_word() : Promise<void> { await applyTextObject("word"); }
1352
+ registerHandler("vi_to_word", vi_to_word);
1353
+ async function vi_to_WORD() : Promise<void> { await applyTextObject("WORD"); }
1354
+ registerHandler("vi_to_WORD", vi_to_WORD);
1355
+ async function vi_to_dquote() : Promise<void> { await applyTextObject("\""); }
1356
+ registerHandler("vi_to_dquote", vi_to_dquote);
1357
+ async function vi_to_squote() : Promise<void> { await applyTextObject("'"); }
1358
+ registerHandler("vi_to_squote", vi_to_squote);
1359
+ async function vi_to_backtick() : Promise<void> { await applyTextObject("`"); }
1360
+ registerHandler("vi_to_backtick", vi_to_backtick);
1361
+ async function vi_to_paren() : Promise<void> { await applyTextObject("("); }
1362
+ registerHandler("vi_to_paren", vi_to_paren);
1363
+ async function vi_to_brace() : Promise<void> { await applyTextObject("{"); };
1364
+ async function vi_to_bracket(): Promise<void> { await applyTextObject("["); }
1365
+ registerHandler("vi_to_bracket", vi_to_bracket);
1366
+ async function vi_to_angle(): Promise<void> { await applyTextObject("<"); }
1367
+ registerHandler("vi_to_angle", vi_to_angle);
1267
1368
 
1268
1369
  // Cancel text object mode
1269
- globalThis.vi_to_cancel = function (): void {
1370
+ function vi_to_cancel(): void {
1270
1371
  switchMode("normal");
1271
- };
1372
+ }
1373
+ registerHandler("vi_to_cancel", vi_to_cancel);
1272
1374
 
1273
1375
  // ============================================================================
1274
1376
  // Find Character Motions (f/t/F/T)
@@ -1363,41 +1465,47 @@ async function executeFindChar(findType: FindCharType, char: string): Promise<vo
1363
1465
  }
1364
1466
 
1365
1467
  // Handler for when a character is typed in find-char mode (async)
1366
- globalThis.vi_find_char_handler = async function (char: string): Promise<void> {
1468
+ async function vi_find_char_handler(char: string): Promise<void> {
1367
1469
  if (state.pendingFindChar) {
1368
1470
  await executeFindChar(state.pendingFindChar, char);
1369
1471
  }
1370
1472
  // Return to normal mode
1371
1473
  state.pendingFindChar = null;
1372
1474
  switchMode("normal");
1373
- };
1475
+ }
1476
+ registerHandler("vi_find_char_handler", vi_find_char_handler);
1374
1477
 
1375
1478
  // Commands to enter find-char mode
1376
- globalThis.vi_find_char_f = function (): void {
1479
+ function vi_find_char_f(): void {
1377
1480
  enterFindCharMode("f");
1378
- };
1481
+ }
1482
+ registerHandler("vi_find_char_f", vi_find_char_f);
1379
1483
 
1380
- globalThis.vi_find_char_t = function (): void {
1484
+ function vi_find_char_t(): void {
1381
1485
  enterFindCharMode("t");
1382
- };
1486
+ }
1487
+ registerHandler("vi_find_char_t", vi_find_char_t);
1383
1488
 
1384
- globalThis.vi_find_char_F = function (): void {
1489
+ function vi_find_char_F(): void {
1385
1490
  enterFindCharMode("F");
1386
- };
1491
+ }
1492
+ registerHandler("vi_find_char_F", vi_find_char_F);
1387
1493
 
1388
- globalThis.vi_find_char_T = function (): void {
1494
+ function vi_find_char_T(): void {
1389
1495
  enterFindCharMode("T");
1390
- };
1496
+ }
1497
+ registerHandler("vi_find_char_T", vi_find_char_T);
1391
1498
 
1392
1499
  // Repeat last find char (async)
1393
- globalThis.vi_find_char_repeat = async function (): Promise<void> {
1500
+ async function vi_find_char_repeat(): Promise<void> {
1394
1501
  if (state.lastFindChar) {
1395
1502
  await executeFindChar(state.lastFindChar.type, state.lastFindChar.char);
1396
1503
  }
1397
- };
1504
+ }
1505
+ registerHandler("vi_find_char_repeat", vi_find_char_repeat);
1398
1506
 
1399
1507
  // Repeat last find char in opposite direction (async)
1400
- globalThis.vi_find_char_repeat_reverse = async function (): Promise<void> {
1508
+ async function vi_find_char_repeat_reverse(): Promise<void> {
1401
1509
  if (state.lastFindChar) {
1402
1510
  const reversedType: FindCharType =
1403
1511
  state.lastFindChar.type === "f" ? "F" :
@@ -1405,65 +1513,79 @@ globalThis.vi_find_char_repeat_reverse = async function (): Promise<void> {
1405
1513
  state.lastFindChar.type === "t" ? "T" : "t";
1406
1514
  await executeFindChar(reversedType, state.lastFindChar.char);
1407
1515
  }
1408
- };
1516
+ }
1517
+ registerHandler("vi_find_char_repeat_reverse", vi_find_char_repeat_reverse);
1409
1518
 
1410
1519
  // Cancel find-char mode
1411
- globalThis.vi_find_char_cancel = function (): void {
1520
+ function vi_find_char_cancel(): void {
1412
1521
  state.pendingFindChar = null;
1413
1522
  switchMode("normal");
1414
- };
1523
+ }
1524
+ registerHandler("vi_find_char_cancel", vi_find_char_cancel);
1415
1525
 
1416
1526
  // ============================================================================
1417
1527
  // Operator-Pending Mode Commands
1418
1528
  // ============================================================================
1419
1529
 
1420
- globalThis.vi_op_left = function (): void {
1530
+ function vi_op_left(): void {
1421
1531
  handleMotionWithOperator("move_left");
1422
- };
1532
+ }
1533
+ registerHandler("vi_op_left", vi_op_left);
1423
1534
 
1424
- globalThis.vi_op_down = function (): void {
1535
+ function vi_op_down(): void {
1425
1536
  handleMotionWithOperator("move_down");
1426
- };
1537
+ }
1538
+ registerHandler("vi_op_down", vi_op_down);
1427
1539
 
1428
- globalThis.vi_op_up = function (): void {
1540
+ function vi_op_up(): void {
1429
1541
  handleMotionWithOperator("move_up");
1430
- };
1542
+ }
1543
+ registerHandler("vi_op_up", vi_op_up);
1431
1544
 
1432
- globalThis.vi_op_right = function (): void {
1545
+ function vi_op_right(): void {
1433
1546
  handleMotionWithOperator("move_right");
1434
- };
1547
+ }
1548
+ registerHandler("vi_op_right", vi_op_right);
1435
1549
 
1436
- globalThis.vi_op_word = function (): void {
1550
+ function vi_op_word(): void {
1437
1551
  handleMotionWithOperator("move_word_right");
1438
- };
1552
+ }
1553
+ registerHandler("vi_op_word", vi_op_word);
1439
1554
 
1440
- globalThis.vi_op_word_back = function (): void {
1555
+ function vi_op_word_back(): void {
1441
1556
  handleMotionWithOperator("move_word_left");
1442
- };
1557
+ }
1558
+ registerHandler("vi_op_word_back", vi_op_word_back);
1443
1559
 
1444
- globalThis.vi_op_line_start = function (): void {
1560
+ function vi_op_line_start(): void {
1445
1561
  handleMotionWithOperator("move_line_start");
1446
- };
1562
+ }
1563
+ registerHandler("vi_op_line_start", vi_op_line_start);
1447
1564
 
1448
- globalThis.vi_op_line_end = function (): void {
1565
+ function vi_op_line_end(): void {
1449
1566
  handleMotionWithOperator("move_line_end");
1450
- };
1567
+ }
1568
+ registerHandler("vi_op_line_end", vi_op_line_end);
1451
1569
 
1452
- globalThis.vi_op_doc_start = function (): void {
1570
+ function vi_op_doc_start(): void {
1453
1571
  handleMotionWithOperator("move_document_start");
1454
- };
1572
+ }
1573
+ registerHandler("vi_op_doc_start", vi_op_doc_start);
1455
1574
 
1456
- globalThis.vi_op_doc_end = function (): void {
1575
+ function vi_op_doc_end(): void {
1457
1576
  handleMotionWithOperator("move_document_end");
1458
- };
1577
+ }
1578
+ registerHandler("vi_op_doc_end", vi_op_doc_end);
1459
1579
 
1460
- globalThis.vi_op_matching_bracket = function (): void {
1580
+ function vi_op_matching_bracket(): void {
1461
1581
  handleMotionWithOperator("go_to_matching_bracket");
1462
- };
1582
+ }
1583
+ registerHandler("vi_op_matching_bracket", vi_op_matching_bracket);
1463
1584
 
1464
- globalThis.vi_cancel = function (): void {
1585
+ function vi_cancel(): void {
1465
1586
  switchMode("normal");
1466
- };
1587
+ }
1588
+ registerHandler("vi_cancel", vi_cancel);
1467
1589
 
1468
1590
  // ============================================================================
1469
1591
  // Mode Definitions
@@ -1580,69 +1702,132 @@ editor.defineMode("vi-insert", null, [
1580
1702
 
1581
1703
  // Explicitly define handlers for each character to ensure they're accessible
1582
1704
  // These return Promises so the runtime can await them
1583
- globalThis.vi_fc_a = async function(): Promise<void> { return globalThis.vi_find_char_handler("a"); };
1584
- globalThis.vi_fc_b = async function(): Promise<void> { return globalThis.vi_find_char_handler("b"); };
1585
- globalThis.vi_fc_c = async function(): Promise<void> { return globalThis.vi_find_char_handler("c"); };
1586
- globalThis.vi_fc_d = async function(): Promise<void> { return globalThis.vi_find_char_handler("d"); };
1587
- globalThis.vi_fc_e = async function(): Promise<void> { return globalThis.vi_find_char_handler("e"); };
1588
- globalThis.vi_fc_f = async function(): Promise<void> { return globalThis.vi_find_char_handler("f"); };
1589
- globalThis.vi_fc_g = async function(): Promise<void> { return globalThis.vi_find_char_handler("g"); };
1590
- globalThis.vi_fc_h = async function(): Promise<void> { return globalThis.vi_find_char_handler("h"); };
1591
- globalThis.vi_fc_i = async function(): Promise<void> { return globalThis.vi_find_char_handler("i"); };
1592
- globalThis.vi_fc_j = async function(): Promise<void> { return globalThis.vi_find_char_handler("j"); };
1593
- globalThis.vi_fc_k = async function(): Promise<void> { return globalThis.vi_find_char_handler("k"); };
1594
- globalThis.vi_fc_l = async function(): Promise<void> { return globalThis.vi_find_char_handler("l"); };
1595
- globalThis.vi_fc_m = async function(): Promise<void> { return globalThis.vi_find_char_handler("m"); };
1596
- globalThis.vi_fc_n = async function(): Promise<void> { return globalThis.vi_find_char_handler("n"); };
1597
- globalThis.vi_fc_o = async function(): Promise<void> { return globalThis.vi_find_char_handler("o"); };
1598
- globalThis.vi_fc_p = async function(): Promise<void> { return globalThis.vi_find_char_handler("p"); };
1599
- globalThis.vi_fc_q = async function(): Promise<void> { return globalThis.vi_find_char_handler("q"); };
1600
- globalThis.vi_fc_r = async function(): Promise<void> { return globalThis.vi_find_char_handler("r"); };
1601
- globalThis.vi_fc_s = async function(): Promise<void> { return globalThis.vi_find_char_handler("s"); };
1602
- globalThis.vi_fc_t = async function(): Promise<void> { return globalThis.vi_find_char_handler("t"); };
1603
- globalThis.vi_fc_u = async function(): Promise<void> { return globalThis.vi_find_char_handler("u"); };
1604
- globalThis.vi_fc_v = async function(): Promise<void> { return globalThis.vi_find_char_handler("v"); };
1605
- globalThis.vi_fc_w = async function(): Promise<void> { return globalThis.vi_find_char_handler("w"); };
1606
- globalThis.vi_fc_x = async function(): Promise<void> { return globalThis.vi_find_char_handler("x"); };
1607
- globalThis.vi_fc_y = async function(): Promise<void> { return globalThis.vi_find_char_handler("y"); };
1608
- globalThis.vi_fc_z = async function(): Promise<void> { return globalThis.vi_find_char_handler("z"); };
1609
- globalThis.vi_fc_A = async function(): Promise<void> { return globalThis.vi_find_char_handler("A"); };
1610
- globalThis.vi_fc_B = async function(): Promise<void> { return globalThis.vi_find_char_handler("B"); };
1611
- globalThis.vi_fc_C = async function(): Promise<void> { return globalThis.vi_find_char_handler("C"); };
1612
- globalThis.vi_fc_D = async function(): Promise<void> { return globalThis.vi_find_char_handler("D"); };
1613
- globalThis.vi_fc_E = async function(): Promise<void> { return globalThis.vi_find_char_handler("E"); };
1614
- globalThis.vi_fc_F = async function(): Promise<void> { return globalThis.vi_find_char_handler("F"); };
1615
- globalThis.vi_fc_G = async function(): Promise<void> { return globalThis.vi_find_char_handler("G"); };
1616
- globalThis.vi_fc_H = async function(): Promise<void> { return globalThis.vi_find_char_handler("H"); };
1617
- globalThis.vi_fc_I = async function(): Promise<void> { return globalThis.vi_find_char_handler("I"); };
1618
- globalThis.vi_fc_J = async function(): Promise<void> { return globalThis.vi_find_char_handler("J"); };
1619
- globalThis.vi_fc_K = async function(): Promise<void> { return globalThis.vi_find_char_handler("K"); };
1620
- globalThis.vi_fc_L = async function(): Promise<void> { return globalThis.vi_find_char_handler("L"); };
1621
- globalThis.vi_fc_M = async function(): Promise<void> { return globalThis.vi_find_char_handler("M"); };
1622
- globalThis.vi_fc_N = async function(): Promise<void> { return globalThis.vi_find_char_handler("N"); };
1623
- globalThis.vi_fc_O = async function(): Promise<void> { return globalThis.vi_find_char_handler("O"); };
1624
- globalThis.vi_fc_P = async function(): Promise<void> { return globalThis.vi_find_char_handler("P"); };
1625
- globalThis.vi_fc_Q = async function(): Promise<void> { return globalThis.vi_find_char_handler("Q"); };
1626
- globalThis.vi_fc_R = async function(): Promise<void> { return globalThis.vi_find_char_handler("R"); };
1627
- globalThis.vi_fc_S = async function(): Promise<void> { return globalThis.vi_find_char_handler("S"); };
1628
- globalThis.vi_fc_T = async function(): Promise<void> { return globalThis.vi_find_char_handler("T"); };
1629
- globalThis.vi_fc_U = async function(): Promise<void> { return globalThis.vi_find_char_handler("U"); };
1630
- globalThis.vi_fc_V = async function(): Promise<void> { return globalThis.vi_find_char_handler("V"); };
1631
- globalThis.vi_fc_W = async function(): Promise<void> { return globalThis.vi_find_char_handler("W"); };
1632
- globalThis.vi_fc_X = async function(): Promise<void> { return globalThis.vi_find_char_handler("X"); };
1633
- globalThis.vi_fc_Y = async function(): Promise<void> { return globalThis.vi_find_char_handler("Y"); };
1634
- globalThis.vi_fc_Z = async function(): Promise<void> { return globalThis.vi_find_char_handler("Z"); };
1635
- globalThis.vi_fc_0 = async function(): Promise<void> { return globalThis.vi_find_char_handler("0"); };
1636
- globalThis.vi_fc_1 = async function(): Promise<void> { return globalThis.vi_find_char_handler("1"); };
1637
- globalThis.vi_fc_2 = async function(): Promise<void> { return globalThis.vi_find_char_handler("2"); };
1638
- globalThis.vi_fc_3 = async function(): Promise<void> { return globalThis.vi_find_char_handler("3"); };
1639
- globalThis.vi_fc_4 = async function(): Promise<void> { return globalThis.vi_find_char_handler("4"); };
1640
- globalThis.vi_fc_5 = async function(): Promise<void> { return globalThis.vi_find_char_handler("5"); };
1641
- globalThis.vi_fc_6 = async function(): Promise<void> { return globalThis.vi_find_char_handler("6"); };
1642
- globalThis.vi_fc_7 = async function(): Promise<void> { return globalThis.vi_find_char_handler("7"); };
1643
- globalThis.vi_fc_8 = async function(): Promise<void> { return globalThis.vi_find_char_handler("8"); };
1644
- globalThis.vi_fc_9 = async function(): Promise<void> { return globalThis.vi_find_char_handler("9"); };
1645
- globalThis.vi_fc_space = async function(): Promise<void> { return globalThis.vi_find_char_handler(" "); };
1705
+ async function vi_fc_a(): Promise<void> { return vi_find_char_handler("a"); }
1706
+ registerHandler("vi_fc_a", vi_fc_a);
1707
+ async function vi_fc_b(): Promise<void> { return vi_find_char_handler("b"); }
1708
+ registerHandler("vi_fc_b", vi_fc_b);
1709
+ async function vi_fc_c(): Promise<void> { return vi_find_char_handler("c"); }
1710
+ registerHandler("vi_fc_c", vi_fc_c);
1711
+ async function vi_fc_d(): Promise<void> { return vi_find_char_handler("d"); }
1712
+ registerHandler("vi_fc_d", vi_fc_d);
1713
+ async function vi_fc_e(): Promise<void> { return vi_find_char_handler("e"); }
1714
+ registerHandler("vi_fc_e", vi_fc_e);
1715
+ async function vi_fc_f(): Promise<void> { return vi_find_char_handler("f"); }
1716
+ registerHandler("vi_fc_f", vi_fc_f);
1717
+ async function vi_fc_g(): Promise<void> { return vi_find_char_handler("g"); }
1718
+ registerHandler("vi_fc_g", vi_fc_g);
1719
+ async function vi_fc_h(): Promise<void> { return vi_find_char_handler("h"); }
1720
+ registerHandler("vi_fc_h", vi_fc_h);
1721
+ async function vi_fc_i(): Promise<void> { return vi_find_char_handler("i"); }
1722
+ registerHandler("vi_fc_i", vi_fc_i);
1723
+ async function vi_fc_j(): Promise<void> { return vi_find_char_handler("j"); }
1724
+ registerHandler("vi_fc_j", vi_fc_j);
1725
+ async function vi_fc_k(): Promise<void> { return vi_find_char_handler("k"); }
1726
+ registerHandler("vi_fc_k", vi_fc_k);
1727
+ async function vi_fc_l(): Promise<void> { return vi_find_char_handler("l"); }
1728
+ registerHandler("vi_fc_l", vi_fc_l);
1729
+ async function vi_fc_m(): Promise<void> { return vi_find_char_handler("m"); }
1730
+ registerHandler("vi_fc_m", vi_fc_m);
1731
+ async function vi_fc_n(): Promise<void> { return vi_find_char_handler("n"); }
1732
+ registerHandler("vi_fc_n", vi_fc_n);
1733
+ async function vi_fc_o(): Promise<void> { return vi_find_char_handler("o"); }
1734
+ registerHandler("vi_fc_o", vi_fc_o);
1735
+ async function vi_fc_p(): Promise<void> { return vi_find_char_handler("p"); }
1736
+ registerHandler("vi_fc_p", vi_fc_p);
1737
+ async function vi_fc_q(): Promise<void> { return vi_find_char_handler("q"); }
1738
+ registerHandler("vi_fc_q", vi_fc_q);
1739
+ async function vi_fc_r(): Promise<void> { return vi_find_char_handler("r"); }
1740
+ registerHandler("vi_fc_r", vi_fc_r);
1741
+ async function vi_fc_s(): Promise<void> { return vi_find_char_handler("s"); }
1742
+ registerHandler("vi_fc_s", vi_fc_s);
1743
+ async function vi_fc_t(): Promise<void> { return vi_find_char_handler("t"); }
1744
+ registerHandler("vi_fc_t", vi_fc_t);
1745
+ async function vi_fc_u(): Promise<void> { return vi_find_char_handler("u"); }
1746
+ registerHandler("vi_fc_u", vi_fc_u);
1747
+ async function vi_fc_v(): Promise<void> { return vi_find_char_handler("v"); }
1748
+ registerHandler("vi_fc_v", vi_fc_v);
1749
+ async function vi_fc_w(): Promise<void> { return vi_find_char_handler("w"); }
1750
+ registerHandler("vi_fc_w", vi_fc_w);
1751
+ async function vi_fc_x(): Promise<void> { return vi_find_char_handler("x"); }
1752
+ registerHandler("vi_fc_x", vi_fc_x);
1753
+ async function vi_fc_y(): Promise<void> { return vi_find_char_handler("y"); }
1754
+ registerHandler("vi_fc_y", vi_fc_y);
1755
+ async function vi_fc_z(): Promise<void> { return vi_find_char_handler("z"); }
1756
+ registerHandler("vi_fc_z", vi_fc_z);
1757
+ async function vi_fc_A(): Promise<void> { return vi_find_char_handler("A"); }
1758
+ registerHandler("vi_fc_A", vi_fc_A);
1759
+ async function vi_fc_B(): Promise<void> { return vi_find_char_handler("B"); }
1760
+ registerHandler("vi_fc_B", vi_fc_B);
1761
+ async function vi_fc_C(): Promise<void> { return vi_find_char_handler("C"); }
1762
+ registerHandler("vi_fc_C", vi_fc_C);
1763
+ async function vi_fc_D(): Promise<void> { return vi_find_char_handler("D"); }
1764
+ registerHandler("vi_fc_D", vi_fc_D);
1765
+ async function vi_fc_E(): Promise<void> { return vi_find_char_handler("E"); }
1766
+ registerHandler("vi_fc_E", vi_fc_E);
1767
+ async function vi_fc_F(): Promise<void> { return vi_find_char_handler("F"); }
1768
+ registerHandler("vi_fc_F", vi_fc_F);
1769
+ async function vi_fc_G(): Promise<void> { return vi_find_char_handler("G"); }
1770
+ registerHandler("vi_fc_G", vi_fc_G);
1771
+ async function vi_fc_H(): Promise<void> { return vi_find_char_handler("H"); }
1772
+ registerHandler("vi_fc_H", vi_fc_H);
1773
+ async function vi_fc_I(): Promise<void> { return vi_find_char_handler("I"); }
1774
+ registerHandler("vi_fc_I", vi_fc_I);
1775
+ async function vi_fc_J(): Promise<void> { return vi_find_char_handler("J"); }
1776
+ registerHandler("vi_fc_J", vi_fc_J);
1777
+ async function vi_fc_K(): Promise<void> { return vi_find_char_handler("K"); }
1778
+ registerHandler("vi_fc_K", vi_fc_K);
1779
+ async function vi_fc_L(): Promise<void> { return vi_find_char_handler("L"); }
1780
+ registerHandler("vi_fc_L", vi_fc_L);
1781
+ async function vi_fc_M(): Promise<void> { return vi_find_char_handler("M"); }
1782
+ registerHandler("vi_fc_M", vi_fc_M);
1783
+ async function vi_fc_N(): Promise<void> { return vi_find_char_handler("N"); }
1784
+ registerHandler("vi_fc_N", vi_fc_N);
1785
+ async function vi_fc_O(): Promise<void> { return vi_find_char_handler("O"); }
1786
+ registerHandler("vi_fc_O", vi_fc_O);
1787
+ async function vi_fc_P(): Promise<void> { return vi_find_char_handler("P"); }
1788
+ registerHandler("vi_fc_P", vi_fc_P);
1789
+ async function vi_fc_Q(): Promise<void> { return vi_find_char_handler("Q"); }
1790
+ registerHandler("vi_fc_Q", vi_fc_Q);
1791
+ async function vi_fc_R(): Promise<void> { return vi_find_char_handler("R"); }
1792
+ registerHandler("vi_fc_R", vi_fc_R);
1793
+ async function vi_fc_S(): Promise<void> { return vi_find_char_handler("S"); }
1794
+ registerHandler("vi_fc_S", vi_fc_S);
1795
+ async function vi_fc_T(): Promise<void> { return vi_find_char_handler("T"); }
1796
+ registerHandler("vi_fc_T", vi_fc_T);
1797
+ async function vi_fc_U(): Promise<void> { return vi_find_char_handler("U"); }
1798
+ registerHandler("vi_fc_U", vi_fc_U);
1799
+ async function vi_fc_V(): Promise<void> { return vi_find_char_handler("V"); }
1800
+ registerHandler("vi_fc_V", vi_fc_V);
1801
+ async function vi_fc_W(): Promise<void> { return vi_find_char_handler("W"); }
1802
+ registerHandler("vi_fc_W", vi_fc_W);
1803
+ async function vi_fc_X(): Promise<void> { return vi_find_char_handler("X"); }
1804
+ registerHandler("vi_fc_X", vi_fc_X);
1805
+ async function vi_fc_Y(): Promise<void> { return vi_find_char_handler("Y"); }
1806
+ registerHandler("vi_fc_Y", vi_fc_Y);
1807
+ async function vi_fc_Z(): Promise<void> { return vi_find_char_handler("Z"); }
1808
+ registerHandler("vi_fc_Z", vi_fc_Z);
1809
+ async function vi_fc_0(): Promise<void> { return vi_find_char_handler("0"); }
1810
+ registerHandler("vi_fc_0", vi_fc_0);
1811
+ async function vi_fc_1(): Promise<void> { return vi_find_char_handler("1"); }
1812
+ registerHandler("vi_fc_1", vi_fc_1);
1813
+ async function vi_fc_2(): Promise<void> { return vi_find_char_handler("2"); }
1814
+ registerHandler("vi_fc_2", vi_fc_2);
1815
+ async function vi_fc_3(): Promise<void> { return vi_find_char_handler("3"); }
1816
+ registerHandler("vi_fc_3", vi_fc_3);
1817
+ async function vi_fc_4(): Promise<void> { return vi_find_char_handler("4"); }
1818
+ registerHandler("vi_fc_4", vi_fc_4);
1819
+ async function vi_fc_5(): Promise<void> { return vi_find_char_handler("5"); }
1820
+ registerHandler("vi_fc_5", vi_fc_5);
1821
+ async function vi_fc_6(): Promise<void> { return vi_find_char_handler("6"); }
1822
+ registerHandler("vi_fc_6", vi_fc_6);
1823
+ async function vi_fc_7(): Promise<void> { return vi_find_char_handler("7"); }
1824
+ registerHandler("vi_fc_7", vi_fc_7);
1825
+ async function vi_fc_8(): Promise<void> { return vi_find_char_handler("8"); }
1826
+ registerHandler("vi_fc_8", vi_fc_8);
1827
+ async function vi_fc_9(): Promise<void> { return vi_find_char_handler("9"); }
1828
+ registerHandler("vi_fc_9", vi_fc_9);
1829
+ async function vi_fc_space(): Promise<void> { return vi_find_char_handler(" "); }
1830
+ registerHandler("vi_fc_space", vi_fc_space);
1646
1831
 
1647
1832
  // Define vi-find-char mode with all the character bindings
1648
1833
  editor.defineMode("vi-find-char", null, [
@@ -1944,12 +2129,13 @@ for (const [name, key] of opCommands) {
1944
2129
  // ============================================================================
1945
2130
 
1946
2131
  // Start command mode - shows ":" prompt at the bottom
1947
- globalThis.vi_command_mode = function (): void {
2132
+ function vi_command_mode(): void {
1948
2133
  editor.startPrompt(":", "vi-command");
1949
- };
2134
+ }
2135
+ registerHandler("vi_command_mode", vi_command_mode);
1950
2136
 
1951
2137
  // Handle command execution when user presses Enter
1952
- globalThis.vi_command_handler = async function (args: { prompt_type: string; input: string }): Promise<boolean> {
2138
+ async function vi_command_handler(args: { prompt_type: string; input: string }): Promise<boolean> {
1953
2139
  if (args.prompt_type !== "vi-command") {
1954
2140
  return false; // Not our prompt, let other handlers process it
1955
2141
  }
@@ -1969,7 +2155,8 @@ globalThis.vi_command_handler = async function (args: { prompt_type: string; inp
1969
2155
  }
1970
2156
 
1971
2157
  return true; // We handled it
1972
- };
2158
+ }
2159
+ registerHandler("vi_command_handler", vi_command_handler);
1973
2160
 
1974
2161
  interface CommandResult {
1975
2162
  error?: string;
@@ -2772,7 +2959,7 @@ editor.on("prompt_confirmed", "vi_command_handler");
2772
2959
 
2773
2960
  let viModeEnabled = false;
2774
2961
 
2775
- globalThis.vi_mode_toggle = function (): void {
2962
+ function vi_mode_toggle(): void {
2776
2963
  editor.debug("[vi_mode_toggle] called, viModeEnabled was: " + viModeEnabled);
2777
2964
  viModeEnabled = !viModeEnabled;
2778
2965
  editor.debug("[vi_mode_toggle] viModeEnabled now: " + viModeEnabled);
@@ -2790,7 +2977,8 @@ globalThis.vi_mode_toggle = function (): void {
2790
2977
  editor.setStatus(editor.t("status.disabled"));
2791
2978
  }
2792
2979
  editor.debug("[vi_mode_toggle] done");
2793
- };
2980
+ }
2981
+ registerHandler("vi_mode_toggle", vi_mode_toggle);
2794
2982
 
2795
2983
  editor.registerCommand(
2796
2984
  "%cmd.toggle_vi_mode",
@@ -2803,3 +2991,5 @@ editor.registerCommand(
2803
2991
  // Initialization
2804
2992
  // ============================================================================
2805
2993
 
2994
+
2995
+ registerHandler("vi_to_brace", vi_to_brace);