vimamsa 0.1.27 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/appimage.yml +17 -10
  3. data/Dockerfile +2 -2
  4. data/README.md +162 -90
  5. data/custom_example.rb +33 -15
  6. data/doc/TODO.md +334 -110
  7. data/doc/action_names_plan.md +442 -0
  8. data/doc/bundling_plan.md +2 -1
  9. data/doc/delta_syntax_plan.md +293 -0
  10. data/doc/demo_recording_plan.md +288 -0
  11. data/doc/design_goals.md +27 -0
  12. data/doc/intro_page_plan.md +266 -0
  13. data/doc/key_bindings_report_plan.md +45 -0
  14. data/doc/line_tree_plan.md +89 -0
  15. data/doc/missing_vim_bindings.md +34 -44
  16. data/doc/modules_settings_plan.md +1 -1
  17. data/doc/registries_plan.md +202 -0
  18. data/doc/startup_speed_plan.md +97 -0
  19. data/doc/test_commands.md +232 -0
  20. data/doc/treap_visualizer.html +585 -0
  21. data/doc/vim_compatibility_plan.md +186 -31
  22. data/doc/vimlike_vim_conflicts.md +236 -228
  23. data/doc/vm_snapshots_plan.md +4 -4
  24. data/doc/wysiwyg_plan.md +231 -0
  25. data/docker_cmd.sh +1 -1
  26. data/exe/run_tests.rb +85 -3
  27. data/exe/vimamsa +49 -6
  28. data/help/intro.txt +30 -0
  29. data/help/vim_intro.txt +31 -0
  30. data/img/demo.gif +0 -0
  31. data/img/demo.mp4 +0 -0
  32. data/lang/hyperplaintext.lang +1 -1
  33. data/lib/vimamsa/ack.rb +2 -0
  34. data/lib/vimamsa/actions.rb +381 -36
  35. data/lib/vimamsa/bookmarks.rb +8 -8
  36. data/lib/vimamsa/buffer.rb +84 -38
  37. data/lib/vimamsa/buffer_changetext.rb +58 -36
  38. data/lib/vimamsa/buffer_list.rb +2 -2
  39. data/lib/vimamsa/buffer_manager.rb +6 -6
  40. data/lib/vimamsa/cli_help.rb +75 -0
  41. data/lib/vimamsa/clipboard.rb +6 -3
  42. data/lib/vimamsa/conf.rb +9 -0
  43. data/lib/vimamsa/crash_handler.rb +2 -2
  44. data/lib/vimamsa/debug.rb +2 -2
  45. data/lib/vimamsa/demo_player.rb +494 -0
  46. data/lib/vimamsa/demo_recorder.rb +277 -0
  47. data/lib/vimamsa/diff_buffer.rb +1 -1
  48. data/lib/vimamsa/dot_repeat.rb +104 -0
  49. data/lib/vimamsa/easy_jump.rb +54 -3
  50. data/lib/vimamsa/editor.rb +136 -65
  51. data/lib/vimamsa/file_history.rb +1 -1
  52. data/lib/vimamsa/file_manager.rb +23 -23
  53. data/lib/vimamsa/form_input.rb +388 -0
  54. data/lib/vimamsa/gui.rb +89 -13
  55. data/lib/vimamsa/gui_command_line.rb +44 -5
  56. data/lib/vimamsa/gui_form_generator.rb +17 -6
  57. data/lib/vimamsa/gui_func_panel.rb +1 -1
  58. data/lib/vimamsa/gui_key_hint.rb +165 -0
  59. data/lib/vimamsa/gui_keylog_panel.rb +164 -2
  60. data/lib/vimamsa/gui_menu.rb +69 -50
  61. data/lib/vimamsa/gui_select_window.rb +77 -43
  62. data/lib/vimamsa/gui_settings.rb +9 -5
  63. data/lib/vimamsa/gui_sourceview.rb +28 -81
  64. data/lib/vimamsa/gui_theme.rb +11 -2
  65. data/lib/vimamsa/hook.rb +2 -0
  66. data/lib/vimamsa/intro_page.rb +367 -0
  67. data/lib/vimamsa/key_actions.rb +315 -225
  68. data/lib/vimamsa/key_binding_tree.rb +228 -61
  69. data/lib/vimamsa/key_bindings_notepad.rb +18 -16
  70. data/lib/vimamsa/key_bindings_report.rb +290 -67
  71. data/lib/vimamsa/key_bindings_vim.rb +43 -297
  72. data/lib/vimamsa/key_bindings_vim_core.rb +356 -0
  73. data/lib/vimamsa/key_bindings_vimlike.rb +347 -339
  74. data/lib/vimamsa/key_names.rb +80 -0
  75. data/lib/vimamsa/langservp.rb +62 -7
  76. data/lib/vimamsa/line_tree.rb +367 -0
  77. data/lib/vimamsa/macro.rb +20 -3
  78. data/lib/vimamsa/rbvma.rb +15 -0
  79. data/lib/vimamsa/registers.rb +125 -0
  80. data/lib/vimamsa/run_ruby.rb +64 -0
  81. data/lib/vimamsa/search_replace.rb +4 -4
  82. data/lib/vimamsa/string_util.rb +17 -3
  83. data/lib/vimamsa/tests.rb +8 -8
  84. data/lib/vimamsa/text_objects.rb +11 -54
  85. data/lib/vimamsa/text_transforms.rb +4 -0
  86. data/lib/vimamsa/tmp_user_dir.rb +39 -0
  87. data/lib/vimamsa/user_dirs.rb +83 -0
  88. data/lib/vimamsa/version.rb +1 -1
  89. data/lib/vimamsa/vim_operators.rb +365 -0
  90. data/modules/calculator/calculator.rb +5 -5
  91. data/modules/color_highlight/color_highlight.rb +3 -3
  92. data/modules/dictation/dictation.rb +32 -32
  93. data/modules/ollama/ollama.rb +5 -5
  94. data/modules/terminal/terminal.rb +5 -5
  95. data/modules/tts/tts.rb +10 -10
  96. data/run_e2e_vm.sh +3 -3
  97. data/run_tests_vm.rb +163 -0
  98. data/scripts/appimage/AppRun +7 -0
  99. data/scripts/appimage/build_in_container.sh +11 -1
  100. data/scripts/appimage/smoke_test.sh +1 -1
  101. data/scripts/demo/demo_easyjump_steps.txt +60 -0
  102. data/scripts/demo/demo_files_steps.txt +52 -0
  103. data/scripts/demo/demo_steps.txt +9 -1
  104. data/scripts/demo/notes.txt +6 -0
  105. data/scripts/demo/record_demo.rb +60 -81
  106. data/scripts/demo/report.rb +7 -0
  107. data/scripts/demo/shapes.rb +1 -0
  108. data/scripts/demo/square/shapes.rb +29 -0
  109. data/scripts/demo/square/steps.txt +185 -0
  110. data/scripts/lib/perf_startup.rb +138 -0
  111. data/scripts/lib/script_helpers.rb +53 -0
  112. data/scripts/perf_compare.rb +34 -0
  113. data/scripts/profile_startup.rb +72 -0
  114. data/tests/test_action_ids.rb +232 -0
  115. data/tests/test_auto_format.rb +2 -2
  116. data/tests/test_autocomplete.rb +1 -1
  117. data/tests/test_basic_editing.rb +18 -18
  118. data/tests/test_bookmarks.rb +6 -6
  119. data/tests/test_bracket_match.rb +3 -0
  120. data/tests/test_cli_help.rb +64 -0
  121. data/tests/test_color_highlight.rb +2 -2
  122. data/tests/test_command_line.rb +1 -1
  123. data/tests/test_context_menu_file.rb +18 -0
  124. data/tests/test_copy_paste.rb +33 -33
  125. data/tests/test_custom_two_phase.rb +1 -1
  126. data/tests/test_demo_player.rb +355 -0
  127. data/tests/test_demo_recorder.rb +202 -0
  128. data/tests/test_dictation.rb +16 -16
  129. data/tests/test_dot_repeat.rb +88 -0
  130. data/tests/test_easy_jump.rb +93 -0
  131. data/tests/test_extract_file_links.rb +3 -3
  132. data/tests/test_file_panel.rb +2 -2
  133. data/tests/test_flash.rb +1 -1
  134. data/tests/test_fold.rb +1 -1
  135. data/tests/test_form_input.rb +203 -0
  136. data/tests/test_func_panel.rb +2 -2
  137. data/tests/test_gtk_sync.rb +7 -7
  138. data/tests/test_intro_page.rb +437 -0
  139. data/tests/test_key_categories.rb +163 -0
  140. data/tests/test_keylog_panel.rb +163 -3
  141. data/tests/test_line_ends.rb +51 -0
  142. data/tests/test_line_tree.rb +86 -0
  143. data/tests/test_lsp_clangd.rb +2 -2
  144. data/tests/test_lsp_root.rb +43 -0
  145. data/tests/test_macro.rb +2 -2
  146. data/tests/test_module_interface.rb +9 -9
  147. data/tests/test_notepad_bindings.rb +5 -5
  148. data/tests/test_perf_startup.rb +28 -0
  149. data/tests/test_random_edit.rb +27 -27
  150. data/tests/test_registers.rb +131 -0
  151. data/tests/test_run_ruby.rb +77 -0
  152. data/tests/test_startup_file.rb +45 -4
  153. data/tests/test_text_objects.rb +1 -1
  154. data/tests/test_text_transforms.rb +12 -0
  155. data/tests/test_tmp_user_dir.rb +79 -0
  156. data/tests/test_tts.rb +10 -10
  157. data/tests/test_undo.rb +34 -34
  158. data/tests/test_user_dirs.rb +122 -0
  159. data/tests/test_vim_bindings.rb +107 -6
  160. data/tests/test_vim_conflicts.rb +41 -4
  161. data/tests/test_vim_operators.rb +116 -0
  162. data/tests/test_window_layout.rb +83 -0
  163. data/vimamsa.gemspec +1 -1
  164. data/vm_guest_run.sh +75 -28
  165. metadata +60 -4
  166. data/run_tests.rb +0 -89
  167. data/run_tests_vm.sh +0 -130
