@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.
- package/CHANGELOG.md +60 -0
- package/README.md +10 -0
- package/package.json +1 -1
- package/plugins/audit_mode.ts +79 -58
- package/plugins/check-types.sh +1 -0
- package/plugins/clangd-lsp.ts +9 -6
- package/plugins/clangd_support.ts +12 -8
- package/plugins/code-tour.ts +15 -10
- package/plugins/config-schema.json +40 -3
- package/plugins/csharp_support.ts +15 -10
- package/plugins/css-lsp.ts +9 -6
- package/plugins/diagnostics_panel.ts +25 -18
- package/plugins/examples/README.md +1 -2
- package/plugins/examples/async_demo.ts +28 -28
- package/plugins/examples/bookmarks.ts +34 -32
- package/plugins/examples/buffer_query_demo.ts +20 -20
- package/plugins/examples/hello_world.ts +46 -10
- package/plugins/examples/virtual_buffer_demo.ts +16 -12
- package/plugins/find_references.ts +7 -5
- package/plugins/git_blame.ts +13 -9
- package/plugins/git_explorer.ts +9 -6
- package/plugins/git_find_file.ts +7 -5
- package/plugins/git_grep.ts +3 -2
- package/plugins/git_gutter.ts +15 -10
- package/plugins/git_log.ts +27 -18
- package/plugins/go-lsp.ts +9 -6
- package/plugins/html-lsp.ts +9 -6
- package/plugins/java-lsp.ts +9 -6
- package/plugins/json-lsp.ts +9 -6
- package/plugins/latex-lsp.ts +9 -6
- package/plugins/lib/finder.ts +1 -0
- package/plugins/lib/fresh.d.ts +139 -14
- package/plugins/live_grep.ts +3 -2
- package/plugins/markdown_compose.ts +33 -23
- package/plugins/markdown_source.ts +15 -10
- package/plugins/marksman-lsp.ts +9 -6
- package/plugins/merge_conflict.ts +33 -22
- package/plugins/odin-lsp.ts +9 -6
- package/plugins/path_complete.ts +3 -2
- package/plugins/pkg.ts +70 -48
- package/plugins/python-lsp.ts +9 -6
- package/plugins/rust-lsp.ts +102 -6
- package/plugins/search_replace.ts +32 -21
- package/plugins/templ-lsp.ts +9 -6
- package/plugins/test_i18n.ts +3 -2
- package/plugins/theme_editor.i18n.json +28 -14
- package/plugins/theme_editor.ts +1230 -495
- package/plugins/typescript-lsp.ts +9 -6
- package/plugins/vi_mode.ts +487 -297
- package/plugins/welcome.ts +9 -6
- package/plugins/zig-lsp.ts +9 -6
package/plugins/vi_mode.ts
CHANGED
|
@@ -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
|
-
|
|
327
|
+
function vi_left() : void {
|
|
328
328
|
executeWithCount("move_left");
|
|
329
|
-
}
|
|
329
|
+
}
|
|
330
|
+
registerHandler("vi_left", vi_left);
|
|
330
331
|
|
|
331
|
-
|
|
332
|
+
function vi_down() : void {
|
|
332
333
|
executeWithCount("move_down");
|
|
333
|
-
}
|
|
334
|
+
}
|
|
335
|
+
registerHandler("vi_down", vi_down);
|
|
334
336
|
|
|
335
|
-
|
|
337
|
+
function vi_up() : void {
|
|
336
338
|
executeWithCount("move_up");
|
|
337
|
-
}
|
|
339
|
+
}
|
|
340
|
+
registerHandler("vi_up", vi_up);
|
|
338
341
|
|
|
339
|
-
|
|
342
|
+
function vi_right() : void {
|
|
340
343
|
executeWithCount("move_right");
|
|
341
|
-
}
|
|
344
|
+
}
|
|
345
|
+
registerHandler("vi_right", vi_right);
|
|
342
346
|
|
|
343
|
-
|
|
347
|
+
function vi_word() : void {
|
|
344
348
|
executeWithCount("move_word_right");
|
|
345
|
-
}
|
|
349
|
+
}
|
|
350
|
+
registerHandler("vi_word", vi_word);
|
|
346
351
|
|
|
347
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
398
|
+
function vi_page_down() : void {
|
|
387
399
|
executeWithCount("page_down");
|
|
388
|
-
}
|
|
400
|
+
}
|
|
401
|
+
registerHandler("vi_page_down", vi_page_down);
|
|
389
402
|
|
|
390
|
-
|
|
403
|
+
function vi_page_up() : void {
|
|
391
404
|
executeWithCount("page_up");
|
|
392
|
-
}
|
|
405
|
+
}
|
|
406
|
+
registerHandler("vi_page_up", vi_page_up);
|
|
393
407
|
|
|
394
|
-
|
|
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
|
-
|
|
414
|
+
function vi_insert_before() : void {
|
|
400
415
|
switchMode("insert");
|
|
401
|
-
}
|
|
416
|
+
}
|
|
417
|
+
registerHandler("vi_insert_before", vi_insert_before);
|
|
402
418
|
|
|
403
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
452
|
+
function vi_escape() : void {
|
|
432
453
|
switchMode("normal");
|
|
433
|
-
}
|
|
454
|
+
}
|
|
455
|
+
registerHandler("vi_escape", vi_escape);
|
|
434
456
|
|
|
435
457
|
// Operators
|
|
436
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
615
|
+
function vi_undo() : void {
|
|
580
616
|
editor.executeAction("undo");
|
|
581
|
-
}
|
|
617
|
+
}
|
|
618
|
+
registerHandler("vi_undo", vi_undo);
|
|
582
619
|
|
|
583
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
733
|
+
function vi_search_forward() : void {
|
|
694
734
|
editor.executeAction("search");
|
|
695
|
-
}
|
|
735
|
+
}
|
|
736
|
+
registerHandler("vi_search_forward", vi_search_forward);
|
|
696
737
|
|
|
697
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
879
|
+
function vi_vblock_left() : void {
|
|
818
880
|
executeWithCount("select_left");
|
|
819
|
-
}
|
|
881
|
+
}
|
|
882
|
+
registerHandler("vi_vblock_left", vi_vblock_left);
|
|
820
883
|
|
|
821
|
-
|
|
884
|
+
function vi_vblock_down() : void {
|
|
822
885
|
executeWithCount("select_down");
|
|
823
|
-
}
|
|
886
|
+
}
|
|
887
|
+
registerHandler("vi_vblock_down", vi_vblock_down);
|
|
824
888
|
|
|
825
|
-
|
|
889
|
+
function vi_vblock_up() : void {
|
|
826
890
|
executeWithCount("select_up");
|
|
827
|
-
}
|
|
891
|
+
}
|
|
892
|
+
registerHandler("vi_vblock_up", vi_vblock_up);
|
|
828
893
|
|
|
829
|
-
|
|
894
|
+
function vi_vblock_right() : void {
|
|
830
895
|
executeWithCount("select_right");
|
|
831
|
-
}
|
|
896
|
+
}
|
|
897
|
+
registerHandler("vi_vblock_right", vi_vblock_right);
|
|
832
898
|
|
|
833
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
961
|
+
function vi_vis_left() : void {
|
|
888
962
|
executeWithCount("select_left");
|
|
889
|
-
}
|
|
963
|
+
}
|
|
964
|
+
registerHandler("vi_vis_left", vi_vis_left);
|
|
890
965
|
|
|
891
|
-
|
|
966
|
+
function vi_vis_down() : void {
|
|
892
967
|
executeWithCount("select_down");
|
|
893
|
-
}
|
|
968
|
+
}
|
|
969
|
+
registerHandler("vi_vis_down", vi_vis_down);
|
|
894
970
|
|
|
895
|
-
|
|
971
|
+
function vi_vis_up() : void {
|
|
896
972
|
executeWithCount("select_up");
|
|
897
|
-
}
|
|
973
|
+
}
|
|
974
|
+
registerHandler("vi_vis_up", vi_vis_up);
|
|
898
975
|
|
|
899
|
-
|
|
976
|
+
function vi_vis_right() : void {
|
|
900
977
|
executeWithCount("select_right");
|
|
901
|
-
}
|
|
978
|
+
}
|
|
979
|
+
registerHandler("vi_vis_right", vi_vis_right);
|
|
902
980
|
|
|
903
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1530
|
+
function vi_op_left(): void {
|
|
1421
1531
|
handleMotionWithOperator("move_left");
|
|
1422
|
-
}
|
|
1532
|
+
}
|
|
1533
|
+
registerHandler("vi_op_left", vi_op_left);
|
|
1423
1534
|
|
|
1424
|
-
|
|
1535
|
+
function vi_op_down(): void {
|
|
1425
1536
|
handleMotionWithOperator("move_down");
|
|
1426
|
-
}
|
|
1537
|
+
}
|
|
1538
|
+
registerHandler("vi_op_down", vi_op_down);
|
|
1427
1539
|
|
|
1428
|
-
|
|
1540
|
+
function vi_op_up(): void {
|
|
1429
1541
|
handleMotionWithOperator("move_up");
|
|
1430
|
-
}
|
|
1542
|
+
}
|
|
1543
|
+
registerHandler("vi_op_up", vi_op_up);
|
|
1431
1544
|
|
|
1432
|
-
|
|
1545
|
+
function vi_op_right(): void {
|
|
1433
1546
|
handleMotionWithOperator("move_right");
|
|
1434
|
-
}
|
|
1547
|
+
}
|
|
1548
|
+
registerHandler("vi_op_right", vi_op_right);
|
|
1435
1549
|
|
|
1436
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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);
|