vimamsa 0.1.26 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/appimage.yml +93 -0
- data/.gitignore +4 -1
- data/Dockerfile +7 -4
- data/README.md +195 -99
- data/custom_example.rb +59 -17
- data/doc/TODO.md +678 -0
- data/doc/action_names_plan.md +442 -0
- data/doc/bundling_plan.md +570 -0
- data/doc/delta_syntax_plan.md +293 -0
- data/doc/demo_recording_plan.md +288 -0
- data/doc/design_goals.md +27 -0
- data/doc/intro_page_plan.md +266 -0
- data/doc/key_bindings_report_plan.md +213 -0
- data/doc/line_tree_plan.md +89 -0
- data/doc/missing_vim_bindings.md +61 -0
- data/doc/modules_settings_plan.md +433 -0
- data/doc/refactor_dedup_plan.md +117 -0
- data/doc/registries_plan.md +202 -0
- data/doc/startup_speed_plan.md +97 -0
- data/doc/treap_visualizer.html +585 -0
- data/doc/unused_code_plan.md +120 -0
- data/doc/vim_compatibility_plan.md +451 -0
- data/doc/vimlike_vim_conflicts.md +262 -0
- data/doc/vm_snapshots_plan.md +146 -0
- data/doc/wysiwyg_plan.md +231 -0
- data/exe/run_tests.rb +124 -3
- data/exe/vimamsa +68 -5
- data/fonts/OFL-Oxanium.txt +93 -0
- data/fonts/Oxanium[wght].ttf +0 -0
- data/help/intro.txt +30 -0
- data/help/vim_intro.txt +31 -0
- data/icon.png +0 -0
- data/img/demo.gif +0 -0
- data/img/demo.mp4 +0 -0
- data/lang/hyperplaintext.lang +7 -1
- data/lib/vimamsa/ack.rb +13 -1
- data/lib/vimamsa/actions.rb +385 -37
- data/lib/vimamsa/appimage_env.rb +35 -0
- data/lib/vimamsa/audio.rb +2 -5
- data/lib/vimamsa/bookmarks.rb +302 -0
- data/lib/vimamsa/buffer.rb +675 -118
- data/lib/vimamsa/buffer_changetext.rb +150 -68
- data/lib/vimamsa/buffer_cursor.rb +7 -0
- data/lib/vimamsa/buffer_list.rb +6 -2
- data/lib/vimamsa/buffer_manager.rb +10 -7
- data/lib/vimamsa/bundled_fonts.rb +32 -0
- data/lib/vimamsa/cli_help.rb +75 -0
- data/lib/vimamsa/clipboard.rb +9 -3
- data/lib/vimamsa/conf.rb +68 -3
- data/lib/vimamsa/constants.rb +3 -0
- data/lib/vimamsa/crash_handler.rb +149 -0
- data/lib/vimamsa/debug.rb +6 -3
- data/lib/vimamsa/demo_player.rb +458 -0
- data/lib/vimamsa/demo_recorder.rb +277 -0
- data/lib/vimamsa/desktop_install.rb +96 -0
- data/lib/vimamsa/diff_buffer.rb +40 -11
- data/lib/vimamsa/dot_repeat.rb +104 -0
- data/lib/vimamsa/easy_jump.rb +57 -3
- data/lib/vimamsa/editor.rb +327 -78
- data/lib/vimamsa/encrypt.rb +78 -29
- data/lib/vimamsa/file_finder.rb +4 -19
- data/lib/vimamsa/file_history.rb +4 -1
- data/lib/vimamsa/file_manager.rb +46 -31
- data/lib/vimamsa/fold.rb +226 -0
- data/lib/vimamsa/form_input.rb +388 -0
- data/lib/vimamsa/gui.rb +603 -119
- data/lib/vimamsa/gui_command_line.rb +247 -0
- data/lib/vimamsa/gui_dialog.rb +94 -42
- data/lib/vimamsa/gui_file_panel.rb +356 -25
- data/lib/vimamsa/gui_form_generator.rb +75 -40
- data/lib/vimamsa/gui_func_panel.rb +67 -22
- data/lib/vimamsa/gui_image.rb +3 -0
- data/lib/vimamsa/gui_key_hint.rb +165 -0
- data/lib/vimamsa/gui_keylog_panel.rb +408 -0
- data/lib/vimamsa/gui_menu.rb +84 -53
- data/lib/vimamsa/gui_select_window.rb +80 -75
- data/lib/vimamsa/gui_settings.rb +86 -41
- data/lib/vimamsa/gui_sourceview.rb +280 -92
- data/lib/vimamsa/gui_sourceview_autocomplete.rb +319 -90
- data/lib/vimamsa/gui_text.rb +63 -2
- data/lib/vimamsa/gui_theme.rb +615 -0
- data/lib/vimamsa/hook.rb +5 -0
- data/lib/vimamsa/hyper_plain_text.rb +3 -0
- data/lib/vimamsa/intro_page.rb +368 -0
- data/lib/vimamsa/key_actions.rb +382 -193
- data/lib/vimamsa/key_binding_tree.rb +467 -273
- data/lib/vimamsa/key_bindings_notepad.rb +45 -0
- data/lib/vimamsa/key_bindings_report.rb +484 -0
- data/lib/vimamsa/key_bindings_vim.rb +104 -0
- data/lib/vimamsa/key_bindings_vimlike.rb +353 -289
- data/lib/vimamsa/key_names.rb +80 -0
- data/lib/vimamsa/langservp.rb +271 -54
- data/lib/vimamsa/line_tree.rb +367 -0
- data/lib/vimamsa/macro.rb +23 -3
- data/lib/vimamsa/main.rb +14 -8
- data/lib/vimamsa/rbvma.rb +41 -1
- data/lib/vimamsa/registers.rb +125 -0
- data/lib/vimamsa/run_ruby.rb +64 -0
- data/lib/vimamsa/search.rb +3 -0
- data/lib/vimamsa/search_replace.rb +15 -14
- data/lib/vimamsa/string_util.rb +134 -40
- data/lib/vimamsa/terminal.rb +3 -0
- data/lib/vimamsa/test_framework.rb +28 -2
- data/lib/vimamsa/tests.rb +11 -8
- data/lib/vimamsa/text_objects.rb +310 -0
- data/lib/vimamsa/text_transforms.rb +18 -0
- data/lib/vimamsa/tmp_user_dir.rb +39 -0
- data/lib/vimamsa/user_dirs.rb +83 -0
- data/lib/vimamsa/util.rb +46 -7
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa/vim_core.rb +355 -0
- data/lib/vimamsa/vim_operators.rb +365 -0
- data/lib/vimamsa.rb +0 -1
- data/modules/calculator/calculator.rb +5 -5
- data/modules/color_highlight/color_highlight.rb +118 -0
- data/modules/color_highlight/color_highlight_info.rb +3 -0
- data/modules/dictation/dictation.rb +1054 -0
- data/modules/dictation/dictation_info.rb +3 -0
- data/modules/dictation/whisper_worker.py +273 -0
- data/modules/ollama/ollama.rb +107 -0
- data/modules/ollama/ollama_info.rb +3 -0
- data/modules/terminal/terminal.rb +5 -5
- data/modules/tts/tts.rb +119 -0
- data/modules/tts/tts_info.rb +3 -0
- data/run_e2e_vm.sh +28 -0
- data/run_tests_vm.rb +138 -0
- data/scripts/appimage/AppRun +54 -0
- data/scripts/appimage/Dockerfile +18 -0
- data/scripts/appimage/build.sh +19 -0
- data/scripts/appimage/build_in_container.sh +192 -0
- data/scripts/appimage/smoke_test.sh +27 -0
- data/scripts/demo/demo_easyjump_steps.txt +60 -0
- data/scripts/demo/demo_files_steps.txt +52 -0
- data/scripts/demo/demo_steps.txt +67 -0
- data/scripts/demo/notes.txt +6 -0
- data/scripts/demo/record_demo.rb +156 -0
- data/scripts/demo/report.rb +7 -0
- data/scripts/demo/shapes.rb +29 -0
- data/scripts/demo/square/shapes.rb +29 -0
- data/scripts/demo/square/steps.txt +185 -0
- data/scripts/lib/perf_startup.rb +138 -0
- data/scripts/lib/script_helpers.rb +53 -0
- data/scripts/perf_compare.rb +34 -0
- data/scripts/profile_startup.rb +72 -0
- data/styles/134272-molokai.xml +3 -0
- data/styles/molokai_cyber.xml +48 -0
- data/styles/molokai_edit.xml +1 -0
- data/tests/support/virtual_keyboard.rb +254 -0
- data/tests/support/virtual_mic.rb +67 -0
- data/tests/test_ack.rb +22 -0
- data/tests/test_action_ids.rb +232 -0
- data/tests/test_auto_format.rb +122 -0
- data/tests/test_autocomplete.rb +211 -0
- data/tests/test_autosave.rb +145 -0
- data/tests/test_basic_editing.rb +46 -16
- data/tests/test_bookmarks.rb +206 -0
- data/tests/test_bracket_match.rb +88 -0
- data/tests/test_bundling.rb +92 -0
- data/tests/test_cli_help.rb +64 -0
- data/tests/test_color_highlight.rb +92 -0
- data/tests/test_command_line.rb +79 -0
- data/tests/test_command_line_file.rb +27 -0
- data/tests/test_context_menu_file.rb +147 -0
- data/tests/test_copy_paste.rb +106 -26
- data/tests/test_crash_handler.rb +39 -0
- data/tests/test_custom_two_phase.rb +92 -0
- data/tests/test_demo_player.rb +301 -0
- data/tests/test_demo_recorder.rb +202 -0
- data/tests/test_dialog_callback_errors.rb +44 -0
- data/tests/test_dictation.rb +294 -0
- data/tests/test_diff_buffer_name.rb +51 -0
- data/tests/test_dot_repeat.rb +88 -0
- data/tests/test_double_click.rb +41 -0
- data/tests/test_drag_selection.rb +125 -0
- data/tests/test_e2e_cmdline.rb +116 -0
- data/tests/test_e2e_dictation.rb +98 -0
- data/tests/test_e2e_replace_char.rb +58 -0
- data/tests/test_easy_jump.rb +93 -0
- data/tests/test_extract_file_links.rb +55 -0
- data/tests/test_file_format.rb +217 -0
- data/tests/test_file_manager.rb +72 -0
- data/tests/test_file_panel.rb +269 -0
- data/tests/test_flash.rb +78 -0
- data/tests/test_fold.rb +111 -0
- data/tests/test_font_refresh.rb +56 -0
- data/tests/test_form_input.rb +203 -0
- data/tests/test_func_panel.rb +68 -0
- data/tests/test_grep_apply.rb +46 -0
- data/tests/test_gtk_sync.rb +126 -0
- data/tests/test_hpt_highlight_visible.rb +75 -0
- data/tests/test_hpt_link_highlight.rb +82 -0
- data/tests/test_intro_page.rb +437 -0
- data/tests/test_jump_to_file.rb +41 -0
- data/tests/test_key_bindings.rb +208 -0
- data/tests/test_key_categories.rb +163 -0
- data/tests/test_keylog_panel.rb +261 -0
- data/tests/test_line_ends.rb +51 -0
- data/tests/test_line_tree.rb +86 -0
- data/tests/test_lsp_clangd.rb +281 -0
- data/tests/test_lsp_jump.rb +87 -0
- data/tests/test_lsp_position_encoding.rb +49 -0
- data/tests/test_lsp_symbols.rb +68 -0
- data/tests/test_macro.rb +137 -0
- data/tests/test_markdown_highlight.rb +57 -0
- data/tests/test_mode_badge.rb +41 -0
- data/tests/test_module_interface.rb +9 -9
- data/tests/test_notepad_bindings.rb +67 -0
- data/tests/test_perf_startup.rb +28 -0
- data/tests/test_popup_queue.rb +51 -0
- data/tests/test_random_edit.rb +109 -0
- data/tests/test_registers.rb +122 -0
- data/tests/test_revert.rb +127 -0
- data/tests/test_run_ruby.rb +77 -0
- data/tests/test_startup_file.rb +58 -0
- data/tests/test_status_area.rb +50 -0
- data/tests/test_text_objects.rb +163 -0
- data/tests/test_text_transforms.rb +341 -0
- data/tests/test_tmp_user_dir.rb +79 -0
- data/tests/test_tts.rb +68 -0
- data/tests/test_undo.rb +34 -34
- data/tests/test_user_dirs.rb +122 -0
- data/tests/test_vim_bindings.rb +353 -0
- data/tests/test_vim_conflicts.rb +100 -0
- data/tests/test_vim_operators.rb +116 -0
- data/tests/test_window_layout.rb +302 -0
- data/vimamsa.gemspec +3 -1
- data/vm_guest_run.sh +129 -0
- metadata +167 -10
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Unused-code removal plan: further source size reduction
|
|
2
|
+
|
|
3
|
+
## Context
|
|
4
|
+
|
|
5
|
+
Follow-up to refactor_dedup_plan.md (tiers 1–4 done, tier 5 skipped). Fresh scan
|
|
6
|
+
(July 2026) for methods whose names appear nowhere outside their own definition —
|
|
7
|
+
searched across lib/, exe/, tests/, modules/, custom_example.rb, and a real-world
|
|
8
|
+
user config (custom.rb + settings.rb), counting references in eval'd key-binding
|
|
9
|
+
strings and symbols but ignoring comment-only lines. Older local scan
|
|
10
|
+
reports (not in the repo) are stale — everything in
|
|
11
|
+
them was either already deleted or is now used; this file supersedes them.
|
|
12
|
+
|
|
13
|
+
Caveat that applies to everything below: any function is technically reachable
|
|
14
|
+
from the `:` command line (it evals Ruby) and from ~/.vimamsa/custom.rb on other
|
|
15
|
+
machines. "Unused" here means: no reference anywhere in the shipped code or this
|
|
16
|
+
machine's user config.
|
|
17
|
+
|
|
18
|
+
Realistic total: **~530 lines** (tiers A–C), plus an optional ~390-line
|
|
19
|
+
commented-out-code sweep (tier D). Verify each tier with
|
|
20
|
+
`ruby exe/run_tests.rb --headless`.
|
|
21
|
+
|
|
22
|
+
## Tier A — dead methods, pure deletion (~350 lines)
|
|
23
|
+
|
|
24
|
+
Verified individually; body sizes in parens. Delete, including any
|
|
25
|
+
now-orphaned ivars/config noted inline.
|
|
26
|
+
|
|
27
|
+
**buffer.rb** (~87): `get_short_path` (7), `recalc_line_ends` (13),
|
|
28
|
+
`sanity_check_line_ends` (12) — near-duplicates of each other, both dead;
|
|
29
|
+
`context_menu_items` (34); `need_redraw!`/`need_redraw?`/`set_redrawed` (9) —
|
|
30
|
+
also remove the now-write-only `@need_redraw` assignment at buffer.rb:458;
|
|
31
|
+
`delete_active_selection` (7, marked "TODO: remove this function");
|
|
32
|
+
`save_as_check_callback` (5, references a commented-out `@unconfirmed_path`
|
|
33
|
+
mechanism; `save_as_callback` itself stays — it's live via editor.rb:474).
|
|
34
|
+
|
|
35
|
+
**buffer_changetext.rb** (~10): `paste_start_xclip` (10) — superseded GTK-clipboard
|
|
36
|
+
fallback; its only call site is already commented out (line ~115). Remove that
|
|
37
|
+
comment too and the `xclip` mention.
|
|
38
|
+
|
|
39
|
+
**debug.rb** (~48): `run_test` (16), `run_random_jump_test__tmpl` (32) — legacy
|
|
40
|
+
test infra referencing tests/test_<id>_output.txt files that no longer exist.
|
|
41
|
+
(`gui_sleep` stays — used elsewhere.)
|
|
42
|
+
|
|
43
|
+
**editor.rb** (~25): `paste_register` (4), `plug` (3),
|
|
44
|
+
`can_open_extension?` (7) — also delete the orphaned
|
|
45
|
+
`cnf.extensions_to_open = [...]` default in conf.rb:129; `filter_buffer` (11).
|
|
46
|
+
|
|
47
|
+
**file_finder.rb**: `updating?` (3).
|
|
48
|
+
|
|
49
|
+
**gui.rb** (~49): `start_profiler` (4) + `end_profiler` (5) — dev tools, keep if
|
|
50
|
+
used interactively; `gui_set_cursor_pos` (3), `handle_image_resize` (15,
|
|
51
|
+
"TODO:gtk4", connects a GTK3-only signal), `editor_area` (3),
|
|
52
|
+
`remove_extra_controllers` (15), `is_buffer_open` (4).
|
|
53
|
+
|
|
54
|
+
**gui_sourceview.rb** (~24): `show_controllers` (7), `cur_pos_xy` (3),
|
|
55
|
+
`sanity_check` (14).
|
|
56
|
+
|
|
57
|
+
**hyper_plain_text.rb**: `hpt_scan_audio` (26).
|
|
58
|
+
|
|
59
|
+
**key_binding_tree.rb**: `clear_modifiers` (3, body already commented out),
|
|
60
|
+
`cur_mode_str` (3).
|
|
61
|
+
|
|
62
|
+
**langservp.rb** (~15): `add_workspaces` (11, TODO stub),
|
|
63
|
+
`handle_responses` (4, empty TODO stub).
|
|
64
|
+
|
|
65
|
+
**macro.rb**: `dump_last_macro` (5).
|
|
66
|
+
|
|
67
|
+
**tests.rb**: `run_tests_0` (15) — broken (evals `test_write_0`, which doesn't
|
|
68
|
+
exist) and unused. Subsumed by Tier B if that is taken.
|
|
69
|
+
|
|
70
|
+
**util.rb** (~34): `running_wayland?` (11), `pipe_to_external` (17),
|
|
71
|
+
`expand_if_existing` (6).
|
|
72
|
+
|
|
73
|
+
## Tier B — delete legacy tests.rb entirely (~190 further lines)
|
|
74
|
+
|
|
75
|
+
`lib/vimamsa/tests.rb` (201 lines) predates the tests/ + test_framework.rb
|
|
76
|
+
suite: `run_tests`/`run_edit_tests`/`EditorTests`, two hash-oracle macro tests
|
|
77
|
+
(`test_paste_0` is a hard `return` stub), and the LOREM_IPSUM/JABBERWOCKY
|
|
78
|
+
constants (referenced nowhere else). Only entry point is the `:run_tests`
|
|
79
|
+
action (key_actions.rb:259) bound to `C , t r` (key_bindings_vimlike.rb:376).
|
|
80
|
+
Delete the file, the require in rbvma.rb:73, the action entry, and the binding.
|
|
81
|
+
If an in-editor test runner is still wanted on that key, repoint it at the
|
|
82
|
+
modern suite instead.
|
|
83
|
+
|
|
84
|
+
## Tier C — unbound actions (~40–70 lines, feature decision)
|
|
85
|
+
|
|
86
|
+
12 registered actions are never bound to a key, never called from code, and not
|
|
87
|
+
referenced in the default custom.rb. They remain reachable through the
|
|
88
|
+
action-search palette (`, , s`), so deleting them removes (obscure) features,
|
|
89
|
+
not just dead code — prune to taste:
|
|
90
|
+
|
|
91
|
+
`fhist_remove_nonexisting` (file_history.rb); from key_actions.rb: `eval_buf`,
|
|
92
|
+
`refresh_colors`, `gui_ensure_cursor_visible`, `close_all_buffers` (refs=0 —
|
|
93
|
+
its proc body references a method that doesn't exist), `refresh_func_panel`,
|
|
94
|
+
`V_to_latex_itemize`, `invoke_grep_search` (registered twice),
|
|
95
|
+
`execute_current_line_in_terminal_autoclose`, `delete_current_file`,
|
|
96
|
+
`buf_backup`, `debug_buf_hex`.
|
|
97
|
+
|
|
98
|
+
Check each proc body for helper functions that become orphaned once the action
|
|
99
|
+
is gone (then re-run the tier-A style scan).
|
|
100
|
+
|
|
101
|
+
## Tier D — commented-out code sweep (optional, ~390 lines)
|
|
102
|
+
|
|
103
|
+
Heuristic count of comment lines that look like code (assignments, method
|
|
104
|
+
calls, `signal_connect`, old `require`s): ~391 across lib/, concentrated in
|
|
105
|
+
buffer.rb (52), key_binding_tree.rb (48), key_bindings_vimlike.rb (42),
|
|
106
|
+
gui_sourceview.rb (38), gui.rb (27). Much of it is pre-GTK4 leftovers
|
|
107
|
+
(`#TODO:gtk4`) and abandoned experiments. This contradicts the repo's
|
|
108
|
+
"match the surrounding style" convention, so do it only as a deliberate,
|
|
109
|
+
per-file pass — keep comments that document intent (e.g. the guarded-binding
|
|
110
|
+
ordering notes), delete only mechanical dead code. Git history preserves
|
|
111
|
+
everything.
|
|
112
|
+
|
|
113
|
+
## Verification
|
|
114
|
+
|
|
115
|
+
- After each tier: `ruby exe/run_tests.rb --headless` (full suite).
|
|
116
|
+
- Tier B: verify `C , t r` is unbound (or repointed) and startup is clean with
|
|
117
|
+
scheme "vim" and "notepad" too (`cnf.keybindings.scheme`).
|
|
118
|
+
- Tier A langservp/editor items: open a Ruby file with LSP enabled once.
|
|
119
|
+
- Final: `wc -l lib/vimamsa/*.rb` before/after; one commit per tier.
|
|
120
|
+
- Also delete the superseded local scan reports (not in the repo).
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
# Plan: better Vim compatibility
|
|
2
|
+
|
|
3
|
+
TODO: act next on item 4 of "Order of work": missing motions (items 1-3 are
|
|
4
|
+
done). When an item is finished, move it
|
|
5
|
+
to the DONE section at the end of this document with a short summary and the
|
|
6
|
+
git ref(s).
|
|
7
|
+
|
|
8
|
+
Goal: someone who knows Vim can start using Vimamsa without relearning basic
|
|
9
|
+
editing.
|
|
10
|
+
|
|
11
|
+
The `vim` keymap (`lib/vimamsa/key_bindings_vim.rb`) is the reference
|
|
12
|
+
implementation of Vim behavior. The default `vimlike` keymap
|
|
13
|
+
(`lib/vimamsa/key_bindings_vimlike.rb`) gets **every Vim binding that doesn't
|
|
14
|
+
conflict with a binding vimlike already has**. A generated report records
|
|
15
|
+
every conflict (see "Conflicts" below).
|
|
16
|
+
|
|
17
|
+
[missing_vim_bindings.md](missing_vim_bindings.md) lists what is missing
|
|
18
|
+
today. This file says what to build, and in which order.
|
|
19
|
+
|
|
20
|
+
## Why the grammar matters most
|
|
21
|
+
|
|
22
|
+
Today each key combination is bound by hand (`C d e`, `C c w`, `C y $`, ...),
|
|
23
|
+
and the text objects are generated by a loop in `text_objects.rb`. Vim users
|
|
24
|
+
don't memorize those combinations. They combine an operator, a count and a
|
|
25
|
+
motion. Any combination nobody wrote out does nothing, and users notice that
|
|
26
|
+
within minutes. So the first and biggest step is a general operator + motion
|
|
27
|
+
layer, written as a binding syntax (`C <op> <motion>`, step 1). Most of the
|
|
28
|
+
later steps build on it.
|
|
29
|
+
|
|
30
|
+
## Shared Vim bindings
|
|
31
|
+
|
|
32
|
+
The Vim actions and the binding table go in shared code, for example
|
|
33
|
+
`lib/vimamsa/vim_core.rb` (actions, motions, operators, text objects) and a
|
|
34
|
+
table `VIM_BINDINGS` of `key => action`. The two keymaps use the table
|
|
35
|
+
differently:
|
|
36
|
+
|
|
37
|
+
- **`vim` keymap:** binds the whole table.
|
|
38
|
+
- **`vimlike` keymap:** loads its own bindings first, then binds each table
|
|
39
|
+
entry that doesn't conflict with them. Entries that conflict are skipped.
|
|
40
|
+
Vimlike's own bindings always win, so existing users see no change in
|
|
41
|
+
behavior.
|
|
42
|
+
|
|
43
|
+
"Conflict" is decided by a function, not by hand (see the next section). New
|
|
44
|
+
Vim bindings therefore show up in vimlike automatically, unless they clash.
|
|
45
|
+
|
|
46
|
+
## Conflicts: definition and automatic report
|
|
47
|
+
|
|
48
|
+
### What counts as a conflict
|
|
49
|
+
|
|
50
|
+
The check and its report are done (see DONE); the definition below is the
|
|
51
|
+
rule that loading the shared table into vimlike must follow.
|
|
52
|
+
|
|
53
|
+
A Vim binding `M k1 k2 ... kn` (mode `M`) conflicts with vimlike when one of
|
|
54
|
+
these holds:
|
|
55
|
+
|
|
56
|
+
1. **Same keys, different action:** vimlike binds exactly the same key sequence
|
|
57
|
+
in mode `M` to something else. Example: `C s` is `easy_jump` in vimlike
|
|
58
|
+
but "substitute character" in Vim.
|
|
59
|
+
2. **A vimlike binding is a prefix of the Vim one:** vimlike binds a shorter
|
|
60
|
+
sequence that runs at once, so the Vim sequence can never be reached.
|
|
61
|
+
Example: vimlike `C z` (start browse mode) blocks `z t`, `z z` and `z b`.
|
|
62
|
+
3. **The Vim binding is a prefix of vimlike ones:** for example, vimlike's
|
|
63
|
+
`,` is a leader key with dozens of `, x` bindings, so Vim's `,` (repeat
|
|
64
|
+
`f`/`t` backwards) can't be bound. The same goes for `space`, which starts
|
|
65
|
+
`C space <char>`.
|
|
66
|
+
|
|
67
|
+
Bindings for the same action, or ones that agree in meaning, are "shared",
|
|
68
|
+
not conflicts.
|
|
69
|
+
|
|
70
|
+
The check walks the real `KeyBindingTree` after vimlike has loaded, so it
|
|
71
|
+
always matches the code. It is not a hand-kept list.
|
|
72
|
+
|
|
73
|
+
### Known conflicts, for orientation
|
|
74
|
+
|
|
75
|
+
These are from reading the code; the report is the authority:
|
|
76
|
+
|
|
77
|
+
| Keys (Command mode) | vimlike | Vim |
|
|
78
|
+
| ------------------------- | ------------------------------ | ---------------------------- |
|
|
79
|
+
| `s` | easy_jump | substitute char |
|
|
80
|
+
| `C` | content search | change to end of line |
|
|
81
|
+
| `X` | open line below | delete char before cursor |
|
|
82
|
+
| `,` | leader prefix | repeat `f`/`t` backwards |
|
|
83
|
+
| `space` | `space <char>` insert prefix | move right |
|
|
84
|
+
| `z` | start browse mode | `zz`, `zt`, `zb`, folds |
|
|
85
|
+
| `tab` | switch to last buffer | jump forward (`ctrl-i`) |
|
|
86
|
+
| `V`, `ctrl-v` | other actions | linewise / block visual |
|
|
87
|
+
|
|
88
|
+
## Steps, in priority order
|
|
89
|
+
|
|
90
|
+
### 1. Operator + motion layer
|
|
91
|
+
|
|
92
|
+
#### Binding syntax: key sets
|
|
93
|
+
|
|
94
|
+
Operators, motions and text objects are defined as **key sets** in the keymap
|
|
95
|
+
files, as data, not hardcoded in Ruby. Bindings then combine them with
|
|
96
|
+
placeholders, the same way `<char>` and `<num>` work today:
|
|
97
|
+
|
|
98
|
+
```ruby
|
|
99
|
+
# lib/vimamsa/vim_core.rb (shared), next to VIM_BINDINGS
|
|
100
|
+
define_key_set :op, {
|
|
101
|
+
"d" => :delete, "c" => :change, "y" => :yank,
|
|
102
|
+
">" => :indent, "<" => :unindent, "=" => :reindent,
|
|
103
|
+
"g u" => :downcase, "g U" => :upcase, "g ~" => :swapcase, "g q" => :format,
|
|
104
|
+
}
|
|
105
|
+
define_key_set :motion, {
|
|
106
|
+
"w" => :word_next, "b" => :word_prev, "e" => :word_end,
|
|
107
|
+
"0" => :line_start, "^" => :line_first_char, "$" => :line_end,
|
|
108
|
+
"j" => :line_down, "k" => :line_up, "g g" => :buf_start, "G" => :buf_end,
|
|
109
|
+
"f <char>" => :find_char, "t <char>" => :till_char, ...
|
|
110
|
+
}
|
|
111
|
+
define_key_set :textobj, { "i <obj>" => :inner, "a <obj>" => :around } # <obj> from text_objects.rb
|
|
112
|
+
|
|
113
|
+
add_keys "vim operators", {
|
|
114
|
+
"C <op> <motion>" => :operator_motion, # d w, c e, y $, g U w
|
|
115
|
+
"C <op> <textobj>" => :operator_textobj, # d i w, c a "
|
|
116
|
+
"C <op> <same>" => :operator_lines, # d d, c c, > >, g U U
|
|
117
|
+
"C <motion>" => :motion_move, # plain cursor movement
|
|
118
|
+
"V <motion>" => :motion_extend, # extend the selection
|
|
119
|
+
"V <op>" => :operator_selection, # V >, v g U
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- **The action gets the matched values**, e.g. `operator_motion(op: :delete,
|
|
124
|
+
motion: :word_next, count: 6, char: nil)`. It doesn't parse keys.
|
|
125
|
+
- **Counts:** `<num>` is allowed before the operator and before the motion
|
|
126
|
+
without writing it out, and the counts multiply (`2 d 3 w` = 6). This reuses
|
|
127
|
+
`match_num_key` (`key_binding_tree.rb:505`).
|
|
128
|
+
- **Motion properties live in the set entry:** linewise, and inclusive or
|
|
129
|
+
exclusive, e.g. `"j" => { id: :line_down, linewise: true }`. The motion
|
|
130
|
+
objects (below) then only compute the target position.
|
|
131
|
+
- **Each keymap owns its sets.** `vim` uses the full sets. `vimlike` uses the same
|
|
132
|
+
sets minus the keys it binds to something else, and the conflict check
|
|
133
|
+
decides that. `custom.rb` can extend a set:
|
|
134
|
+
`key_set_add :motion, "ö" => :para_next`. Every operator then works with the
|
|
135
|
+
new motion.
|
|
136
|
+
- **Implementation:** expand the templates into concrete tree nodes when they're
|
|
137
|
+
bound. For example, `C <op> <motion>` becomes `C d w`, `C g U $`, … Each node
|
|
138
|
+
remembers the values it was expanded from and the template it came from. That
|
|
139
|
+
keeps the existing tree, prefix matching, `esc` cancelling and the conflict
|
|
140
|
+
check working unchanged. The help page can show the template line instead of
|
|
141
|
+
hundreds of expanded ones (see `doc/key_bindings_report_plan.md`). A key set
|
|
142
|
+
change rebinds the templates that use it.
|
|
143
|
+
- The hand-made bindings and the text-object loop in `text_objects.rb:347` are
|
|
144
|
+
replaced by these templates.
|
|
145
|
+
|
|
146
|
+
#### Behavior
|
|
147
|
+
|
|
148
|
+
- **Motions** are objects that, given a buffer, a position and a count, return
|
|
149
|
+
a target position. Each one is also marked:
|
|
150
|
+
- charwise or linewise (`j`, `k`, `G` and `gg` are linewise),
|
|
151
|
+
- inclusive or exclusive (`e` and `f` are inclusive; `w` and `b` are exclusive).
|
|
152
|
+
- **Operators** (`d c y > < = gu gU g~ gq`) take a range plus a
|
|
153
|
+
linewise/charwise flag and act on it. Doubling an operator (`dd`, `cc`, `>>`,
|
|
154
|
+
`gUU`) acts on `count` lines.
|
|
155
|
+
- **Counts** work on both and multiply: `3dw`, `d3w`, `2d3w`. Counts inside a
|
|
156
|
+
sequence already work where a binding has `<num>` (see DONE); the layer makes
|
|
157
|
+
them general.
|
|
158
|
+
- **Operator-pending state** comes from the expanded tree. After `d`, the tree is
|
|
159
|
+
in the middle of the `C <op> <motion>` sequences, and `esc` cancels as for any
|
|
160
|
+
other sequence. The mode indicator shows `d` while it waits.
|
|
161
|
+
- The same motion objects drive plain cursor movement and Visual-mode extension,
|
|
162
|
+
so each motion is written only once.
|
|
163
|
+
- Keep `cw` behaving like `ce`, and keep `dw` stopping at the end of the line,
|
|
164
|
+
as in Vim.
|
|
165
|
+
|
|
166
|
+
The conflict check applies inside operator-pending state too. When vimlike
|
|
167
|
+
binds `d <x>` to something of its own, that wins, and the report lists it.
|
|
168
|
+
|
|
169
|
+
### 2. Missing motions
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
- `t` / `T`, with `;` and `,` repeating them.
|
|
173
|
+
- `%`.
|
|
174
|
+
- `?`, and `#` for the word under the cursor.
|
|
175
|
+
- `W B E ge gE`.
|
|
176
|
+
- `{ }` and `( )`.
|
|
177
|
+
- `H M L`.
|
|
178
|
+
- Half-page `ctrl-d` / `ctrl-u`; `ctrl-e` / `ctrl-y`; `zt zz zb`.
|
|
179
|
+
|
|
180
|
+
Most of these are small once step 1 exists. The ones that don't conflict
|
|
181
|
+
(`t`, `%`, `W`, `{`, ...) go into vimlike too.
|
|
182
|
+
|
|
183
|
+
### 3. Visual modes
|
|
184
|
+
|
|
185
|
+
- Linewise `V` and blockwise `ctrl-v`. Block mode needs `I` / `A` for inserting
|
|
186
|
+
text on many lines at once.
|
|
187
|
+
- `o` (go to the other end of the selection) and `gv` (select the last area again).
|
|
188
|
+
- Visual mode applies operators through the step 1 layer (`V>`, `vgU`, ...).
|
|
189
|
+
|
|
190
|
+
In vimlike, `V` and `ctrl-v` already have other uses, so they are conflicts.
|
|
191
|
+
The modes themselves are still shared code, and vimlike can reach them
|
|
192
|
+
through other keys if wanted.
|
|
193
|
+
|
|
194
|
+
### 4. Registers, put, repeat and undo
|
|
195
|
+
|
|
196
|
+
- Registers remember whether text was yanked linewise or charwise. After `yy`
|
|
197
|
+
or `dd`, `p` / `P` puts it below or above the line, not at the cursor.
|
|
198
|
+
- Registers: named (`"a`–`"z`, with `"A` appending), unnamed `""`, yank `"0`,
|
|
199
|
+
numbered `"1`–`"9`, clipboard `"+` / `"*`, and black hole `"_`. Also
|
|
200
|
+
`ctrl-r x` in Insert mode.
|
|
201
|
+
- `.` repeats the last change exactly: the operator, the motion and count, and
|
|
202
|
+
any text typed in Insert mode. Recording changes as data (step 1) makes this
|
|
203
|
+
possible.
|
|
204
|
+
- One Insert-mode session (`i...esc`) is one undo step. (TODO: this should be configurable option. if user spends a long time in insert mode, this doesn't make sense)
|
|
205
|
+
|
|
206
|
+
### 5. Ex commands
|
|
207
|
+
|
|
208
|
+
Only limited support: the few Ex commands people type every day, not Vim's
|
|
209
|
+
whole command language. Extend `lib/vimamsa/gui_command_line.rb`, which already
|
|
210
|
+
handles `:w :q :wq :e :42 :!`:
|
|
211
|
+
|
|
212
|
+
- `:s/pat/rep/flags` comes first. It takes a range: `%`, `.`, `$`, `N,M`, `'<,'>`
|
|
213
|
+
(the default is the current line).
|
|
214
|
+
- The pattern is a **Ruby regex**, as in the editor's other searches. There is
|
|
215
|
+
no translation of Vim regex syntax.
|
|
216
|
+
- The replacement uses Ruby's `gsub` syntax (`\1`, `\k<name>`, `\0`).
|
|
217
|
+
- Flags: `g` (all matches on a line), `i` (ignore case).
|
|
218
|
+
- `:noh`, `:x`, `:wa`, `:qa`.
|
|
219
|
+
- `:bn`, `:bp`, `:bd`.
|
|
220
|
+
- `:set` for a few options mapped onto `cnf`: `ts`, `sw`, `et`, `nu`, `wrap`.
|
|
221
|
+
|
|
222
|
+
Not planned: `:b N`, `:<range>d`, `:<range>y`, `:<range>>`, `:g` / `:v`, more
|
|
223
|
+
`:set` options. A command that looks like an Ex command (one word, with an
|
|
224
|
+
optional range), isn't supported, and also fails as Ruby gets "Ex command
|
|
225
|
+
`:xyz` is not supported" instead of a Ruby error.
|
|
226
|
+
|
|
227
|
+
The command line already runs Ruby code as a fallback. Vim commands must be
|
|
228
|
+
tried first, and Ruby only when nothing matches. The command line is shared,
|
|
229
|
+
so this applies to both keymaps.
|
|
230
|
+
|
|
231
|
+
### 6. Smaller habits
|
|
232
|
+
|
|
233
|
+
- A real jumplist: `ctrl-o` / `ctrl-i` and ``` `` ```.
|
|
234
|
+
- `gi`, `gJ`, `ctrl-x` (decrement), `gq`.
|
|
235
|
+
- Insert mode: `ctrl-w`, `ctrl-u`, `ctrl-o {cmd}`.
|
|
236
|
+
|
|
237
|
+
## Supporting work
|
|
238
|
+
|
|
239
|
+
### Differential tests against real Vim
|
|
240
|
+
|
|
241
|
+
A vim-compatibility test suite (for example
|
|
242
|
+
`tests/test_vim_compat.rb`) runs each case in both editors and compares the
|
|
243
|
+
buffer text and cursor position:
|
|
244
|
+
|
|
245
|
+
```sh
|
|
246
|
+
vim -Nu NONE -i NONE -es -c 'exe "norm! <keys>"' -c 'wq' file
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
A case is just `(start text, start cursor, keys)`, so one table can hold
|
|
250
|
+
hundreds of cases. Skip the suite when `vim` isn't installed.
|
|
251
|
+
|
|
252
|
+
- Run every case with the `vim` keymap.
|
|
253
|
+
- Also run it with `vimlike`, except for cases whose keys are in the
|
|
254
|
+
generated conflict list. That proves the shared bindings behave the same in
|
|
255
|
+
both keymaps.
|
|
256
|
+
|
|
257
|
+
Done so far for text objects only (see DONE); the general suite is open.
|
|
258
|
+
|
|
259
|
+
This makes "compatible" something the tests measure, and it catches the
|
|
260
|
+
off-by-one edge cases (`$`, `e` at the end of a word, `cw`, linewise put) that
|
|
261
|
+
reading the code misses.
|
|
262
|
+
|
|
263
|
+
### Onboarding
|
|
264
|
+
|
|
265
|
+
- **First run:** ask whether to use "Vim keys" or "Vimamsa keys". Today a
|
|
266
|
+
Vim user has to find the scheme setting on their own.
|
|
267
|
+
- **A "differences from Vim" page:** a short list of the deliberate
|
|
268
|
+
differences in the `vim` keymap, built from the header comment of
|
|
269
|
+
`key_bindings_vim.rb`. For vimlike, the generated conflict report already
|
|
270
|
+
covers this. Reach both through `:help vim` or the Help menu.
|
|
271
|
+
- **Optional:** read simple mappings (`nnoremap`, `inoremap` and `vnoremap`
|
|
272
|
+
lines only) from `~/.vimrc`, or from a `~/.vimamsa/vimrc`, so personal
|
|
273
|
+
mappings carry over.
|
|
274
|
+
|
|
275
|
+
### Investigate: switching keymap without restart
|
|
276
|
+
|
|
277
|
+
Today the scheme (`cnf.keybindings.scheme`) is read once in `Editor#start`, and
|
|
278
|
+
changing it needs a restart. Find out whether a switch at runtime (from
|
|
279
|
+
Settings, or `:set keymap=vim`) is feasible, and what it would break:
|
|
280
|
+
|
|
281
|
+
- **Rebuilding the tree:** a new `KeyBindingTree` must be built, and then
|
|
282
|
+
every binding made after the scheme file must be added again. That includes
|
|
283
|
+
module bindings (`search_replace.rb`, `file_manager.rb`, buffer manager,
|
|
284
|
+
bookmarks, diff view), plugins and both phases of `custom.rb`. They are now
|
|
285
|
+
scattered `bindkey` calls run once at startup. They would need to be
|
|
286
|
+
replayable, either by recording every `bindkey` call with its origin or by
|
|
287
|
+
giving each module a `bind_keys` hook.
|
|
288
|
+
- **Actions:** scheme files register actions (`reg_act`) and define helper
|
|
289
|
+
methods (`_insert_move`, ...) with the same names in both schemes. Leftovers
|
|
290
|
+
from the old scheme stay in `vma.actions`, and redefinitions overwrite each
|
|
291
|
+
other. Scheme-only actions would need to be namespaced or unregistered.
|
|
292
|
+
- **Global side effects:** scheme files also set `cnf.mode.*` cursor colors,
|
|
293
|
+
which overwrites what the user set in `custom.rb`.
|
|
294
|
+
- **Live state:** the current mode, a half-typed key sequence, a pending
|
|
295
|
+
count, macro recording, minor modes on open buffers (`fexp`, `grep`,
|
|
296
|
+
`bmgr`) and `vma.kbd` listeners (`setup_kbd_handlers`) all point into the
|
|
297
|
+
old tree. The switch has to happen from a clean state: Command mode, no
|
|
298
|
+
pending keys, listeners moved to the new tree.
|
|
299
|
+
- **Things that cache bindings:** the menu labels (`act_bindings`), the key
|
|
300
|
+
binding help buffer and the conflict report must be rebuilt.
|
|
301
|
+
- **Macros and muscle memory:** recorded macros are key sequences, so they
|
|
302
|
+
mean something else in the other scheme.
|
|
303
|
+
- **Tests:** tests assume vimlike (`--test` forces it). A switch test would
|
|
304
|
+
check that bindings, modes and the user's custom bindings survive vimlike →
|
|
305
|
+
vim → vimlike.
|
|
306
|
+
|
|
307
|
+
The sandbox loader written for the conflict report (it loads a scheme file
|
|
308
|
+
into a separate tree and restores the actions, methods and `cnf` it touches)
|
|
309
|
+
is a first step and shows which side effects exist. The outcome of the
|
|
310
|
+
investigation is a short note: feasible as is, feasible after a refactor (say
|
|
311
|
+
which), or keep the restart.
|
|
312
|
+
|
|
313
|
+
## Order of work
|
|
314
|
+
|
|
315
|
+
1. ~~Move the existing Vim bindings into the shared table. Load the
|
|
316
|
+
non-conflicting ones into vimlike.~~ Done, see DONE.
|
|
317
|
+
2. ~~The key-set binding syntax (`<op>`, `<motion>`, `<textobj>`, `<same>`), the
|
|
318
|
+
operator layer and ported motions, and the differential test suite. Port the
|
|
319
|
+
existing hand-made bindings first, so nothing gets worse. This includes the
|
|
320
|
+
text object bindings, which are bound per operator for now.~~ Done, see DONE.
|
|
321
|
+
3. ~~Registers that remember linewise text, and linewise put.~~ Done, see DONE.
|
|
322
|
+
4. Missing motions.
|
|
323
|
+
5. `V` and `ctrl-v`.
|
|
324
|
+
6. ~~`.` repeat, and undo grouping for Insert sessions.~~ Done (ahead of 4 and
|
|
325
|
+
5), see DONE.
|
|
326
|
+
7. `:s` with ranges, then the few other Ex commands.
|
|
327
|
+
8. Onboarding: the first-run question and the differences page.
|
|
328
|
+
9. Step 6 items and `.vimrc` import.
|
|
329
|
+
10. The investigation into switching keymaps without restart. It can run any
|
|
330
|
+
time; the sandbox loader it builds on exists.
|
|
331
|
+
|
|
332
|
+
Each step regenerates `doc/vimlike_vim_conflicts.md` and updates
|
|
333
|
+
`missing_vim_bindings.md` and the header comment of `key_bindings_vim.rb`.
|
|
334
|
+
|
|
335
|
+
## DONE
|
|
336
|
+
|
|
337
|
+
- **Conflict report** (2026-11-18, `b7d113a`): `vim_binding_conflicts` in
|
|
338
|
+
`key_bindings_report.rb` loads both keymap files into separate key trees (a
|
|
339
|
+
sandbox loader that restores `vma.kbd`, actions, helper methods and cursor
|
|
340
|
+
colors) and classifies each vim binding as shared, missing from vimlike, or
|
|
341
|
+
a conflict (same keys with another action, blocked by a shorter vimlike
|
|
342
|
+
binding, vimlike uses the keys as a prefix, or taken by a `<char>` binding).
|
|
343
|
+
Bindings that run the same code count as shared. The report is
|
|
344
|
+
`doc/vimlike_vim_conflicts.md`, regenerated with
|
|
345
|
+
`VMA_UPDATE_DOC=1 ruby exe/run_tests.rb --headless vim_conflicts`;
|
|
346
|
+
`tests/test_vim_conflicts.rb` fails when it is out of date. Help menu:
|
|
347
|
+
"Vim keys that differ in vimlike". Differs from the plan: no "Added to
|
|
348
|
+
vimlike" group yet (needs the shared table), and "Not implemented" lists
|
|
349
|
+
only vim-keymap bindings missing from vimlike, not a full reference list.
|
|
350
|
+
- **Text objects** (2026-11-18, `4c5ed8b`): `lib/vimamsa/text_objects.rb`.
|
|
351
|
+
`iw aw iW aW is as ip ap`, quotes (`" ' \``), brackets `( [ { <` with the
|
|
352
|
+
`b`/`B` aliases, and `it`/`at`, after `d c y gU gu g~` and in Visual mode, in
|
|
353
|
+
both keymaps. Follows vim 9.1, including the white space `aw`/`a"` take,
|
|
354
|
+
linewise inner blocks, `di(` using the next block on the line, and a count
|
|
355
|
+
before the operator (`2di(`). Bound per operator for now, not through the
|
|
356
|
+
operator-pending layer (step 1).
|
|
357
|
+
- **Differential test against real vim, text objects** (2026-11-18, `4c5ed8b`,
|
|
358
|
+
`e464117`): `tests/test_text_objects.rb` holds 57 cases with vim's results
|
|
359
|
+
and re-checks them against `vim -Nu NONE -es` when vim is installed. The
|
|
360
|
+
test VM now installs vim, so the check runs there.
|
|
361
|
+
- **Shared `VIM_BINDINGS` table** (2026-11-20, `f1535c7`):
|
|
362
|
+
`lib/vimamsa/vim_core.rb` holds the vim composite actions
|
|
363
|
+
(`reg_vim_actions`) and the table, moved out of `key_bindings_vim.rb`, which
|
|
364
|
+
now binds all of it with `bind_vim_bindings` and keeps only its modes and
|
|
365
|
+
its own deviations (`C tab`, `C enter`, browse mode, audio).
|
|
366
|
+
`key_bindings_vimlike.rb` ends with `bind_vim_bindings(only_free: true)`:
|
|
367
|
+
each entry is bound only if `vim_binding_status` finds it `:missing`, so
|
|
368
|
+
vimlike's own bindings win, and the menus keep showing vimlike's keys for an
|
|
369
|
+
action. That added 19 bindings to vimlike (`c w c e c c c $ D S Y . y w y $`,
|
|
370
|
+
`` ` ``, `ctrl-a ctrl-b ctrl-d ctrl-f ctrl-u`, Visual `< > c`); the 20
|
|
371
|
+
conflicts are unchanged. What was added is kept in `vma.kbd.vim_added`, and
|
|
372
|
+
the report has a new "Added to vimlike" group. `run_tests_vm.rb` forwards
|
|
373
|
+
`VMA_UPDATE_DOC=1` and copies the regenerated report back, so
|
|
374
|
+
`VMA_UPDATE_DOC=1 ./run_tests_vm.rb vim_conflicts` updates it from the VM.
|
|
375
|
+
Note for later steps: module and `custom.rb` bindings load after the table,
|
|
376
|
+
so they override an added entry with the same keys.
|
|
377
|
+
- **Count inside a key sequence** (2026-11-19, `2e9fb0b`): `d 3 e` works, and
|
|
378
|
+
any binding with `<num>`. The count multiplies one typed before the
|
|
379
|
+
sequence (`2 d 3 e` = 6). A first piece of the counts in step 1.
|
|
380
|
+
- **Operator + motion layer** (step 1, order item 2; 2026-11-21). Key sets
|
|
381
|
+
and templates in `KeyBindingTree` (`define_key_set`, `key_set_add`,
|
|
382
|
+
`bind_template`): a binding like `"C <op> <motion>"` is expanded into one
|
|
383
|
+
tree node per combination, each remembering its values (`bind_args`) and
|
|
384
|
+
its template; the action gets the values, `a.op.motion!({ op: :delete,
|
|
385
|
+
motion: :word_next })`, plus the typed `<char>`. A `<num>` variant before
|
|
386
|
+
every placeholder but the first gives counts after the operator; they
|
|
387
|
+
multiply with a count before it. `key_set_add` binds the new combinations
|
|
388
|
+
of every template already bound. `lib/vimamsa/vim_operators.rb` has the
|
|
389
|
+
sets (`VIM_KEY_SETS`: operators `d c y gU gu g~ > <`, 27 motions, `i`/`a`
|
|
390
|
+
text objects), what each motion means (`VIM_MOTIONS`: linewise,
|
|
391
|
+
inclusive) and the Buffer methods (`vim_motion_target`,
|
|
392
|
+
`vim_operator_motion`, `vim_operator_lines`, `vim_apply_operator`, also
|
|
393
|
+
used by `text_object_op`). Vim rules: exclusive motions ending in column 0,
|
|
394
|
+
`dw` on the last word of a line, `cw` = `ce`, multi-line `d$` from the
|
|
395
|
+
indent is linewise, `5dd` with fewer lines does nothing. The templates are
|
|
396
|
+
the "vim operators" section of `VIM_BINDINGS`; the hand-made `d`/`c`/`y`/
|
|
397
|
+
`gU` combinations and `bind_vim_text_objects` are gone. The plain-motion
|
|
398
|
+
template (`VC <motion>`) is bound only where a keymap has no binding of its
|
|
399
|
+
own, so it adds `W B E t T` (and the vim keymap's `$` is now the vim
|
|
400
|
+
motion, fixing the old `$dFa` failure). vimlike adds its `O` motion to the
|
|
401
|
+
set. The key bindings page shows a template as one line and lists the key
|
|
402
|
+
sets; the conflicts report groups template expansions per template.
|
|
403
|
+
Deviation from the design above: motion properties (linewise, inclusive)
|
|
404
|
+
are in `VIM_MOTIONS`, not in the key set entries, because they belong to
|
|
405
|
+
the motion, not to its key. `=` and `gq` are not done.
|
|
406
|
+
Tests: `tests/test_vim_operators.rb` (vimlike, checked against real vim),
|
|
407
|
+
oracle cases in `tests/test_vim_bindings.rb` (vim keymap).
|
|
408
|
+
- **Registers** (step 4, order item 3; 2026-11-21). `lib/vimamsa/registers.rb`:
|
|
409
|
+
`vma.registers` holds each register's text and whether it was copied as
|
|
410
|
+
whole lines. `""` (unnamed), `"0` (last copy), `"1`–`"9` (deletes of
|
|
411
|
+
whole lines or of text spanning lines, shifted on each one), `"-` (smaller
|
|
412
|
+
deletes), `"a`–`"z` (`"A` appends; linewise if either part is), `"+` /
|
|
413
|
+
`"*` and the black hole `"_`. `"x` (Command and Visual mode, `edit.register`,
|
|
414
|
+
in the shared table; vimlike also keeps its `, r x`) selects a register
|
|
415
|
+
for the next command only; a count may come between (`"a3yy`).
|
|
416
|
+
`Clipboard#set(text, linewise:, kind:)` stores through the registers, so
|
|
417
|
+
every copy and delete (the operators, text objects, `yy`, `dd`, Visual
|
|
418
|
+
mode, ...) goes through one place; the system clipboard still gets every
|
|
419
|
+
copy except into `"_`. Put (`Buffer#paste_register`): a named register
|
|
420
|
+
directly; the unnamed one and `"+` / `"*` read the system clipboard, and
|
|
421
|
+
its text is put as lines only if it is what the editor copied as lines.
|
|
422
|
+
This replaces the per-buffer `@paste_lines`, so `yy` in one buffer and `p`
|
|
423
|
+
in another puts a line. Case changes and other text replacements no longer
|
|
424
|
+
overwrite the clipboard (`delete_range(..., register: false)`). Insert mode
|
|
425
|
+
`ctrl-r x` (`edit.insert.register`) is in the vim keymap only, listed in
|
|
426
|
+
`VIM_KEYMAP_ONLY` (no new ctrl chords in vimlike). `:reg` / `:registers` on
|
|
427
|
+
the command line and `edit.register.list` show the registers.
|
|
428
|
+
Not done: `".`, `"%`, `":`, `"/` and the expression register, keeping
|
|
429
|
+
registers across restarts, Visual mode put replacing the selection from a
|
|
430
|
+
register.
|
|
431
|
+
Tests: `tests/test_registers.rb`.
|
|
432
|
+
- **`.` repeat and Insert-session undo** (step 4, order item 6; 2026-11-21).
|
|
433
|
+
`lib/vimamsa/dot_repeat.rb` (`vma.dot`) follows the key tree's
|
|
434
|
+
`:key_action` / `:action_handled` events. A change is a command run from
|
|
435
|
+
Command mode that changed the buffer, or that started Insert or Replace
|
|
436
|
+
mode; then everything done until that mode is left is part of it (typed
|
|
437
|
+
text, backspace, the leaving key). It is stored as the tree ran it (for the
|
|
438
|
+
operator layer `a.op.motion!({...})`), with its count and register. `.`
|
|
439
|
+
(`undo.repeat`) runs it again through `handle_key_bindigs_action`, as one
|
|
440
|
+
undo step; a count given to `.` replaces the change's count, or for an
|
|
441
|
+
insert command (`i`, `a`, `o`) repeats the typed text. Undo, macros and
|
|
442
|
+
commands on files, buffers or the view are not changes. A mode change no
|
|
443
|
+
longer starts a new undo step while a group runs as one step (a macro, a
|
|
444
|
+
repeat). `cnf.undo.insert_one_step` (Settings ▸ Behavior, default false):
|
|
445
|
+
true makes an Insert session one undo step also across pauses; false
|
|
446
|
+
keeps the current behavior, where a pause of `cnf.undo.group_threshold`
|
|
447
|
+
seconds starts a new step.
|
|
448
|
+
Not done: `.` for Visual mode changes, `"1p...` stepping through the
|
|
449
|
+
numbered registers, a `cw` and its typed text as one undo step (they are
|
|
450
|
+
two). Found on the way: `esc` doesn't move the cursor left as in vim.
|
|
451
|
+
Tests: `tests/test_dot_repeat.rb`, oracle cases in `test_vim_bindings.rb`.
|