data/doc/TODO.md CHANGED
@@ -8,114 +8,42 @@ the git ref(s), as a short commit hash or a range.
8
8
 
9
9
  ## Open
10
10
 
11
- ### Stop writing to `~/.vimamsa`; use XDG dirs (`~/.config` / `~/.local/share`)
12
-
13
- Nothing should be written to `~/.vimamsa` or other ad-hoc dot dirs. User-edited
14
- configuration goes in `~/.config/vimamsa` (`$XDG_CONFIG_HOME`). Files the program
15
- generates (history, session, backups, caches, downloaded models/venvs) go in
16
- `~/.local/share/vimamsa` (`$XDG_DATA_HOME`).
17
-
18
- Hardcoded paths found (2026-11-18). They also bypass `vma_user_dir` / `--user-dir`, so
19
- the test suite (`~/.config/vimamsa-test`) can still touch the real user's files:
20
- - `lib/vimamsa/gui_command_line.rb:20`: `HISTORY_FILE = "~/.vimamsa/cmd_history.txt"`.
21
- Change to data dir.
22
- - `lib/vimamsa/buffer.rb:2221`: backups in `~/.vimamsa/backup`. Change to data dir.
23
- `editor.rb:189` already creates `get_dot_path("backup")`, which is a different
24
- directory from the one backups are written to.
25
- - `lib/vimamsa/macro.rb:219`: `save_macro` writes to `~/.config/.vimamsa`, a stray
26
- third directory. Unify it with `NAMED_MACROS_FILE` (`macro.rb:46`). Saved macros are
27
- user content, so they go in the config dir.
28
-
29
- Currently everything else goes through `get_dot_path` → `~/.config/vimamsa`, including
30
- generated state. It should be split as follows:
31
- - Stays in config: `custom.rb`, `settings.rb`, `styles/`, bookmarks, named macros.
32
- - Moves to data: `session.txt`, `buffers.txt` (`buffer_list.rb:5,14`), `backup/`,
33
- `crash/`, `cmd_history.txt`, `dictation_prompts.json`. Also the `listen/` dir and
34
- `ripl_ctrl` (`gui.rb:535`). Those two are runtime files, so `$XDG_RUNTIME_DIR` could
35
- be an option, but `~/.local/share` is fine for now. `exe/vimamsa` uses `listen/`
36
- too, and it must agree with the editor.
37
-
38
- Plan sketch:
39
- 1. Add `vma_data_dir` / `get_data_path(sfx)` beside `vma_user_dir` / `get_dot_path`
40
- (`editor.rb:742-755`). They honor `$XDG_DATA_HOME`, and `--user-dir` overrides both
41
- dirs, so tests stay isolated. Also honor `$XDG_CONFIG_HOME` in `vma_user_dir`.
42
- 2. Route the three hardcoded paths and the data files above through these helpers.
43
- 3. One-time migration at startup: if the old file exists and the new one doesn't, move
44
- it (`~/.vimamsa/{cmd_history.txt,backup/}`, `~/.config/.vimamsa/macro_*`, and data
45
- files from `~/.config/vimamsa`). Log what was moved.
46
- 4. Fix docs that say `~/.vimamsa/...`:
47
- - `README.md:62,158` (custom.rb is actually in `~/.config/vimamsa`)
48
- - `modules/tts/tts.rb:14` and `modules/dictation/dictation.rb:24` ("settings.rb")
49
- - `custom_example.rb`, if it applies
50
- 5. Tests: with `$vma_user_dir` set, no file outside the test dirs is created. Run a test
51
- that exercises history, backup and macro save, and check that `~/.vimamsa` is not
52
- created.
53
- 6. `doc/modules_settings_plan.md` already uses `~/.local/share/vimamsa/venv` for its
54
- shared Python venv. Build it on `get_data_path("venv")`.
11
+ ### Record demos; form input through the key bindings
12
+
13
+ Record a demo like a macro, into the demo step format, by capturing keys in
14
+ `match_key_conf`. First, form fields get a form input mode: GTK widgets as the
15
+ view, a vimamsa `Buffer` per field as the model, and the form window's keys going
16
+ to the key bindings. Then typing in forms (e.g. `, r r`) records and replays too.
17
+ Plan: `doc/demo_recording_plan.md`.
18
+
19
+ ### Faster startup
20
+
21
+ About 0.9 s of a 2.6–3.0 s startup can be saved. The biggest item: the red-colors gem,
22
+ which cairo requires, builds every colormap when loaded (0.6–0.8 s); it can be loaded
23
+ only when it is used. Plan: `doc/startup_speed_plan.md`.
24
+
25
+ ### Easy jump: line-start labels in the gutter
26
+
27
+ Easy jump labels are opaque black boxes with bold red text, drawn over the first
28
+ characters of words and lines (`easy_jump.rb`, `VMAgui#overlay_draw_text`). While
29
+ they're shown, the code under them can't be read: `AA` covers `# E`, `DD` covers `def`
30
+ (seen in the easy jump demo, 2026-11-21).
31
+
32
+ - Draw the line-start labels in the gutter, next to the line numbers, so they cover
33
+ no code.
34
+ - Word-start labels stay in the text. Possibly make them see-through, with brighter
35
+ text.
36
+ - `DemoPlayer#jump_label` and its test look labels up by position
37
+ (`@easy_jump_wsmarks`), so they should still work.
55
38
 
56
39
  ### Descriptive names for key bindings that lack one
57
40
 
58
- Many bindings show raw Ruby code instead of a description in Help ▸ Show key bindings
59
- (`show_key_bindings`, `key_bindings_report.rb`) and in other places that show action
60
- names. Example:
61
-
62
- [C] d F space : buf.delete2(:to_char_backward,' ')
63
-
64
- It should say something like `Delete backward to previous space`.
65
-
66
- Cause: `KeyBindingTree#get_by_keywords` (`key_binding_tree.rb:404-417`) only looks up a
67
- description when the action is a registered **Symbol** (`@actions[sym].method_name`).
68
- Bindings whose action is an eval'd **String** are printed as they are. Counts
69
- (2026-11-19), as `"keys" => "ruby string"` entries:
70
-
71
- | Scheme | String bindings | Symbol bindings |
72
- |---|---|---|
73
- | `key_bindings_vimlike.rb` | 97 | 145 |
74
- | `key_bindings_vim.rb` | 78 | 79 |
75
- | `key_bindings_notepad.rb` | 4 | 9 |
76
-
77
- Some registered symbols also have an empty description, e.g. `:jump_to_random`
78
- (`key_actions.rb:67`) and `:ack_search` (`key_actions.rb:124`, a duplicate of line 151,
79
- which does have one). These print as the bare symbol.
80
-
81
- Other places that show the raw action and would benefit from the same lookup:
82
- - the previous-action label in the toolbar (`gui.rb:829`)
83
- - the key log panel (`gui_keylog_panel.rb:109`)
84
-
85
- Plan sketch:
86
- 1. **One description table keyed by the action string**, shared by all schemes. Many
87
- strings are identical in vim and vimlike, e.g. `buf.delete2(:to_char_backward,' ')`
88
- is in both, so each one is described once. For example, a new
89
- `lib/vimamsa/key_action_descs.rb` (required in `rbvma.rb`):
90
- ```ruby
91
- KEY_ACTION_DESCS = {
92
- "buf.move(FORWARD_CHAR)" => "Move forward one character",
93
- "buf.delete2(:to_char_backward,' ')" => "Delete backward to previous space",
94
- "buf.delete2(:to_char_backward,<char>)" => "Delete backward to previous <char>",
95
- "bufs.close_current_buffer" => "Close current buffer",
96
- ...
97
- }
98
- ```
99
- Templates with `<char>` keep the placeholder in the description.
100
- - Alternative: convert each string action to a `reg_act` symbol with a description.
101
- That's cleaner in the long run (they also become searchable in Search for
102
- Actions), but it touches every binding line in three scheme files, plus user
103
- `custom.rb` files that rebind the same strings. Proposed: the table first.
104
- Convert to symbols opportunistically, and especially convert actions that are
105
- worth finding through Search for Actions.
106
- 2. A helper `action_description(action)`: Symbol → `method_name` (if non-empty);
107
- String → `KEY_ACTION_DESCS[action]`; otherwise the action itself. Use it in
108
- `get_by_keywords`, `gui.rb:829` and the key log panel.
109
- 3. Report format: show the description, with the raw code dimmed after it so power
110
- users still see what runs. For example:
111
- `[C] d F space : Delete backward to previous space ⟨buf.delete2(:to_char_backward,' ')⟩`.
112
- Or show the code only for entries without a description.
113
- 4. Fill in descriptions for all ~180 string bindings and the symbols with empty
114
- descriptions. Remove the duplicate `:ack_search` registration.
115
- 5. Test (`tests/test_key_bindings.rb` or a new one): for each scheme (load it with
116
- `load_scheme_kbd`), every binding resolves to a non-empty description that isn't
117
- the raw action. Print the missing ones, so new bindings without a description fail
118
- the suite.
41
+ Mostly done: every binding now runs a named action (the dotted action ids, see
42
+ "Consistent, hierarchical action names"), and the key bindings page, key log and
43
+ toolbar show its description. Left: seven actions are registered with an empty
44
+ description, so they show as bare ids: `bmark.select`, `bmark.delete`, `bmgr.select`,
45
+ `bmgr.close`, `fexp.select`, `buf.history.prev` and `buf.diff`
46
+ (`grep -rn 'reg_act(.*, "")' lib modules`).
119
47
 
120
48
  ### More Vim bindings: counts after operators, missing operator + motion combinations
121
49
 
@@ -150,16 +78,16 @@ State (2026-11-19):
150
78
  - `d j`, `d k`: missing in both; in vimlike they're commented-out TODOs at
151
79
  `key_bindings_vimlike.rb:222-223`
152
80
  - `d G`, `d g g`; `d }`, `d {`, `y }`; `d %`; `d ^`, `y ^`
153
- - vimlike has no change operator at all (`c`, `C`, `s`, `S` are bound to other
154
- things), so it needs a key decision first. See `doc/vimlike_vim_conflicts.md`.
81
+ - vimlike now has `c w`, `c e`, `c c`, `c $`, `S` from the shared vim table
82
+ (2026-11-20); `C` and `s` stay vimlike's own. See `doc/vimlike_vim_conflicts.md`.
155
83
  3. **Missing motions** (they then also work after operators):
156
84
  - `W` / `E` / `ge` (`B` is commented out in vimlike)
157
85
  - `T x`, and `,` (`;` exists)
158
86
  - `%`, `{` / `}`, `(` / `)`
159
87
  - `H` / `L` (`M` is taken in vimlike), `#`
160
88
  4. **Doubled operators / other count commands**:
161
- - `>>` / `<<` with counts, and Visual `>` / `<` in vimlike
162
- - `ctrl-a` / `ctrl-x` (neither is in vimlike)
89
+ - `>>` / `<<` with counts (Visual `>` / `<` are now in vimlike too)
90
+ - `ctrl-x` (`ctrl-a` is now in vimlike, from the shared vim table)
163
91
  - check that `3 r x`, `3 p` and `J` / `gJ` with counts apply the count correctly
164
92
  5. **Larger, already planned**: line-wise `V`, block `ctrl-v`, `o` / `gv` in Visual
165
93
  mode, named registers (`"a`). See plan steps 4–5.
@@ -250,7 +178,7 @@ every run since, so a fresh install is never tested. Plan:
250
178
  `doc/vm_snapshots_plan.md`.
251
179
  - two VirtualBox snapshots: `clean` (fresh 24.04 + Guest Additions) and
252
180
  `provisioned`
253
- - `run_tests_vm.sh` restores `provisioned` before every run
181
+ - `run_tests_vm.rb` restores `provisioned` before every run
254
182
  - it automatically does a fresh run from `clean` when install inputs change or
255
183
  weekly, and then retakes `provisioned`
256
184
 
@@ -444,10 +372,306 @@ Depends on / ties in with:
444
372
 
445
373
  See `doc/modules_settings_plan.md`.
446
374
 
375
+ ### Consistent, hierarchical action names
376
+
377
+ Action ids are ad hoc. They mix verb-first and noun-first names, use implementation
378
+ prefixes (`gui_`, `vim_`, `e_`, `V_`), contain duplicates (`undo` / `edit_undo`,
379
+ `move_next_line` / `forward_line`, …) and use inconsistent words (forward / next,
380
+ buf / buffer). Plan: `doc/action_names_plan.md`.
381
+ - dotted ids, from general to specific: `move.word.next`, `buf.close`, `sel.copy`
382
+ - an `a` proxy like `cnf`: `bindkey "C w", a.move.word.next`, and `a.buf.save!` runs an action
383
+ - namespaces map onto the key bindings report categories
384
+ - `ACTION_ALIASES` keep the old ids working in `custom.rb` and in saved macros
385
+ - `Action#path` replaces the unused `:group` option
386
+
387
+ ### Tab completes file names on the command line
388
+
389
+ `:!cat /proc/cpu<tab>` should complete to `:!cat /proc/cpuinfo`. Today the command
390
+ line (`lib/vimamsa/gui_command_line.rb`) handles only Escape, Up and Down. Tab
391
+ does nothing useful.
392
+ - Complete the word before the cursor as a path: absolute, `~/…`, or relative to the
393
+ current buffer's directory (or the working directory for unsaved buffers).
394
+ - A single match is completed in place, with `/` added for a directory. Several
395
+ matches complete to their longest common prefix. A second Tab lists them, in the
396
+ message area or a small popup.
397
+ - Works for `:!cmd` and `:e`, and anywhere a word looks like a path. Escape spaces,
398
+ or quote the path, as the shell needs.
399
+ - Later: complete command names after `:!` from `$PATH`, and action ids after
400
+ `:a.` (`doc/action_names_plan.md`).
401
+ - Test: in a temp directory with `foo_one`, `foo_two` and `bar/`, `:e ba<tab>` gives
402
+ `bar/`, and `:e fo<tab>` gives `foo_`.
403
+
404
+ ### Keymap syntax that isn't Ruby code (`map` strings and keymap files)
405
+
406
+ Declare keymaps in a plain text format, one binding per line, instead of Ruby hashes:
407
+
408
+ ```
409
+ # today (key_bindings_vimlike.rb)
410
+ "C z " => "mode.browse",
411
+
412
+ # keymap file
413
+ C z mode.browse
414
+ VC l move.char.next
415
+ C d <num> e edit.delete.word_end
416
+ ```
417
+
418
+ The last token is the action id; everything before it is the mode and the keys, in
419
+ the notation used today. This depends on the dotted ids from
420
+ `doc/action_names_plan.md`: an id always contains a `.`, so it can't be mistaken for
421
+ a key name.
422
+ - The same syntax works in two places:
423
+ - **In Ruby, as a multiline string passed to `map`**, so it can sit in the scheme
424
+ files, in modules and in `custom.rb`:
425
+
426
+ ```ruby
427
+ map <<~KEYS
428
+ [motion]
429
+ VC h move.char.prev
430
+ VC l move.char.next
431
+ C z mode.browse
432
+ KEYS
433
+ ```
434
+ - **In separate files** (optional), such as `keymaps/vimlike.keys`, or a user file in
435
+ the config dir that is loaded after the scheme. This lets users rebind keys without
436
+ writing Ruby. Loading a file is just `map(File.read(path))`, with the file name
437
+ used in error messages.
438
+ - Lines starting with `#` are comments. A section line such as `[motion]` sets the
439
+ category for the lines below it (`doc/key_bindings_report_plan.md`).
440
+ - Conditions (today `I tab(vma.buf.view.autocp_active)`) become named conditions
441
+ defined in Ruby: `I tab edit.complete.next when completion_open`.
442
+ - Key sets for operators and motions (`doc/vim_compatibility_plan.md`, step 1) need a
443
+ block syntax, e.g. `set op` … `end`, plus template lines like `C <op> <motion>
444
+ operator.motion`.
445
+ - No Ruby code in the keymap syntax. The Ruby-string bindings get named actions first (the
446
+ "Descriptive names for key bindings" item).
447
+ - The parser reports errors with file and line: an unknown action, an unknown key
448
+ name, a mode that doesn't exist. For a `map` string, the line is the calling
449
+ file's line plus the offset inside the string (`caller_locations`).
450
+ - Parse into the same `add_keys` / `bindkey` calls, so the tree, the conflict
451
+ report and the tests don't change. A test checks that the `map` version of a
452
+ scheme gives the same tree as the `add_keys` hashes it replaces.
453
+
454
+ ### Git functions as a separate module
455
+
456
+ Move the git features into `modules/git/`: "Show git diff" of the current file
457
+ (`buf.diff.git`, `git_diff_buffer`) and of the whole repo (`file.diff.repo`, `git_diff_w`).
458
+ Both are in `lib/vimamsa/diff_buffer.rb` today.
459
+
460
+ Stays in core:
461
+ - the diff view: the `diffview` minor mode, `DiffLineMapper`, jump to source, and the
462
+ unsaved-changes diff (`buf.diff`, which uses plain `diff`)
463
+ - project-root detection by a `.git` directory (`editor.rb:823`). It only looks for a
464
+ marker and doesn't run git.
465
+
466
+ Changes needed in the module interface (checked 2026-11-20):
467
+ - **Default on.** Modules are off unless `cnf.modules.<name>.enabled` is set. Only
468
+ `color_highlight` gets a default, hardcoded in core (`conf.rb:165`). Git diff is an
469
+ existing feature, so add `default_enabled: true` to `_info` and drop the hardcoded
470
+ default.
471
+ - **Menu entries anywhere.** `gui_menu.rb:57-58` hardcodes the git items under
472
+ Actions ▸ experimental. Modules can only add items to the top-level Modules menu
473
+ (`add_module_action`). Let a module add items to any menu path, and remove them in
474
+ `<name>_disable`.
475
+ - **Core code that knows about git.** `Buffer#git_root` and `resolve_diff_path`, which
476
+ runs `git rev-parse` itself, are git-specific. Replace them with a generic
477
+ `diff_base_dir` (the directory that relative `a/` and `b/` paths in a diff are
478
+ relative to). The module sets it when it creates the diff buffer.
479
+ - **A public diff view API.** The module has to open a diff buffer in diff view
480
+ without copying core code. Something like `open_diff_buffer(text, name, base_dir:)`,
481
+ which does what `create_new_buffer` + `gui_set_file_lang("diff")` + `diffview` do
482
+ today.
483
+ - **Actions of a disabled module.** Today they give "Unknown action". Instead, say
484
+ "enable the git module (Settings ▸ Modules)". For this, `_info` lists the module's
485
+ action ids (`actions: ["git.diff.buf", "git.diff.repo"]`). This also lets the
486
+ `ACTION_ALIASES` entries (`git_diff_buffer` → …) point to module actions. The alias
487
+ test then allows an alias whose target belongs to a module.
488
+ - **Requirements.** The `git` executable, through the `requirements:` key from
489
+ `doc/modules_settings_plan.md`. Check it with `which git`.
490
+ - **Tests.** `tests/test_diff_buffer_name.rb` calls `git_diff_buffer` directly. Add a
491
+ test helper that loads and initializes a module for one test (`with_module(:git)`),
492
+ so module tests don't depend on the user's settings.
493
+
494
+ Renames (with aliases): `buf.diff.git` → `git.diff.buf`, `file.diff.repo` →
495
+ `git.diff.repo`. Later candidates for the module: blame, log of the current file,
496
+ stage the current file.
497
+
498
+ ### Open links in Markdown files, as with hpt `⟦…⟧` links
499
+
500
+ Enter (`handle_line_action`) on a link in a `.md` file should open it, as it does
501
+ for hyperplaintext links `⟦file⟧`. For example `[vimlike_vim_conflicts.md]` or
502
+ `[the report](vimlike_vim_conflicts.md)` in `doc/vim_compatibility_plan.md`.
503
+
504
+ Why it fails today (`Buffer#get_cur_nonwhitespace_word`, `buffer.rb:1514`):
505
+ - The word under the cursor is cut at white space, so it keeps the brackets:
506
+ `[vimlike_vim_conflicts.md](vimlike_vim_conflicts.md)`. That's not an existing
507
+ file, a URL, a `file:line` pointer or a `⟦…⟧` link.
508
+ - A relative path resolves against `bufs.last_dir`, not the directory of the file
509
+ that contains the link. `hpt_check_cur_word` does use the buffer's directory.
510
+ - In `[link text](target)`, the cursor is often on the link text, which may contain
511
+ spaces, so the target isn't in the "word" at all.
512
+
513
+ To do:
514
+ - Recognize the Markdown link forms around the cursor on the current line (not by
515
+ white-space word):
516
+ - `[text](target)` and `[text](target "title")`, with the cursor anywhere on it
517
+ - `<https://…>` autolinks
518
+ - `[text][ref]` and `[ref]` with a `[ref]: target` definition in the file
519
+ - a bracketed file name `[name.md]` that exists next to the file, as in the
520
+ example above
521
+ - Resolve relative targets against the file's directory, like `hpt_check_cur_word`.
522
+ - `target#anchor`: open the file and jump to the heading whose GitHub-style slug
523
+ matches.
524
+ - Then dispatch as now: text file → open it, URL → browser, other file →
525
+ default program (`handle_word`). Also offer it in the context menu.
526
+ - Maybe share this with `file_path_at` (`buffer.rb:1561`), which already strips
527
+ surrounding brackets and punctuation for the hover/open-file check.
528
+ - Tests: Enter on each form in a temp `.md` file opens the right file and line.
529
+
530
+ ### WYSIWYG editing: rich text with hidden markup
531
+
532
+ Bold, italic and font size shown as formatting, with the markup hidden in the file
533
+ and shown only on request ("Show markup"). The buffer holds only the visible text,
534
+ the formatting is a separate span model mirrored to GtkTextView tags, and the hpt
535
+ markers are the file format. Plan: `doc/wysiwyg_plan.md`.
536
+
537
+ ### Changesets as the change format
538
+
539
+ Replace the `[pos, op, len, text]` delta arrays with OT-style changesets (`retain` /
540
+ `delete` / `insert`, with optional attributes), as in CodeMirror and Quill. They give
541
+ one `map_pos` for every position-based structure, composed undo groups, formatting
542
+ changes for WYSIWYG, and later `transform` for multiple cursors. Decided 2026-11-21.
543
+ Plan: `doc/delta_syntax_plan.md`.
544
+
545
+ ### Performance: line ends and UTF-8 indexing in large files
546
+
547
+ Measured 2026-11-21 in plain Ruby 3.4, ~55-character lines. Fixed already:
548
+ `scan_indexes` (O(n^2) on non-ASCII text: 13 s → about 0.1 s for 5.5 MB) and
549
+ `get_line_end` (`select` → `bsearch`). See DONE.
550
+
551
+ Still open:
552
+ - **`update_line_ends` shifted every later line end on each edit.** Done: `@line_ends`
553
+ is now a treap of lines (`LineTree`, see DONE and `doc/line_tree_plan.md`).
554
+ Follow-up: loops over all lines (`fold.rb`'s fold search) call `[i]` per line,
555
+ which is now O(log n) each. Walk the tree in order there if it shows up in
556
+ profiles.
557
+ - **UTF-8 character indexing.** Ruby strings have no character index. Once a buffer
558
+ contains one non-ASCII character, every `self[pos]`, `insert` and `slice!` scans from
559
+ the start. That's 0.5 ms each at 5.5 MB, versus 0.002 ms for ASCII-only text. Motions
560
+ and syntax checks make many such calls per keystroke.
561
+ - First profile typing and moving around in a large non-ASCII file in the real editor
562
+ (`perf`, or `ruby-prof`) to see whether this dominates.
563
+ - If it does, the options are:
564
+ - a checkpoint index: character → byte offset every ~4 KB, updated through a
565
+ Fenwick tree, used for `byteslice` access
566
+ - a rope: a balanced tree of chunks with character counts per node. This changes
567
+ the `Buffer < String` model, so it's a last resort.
568
+ - The GTK side needs nothing: `GtkTextBuffer` is already a B-tree.
569
+
570
+ ### Replace complicated shell scripts with Ruby scripts
571
+
572
+ The longer scripts have outgrown bash: env-var parsing, error handling, quoting,
573
+ retries and many steps. Port them to Ruby. Ruby is already the project language,
574
+ so testing and sharing helpers between scripts gets easier.
575
+
576
+ Candidates (lines as of 2026-11-20):
577
+ - ~~`run_tests_vm.sh` (130): host side~~: done, now `run_tests_vm.rb` (see DONE).
578
+ - `vm_guest_run.sh` (120): guest side; provisioning, gem build, test run
579
+ - `scripts/appimage/build_in_container.sh` (192): the AppImage build
580
+
581
+ Keep as shell:
582
+ - small wrappers: `run_e2e_vm.sh`, `scripts/appimage/build.sh`,
583
+ `scripts/appimage/smoke_test.sh`, `install.sh`, `docker_cmd.sh`
584
+
585
+ Constraints:
586
+ - **Bootstrap without Ruby.** A clean VM (the `clean` snapshot) has no Ruby, and
587
+ `vm_guest_run.sh` is what installs it (`apt-get install ruby ruby-dev …`). So
588
+ keep a few lines of shell that install Ruby if it's missing and then `exec`
589
+ the `.rb` script.
590
+ - Same for the AppImage container: the Dockerfile installs no system Ruby, and the
591
+ script builds the bundled Ruby itself. Either add `ruby` to the Dockerfile for the
592
+ build script only (it must not leak into the AppDir), or keep the steps before
593
+ the Ruby build in shell.
594
+ - Use only the standard library (`open3`, `fileutils`, `optparse`); no gems,
595
+ because they aren't installed yet when the script runs.
596
+ - Keep the same interface: env vars (`VM_NAME`, `VM_USER`, `VM_PASS`, `VM_DISPLAY`,
597
+ `FORCE_PROVISION`, `VMA_TEST_ARGS`, `VMA_REF`, `RUBY_VERSION`), the arguments, and the exit codes
598
+ (the suite's 0/1, 2 for missing variables). Never print `VM_PASS`.
599
+ - Shared helpers (run a command and echo `>>` steps, fail with a message) go in
600
+ `scripts/lib/`.
601
+ - Update the references in `CLAUDE.md`, `doc/vm_snapshots_plan.md` and
602
+ `doc/bundling_plan.md`.
603
+ - Check each port with a full VM run (`run_tests_vm.rb`) or an AppImage build plus its smoke test.
604
+
447
605
  ## DONE
448
606
 
449
607
  Format: `- **Item title** (2026-MM-DD, `abc1234`[..`def5678`]): one or two lines on what was changed.`
450
608
 
609
+ - **Demo playback: no user input while running; restart after edits** (2026-11-22,
610
+ `5254114`): while a demo plays, the user's keys and clicks/drags in the text are
611
+ ignored (`DemoPlayer.blocks_input?`, checked in `gui.rb` and `gui_sourceview.rb`), with a
612
+ message to pause it. Paused, the editor can be used; if the text, cursor, mode or
613
+ current buffer changed, continuing starts the demo from the beginning. Tests in
614
+ `tests/test_demo_player.rb`.
615
+
616
+ - **XDG dirs instead of `~/.vimamsa`** (2026-11-22, uncommitted): generated files
617
+ (session, buffer list, command and file history, file index, recorded macros,
618
+ backups, crash reports, listen dir) go in `~/.local/share/vimamsa`; config stays in
619
+ `~/.config/vimamsa` (`$XDG_DATA_HOME` / `$XDG_CONFIG_HOME` honored). `--user-dir`
620
+ keeps both in one dir. The old files move once at start (`user_dirs.rb`). Tests in
621
+ `tests/test_user_dirs.rb`, one of which fails on any fixed `~/.vimamsa` path.
622
+
623
+ - **Introduction page for first-time users** (2026-11-21, `6448bb9`): shown on
624
+ the first start, from Help ▸ Introduction, with `:intro` or with `--intro`. It has
625
+ inline buttons that start the demos, key names taken from the bindings, and a
626
+ one-screen "Vimamsa for Vim users" page, plus a demo dropdown above the key log.
627
+ `doc/intro_page_plan.md`.
628
+
629
+ - **Switching files demo** (2026-11-21, `9399229`): Help ▸ Demos ▸ Switching files
630
+ (`scripts/demo/demo_files_steps.txt`, on shapes.rb, report.rb and notes.txt): tab,
631
+ browse mode h / l, and the file explorer (`, f`, then k / j and l). Demos can have
632
+ several files, and a demo folder of their own.
633
+ - **Easy jump label feedback** (2026-11-21, `2125c34`): after the first key, matching
634
+ labels show it bright yellow and bold, and the others are dimmed. The chosen label
635
+ stays 0.15 s after the others go. `cnf.easy_jump.glow` (off: without a GPU it made
636
+ easy jump about 60% slower). Tests in `tests/test_easy_jump.rb`.
637
+ - **Key hint below the row** (2026-11-21, `fef2d63`): `cnf.key_hint.y_offset` px
638
+ below the cursor's row (above it if no room), right of the text it covers.
639
+
640
+ - **Demo player: loop, pause, speed, demos menu** (2026-11-21, `19e528c`): Help ▸
641
+ Demos ▸ Basic editing / Easy jump (`scripts/demo/demo_easyjump_steps.txt`: moves
642
+ `to_s` with v + easy jump, x, P). A demo loops, with the file restored, until
643
+ stopped. Buttons above the key log (Pause/Continue, −, +), ✕ closes the key log
644
+ (stopping the demo); actions `help.demo.pause` / `.faster` / `.slower` / `.stop` /
645
+ `.easyjump`. Tests in `tests/test_demo_player.rb`.
646
+ - **Key hint next to the cursor** (2026-11-21, `19e528c`): while the key log is
647
+ shown, a see-through bubble with a dashed border, right of the end of the cursor's
648
+ line, shows the current mode (badge colors), the last key and action, then fades
649
+ (`gui_key_hint.rb`). The key log is cleared at the start of each demo round. Easy
650
+ jump labels are logged too (`log_jump_label`). Tests in `tests/test_keylog_panel.rb`.
651
+
652
+ - **`run_tests_vm.sh` ported to Ruby** (2026-11-21, `ac4251a`): `run_tests_vm.rb`, same env
653
+ vars, arguments, steps and exit codes, standard library only; shared helpers in
654
+ `scripts/lib/script_helpers.rb`. `run_e2e_vm.sh` and the docs point to it.
655
+
656
+ - **Resized window after maximize restored** (2026-11-21, `36c04d3`): GNOME's auto-maximize
657
+ maximized a restored window that covers most of the screen, which was then saved
658
+ as maximized. `VMAgui#undo_auto_maximize` unmaximizes it to the saved size.
659
+ Test: `test_resized_after_maximize_restored` in `tests/test_window_layout.rb`.
660
+
661
+ - **Line ends in a treap** (2026-11-21, `96234a8`): `@line_ends` is a
662
+ `LineTree` (`lib/vimamsa/line_tree.rb`), an implicit treap with one node per line
663
+ (length, random priority, subtree line and character counts). It answers the Array
664
+ methods the code used (`size`, `[i]`, `bsearch_index`, `bsearch`), so no call site
665
+ changed. An edit costs about 0.005 ms at 100k lines, down from 6.3 ms, and lookups
666
+ about 0.004 ms. Plan: `doc/line_tree_plan.md`. Tests: `tests/test_line_tree.rb`.
667
+
668
+ - **Fast line ends for non-ASCII text** (2026-11-21, `57d3030`): `scan_indexes`
669
+ (`string_util.rb`) counts characters only between consecutive matches, using byte
670
+ offsets, instead of calling `MatchData#begin`, which counts from the start of the
671
+ file each time. Loading the line ends of a 5.5 MB file with one non-ASCII character
672
+ went from 13 s to about 0.1 s. `get_line_end` uses `bsearch` instead of `select`.
673
+ Tests: `tests/test_line_ends.rb`.
674
+
451
675
  - **Restore window geometry and view layout on startup** (2026-11-18, `99cd484`): window
452
676
  size/maximized, file/func/keylog panels with widths, two-column split and file, and
453
677
  minibuffer history height are saved per screen resolution (last 5) in the data dir