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.
- checksums.yaml +4 -4
- data/.github/workflows/appimage.yml +17 -10
- data/Dockerfile +2 -2
- data/README.md +162 -90
- data/custom_example.rb +33 -15
- data/doc/TODO.md +334 -110
- data/doc/action_names_plan.md +442 -0
- data/doc/bundling_plan.md +2 -1
- 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 +45 -0
- data/doc/line_tree_plan.md +89 -0
- data/doc/missing_vim_bindings.md +34 -44
- data/doc/modules_settings_plan.md +1 -1
- data/doc/registries_plan.md +202 -0
- data/doc/startup_speed_plan.md +97 -0
- data/doc/test_commands.md +232 -0
- data/doc/treap_visualizer.html +585 -0
- data/doc/vim_compatibility_plan.md +186 -31
- data/doc/vimlike_vim_conflicts.md +236 -228
- data/doc/vm_snapshots_plan.md +4 -4
- data/doc/wysiwyg_plan.md +231 -0
- data/docker_cmd.sh +1 -1
- data/exe/run_tests.rb +85 -3
- data/exe/vimamsa +49 -6
- data/help/intro.txt +30 -0
- data/help/vim_intro.txt +31 -0
- data/img/demo.gif +0 -0
- data/img/demo.mp4 +0 -0
- data/lang/hyperplaintext.lang +1 -1
- data/lib/vimamsa/ack.rb +2 -0
- data/lib/vimamsa/actions.rb +381 -36
- data/lib/vimamsa/bookmarks.rb +8 -8
- data/lib/vimamsa/buffer.rb +84 -38
- data/lib/vimamsa/buffer_changetext.rb +58 -36
- data/lib/vimamsa/buffer_list.rb +2 -2
- data/lib/vimamsa/buffer_manager.rb +6 -6
- data/lib/vimamsa/cli_help.rb +75 -0
- data/lib/vimamsa/clipboard.rb +6 -3
- data/lib/vimamsa/conf.rb +9 -0
- data/lib/vimamsa/crash_handler.rb +2 -2
- data/lib/vimamsa/debug.rb +2 -2
- data/lib/vimamsa/demo_player.rb +494 -0
- data/lib/vimamsa/demo_recorder.rb +277 -0
- data/lib/vimamsa/diff_buffer.rb +1 -1
- data/lib/vimamsa/dot_repeat.rb +104 -0
- data/lib/vimamsa/easy_jump.rb +54 -3
- data/lib/vimamsa/editor.rb +136 -65
- data/lib/vimamsa/file_history.rb +1 -1
- data/lib/vimamsa/file_manager.rb +23 -23
- data/lib/vimamsa/form_input.rb +388 -0
- data/lib/vimamsa/gui.rb +89 -13
- data/lib/vimamsa/gui_command_line.rb +44 -5
- data/lib/vimamsa/gui_form_generator.rb +17 -6
- data/lib/vimamsa/gui_func_panel.rb +1 -1
- data/lib/vimamsa/gui_key_hint.rb +165 -0
- data/lib/vimamsa/gui_keylog_panel.rb +164 -2
- data/lib/vimamsa/gui_menu.rb +69 -50
- data/lib/vimamsa/gui_select_window.rb +77 -43
- data/lib/vimamsa/gui_settings.rb +9 -5
- data/lib/vimamsa/gui_sourceview.rb +28 -81
- data/lib/vimamsa/gui_theme.rb +11 -2
- data/lib/vimamsa/hook.rb +2 -0
- data/lib/vimamsa/intro_page.rb +367 -0
- data/lib/vimamsa/key_actions.rb +315 -225
- data/lib/vimamsa/key_binding_tree.rb +228 -61
- data/lib/vimamsa/key_bindings_notepad.rb +18 -16
- data/lib/vimamsa/key_bindings_report.rb +290 -67
- data/lib/vimamsa/key_bindings_vim.rb +43 -297
- data/lib/vimamsa/key_bindings_vim_core.rb +356 -0
- data/lib/vimamsa/key_bindings_vimlike.rb +347 -339
- data/lib/vimamsa/key_names.rb +80 -0
- data/lib/vimamsa/langservp.rb +62 -7
- data/lib/vimamsa/line_tree.rb +367 -0
- data/lib/vimamsa/macro.rb +20 -3
- data/lib/vimamsa/rbvma.rb +15 -0
- data/lib/vimamsa/registers.rb +125 -0
- data/lib/vimamsa/run_ruby.rb +64 -0
- data/lib/vimamsa/search_replace.rb +4 -4
- data/lib/vimamsa/string_util.rb +17 -3
- data/lib/vimamsa/tests.rb +8 -8
- data/lib/vimamsa/text_objects.rb +11 -54
- data/lib/vimamsa/text_transforms.rb +4 -0
- data/lib/vimamsa/tmp_user_dir.rb +39 -0
- data/lib/vimamsa/user_dirs.rb +83 -0
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa/vim_operators.rb +365 -0
- data/modules/calculator/calculator.rb +5 -5
- data/modules/color_highlight/color_highlight.rb +3 -3
- data/modules/dictation/dictation.rb +32 -32
- data/modules/ollama/ollama.rb +5 -5
- data/modules/terminal/terminal.rb +5 -5
- data/modules/tts/tts.rb +10 -10
- data/run_e2e_vm.sh +3 -3
- data/run_tests_vm.rb +163 -0
- data/scripts/appimage/AppRun +7 -0
- data/scripts/appimage/build_in_container.sh +11 -1
- data/scripts/appimage/smoke_test.sh +1 -1
- data/scripts/demo/demo_easyjump_steps.txt +60 -0
- data/scripts/demo/demo_files_steps.txt +52 -0
- data/scripts/demo/demo_steps.txt +9 -1
- data/scripts/demo/notes.txt +6 -0
- data/scripts/demo/record_demo.rb +60 -81
- data/scripts/demo/report.rb +7 -0
- data/scripts/demo/shapes.rb +1 -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/tests/test_action_ids.rb +232 -0
- data/tests/test_auto_format.rb +2 -2
- data/tests/test_autocomplete.rb +1 -1
- data/tests/test_basic_editing.rb +18 -18
- data/tests/test_bookmarks.rb +6 -6
- data/tests/test_bracket_match.rb +3 -0
- data/tests/test_cli_help.rb +64 -0
- data/tests/test_color_highlight.rb +2 -2
- data/tests/test_command_line.rb +1 -1
- data/tests/test_context_menu_file.rb +18 -0
- data/tests/test_copy_paste.rb +33 -33
- data/tests/test_custom_two_phase.rb +1 -1
- data/tests/test_demo_player.rb +355 -0
- data/tests/test_demo_recorder.rb +202 -0
- data/tests/test_dictation.rb +16 -16
- data/tests/test_dot_repeat.rb +88 -0
- data/tests/test_easy_jump.rb +93 -0
- data/tests/test_extract_file_links.rb +3 -3
- data/tests/test_file_panel.rb +2 -2
- data/tests/test_flash.rb +1 -1
- data/tests/test_fold.rb +1 -1
- data/tests/test_form_input.rb +203 -0
- data/tests/test_func_panel.rb +2 -2
- data/tests/test_gtk_sync.rb +7 -7
- data/tests/test_intro_page.rb +437 -0
- data/tests/test_key_categories.rb +163 -0
- data/tests/test_keylog_panel.rb +163 -3
- data/tests/test_line_ends.rb +51 -0
- data/tests/test_line_tree.rb +86 -0
- data/tests/test_lsp_clangd.rb +2 -2
- data/tests/test_lsp_root.rb +43 -0
- data/tests/test_macro.rb +2 -2
- data/tests/test_module_interface.rb +9 -9
- data/tests/test_notepad_bindings.rb +5 -5
- data/tests/test_perf_startup.rb +28 -0
- data/tests/test_random_edit.rb +27 -27
- data/tests/test_registers.rb +131 -0
- data/tests/test_run_ruby.rb +77 -0
- data/tests/test_startup_file.rb +45 -4
- data/tests/test_text_objects.rb +1 -1
- data/tests/test_text_transforms.rb +12 -0
- data/tests/test_tmp_user_dir.rb +79 -0
- data/tests/test_tts.rb +10 -10
- data/tests/test_undo.rb +34 -34
- data/tests/test_user_dirs.rb +122 -0
- data/tests/test_vim_bindings.rb +107 -6
- data/tests/test_vim_conflicts.rb +41 -4
- data/tests/test_vim_operators.rb +116 -0
- data/tests/test_window_layout.rb +83 -0
- data/vimamsa.gemspec +1 -1
- data/vm_guest_run.sh +75 -28
- metadata +60 -4
- data/run_tests.rb +0 -89
- data/run_tests_vm.sh +0 -130
data/lib/vimamsa/actions.rb
CHANGED
|
@@ -9,13 +9,308 @@ class Action
|
|
|
9
9
|
@method = method
|
|
10
10
|
@opt = opt
|
|
11
11
|
end
|
|
12
|
+
|
|
13
|
+
# Segments of the id, general to specific: "move.word.next" =>
|
|
14
|
+
# ["move", "word", "next"]. An old symbol id is one segment.
|
|
15
|
+
def path
|
|
16
|
+
@id.to_s.split(".")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Action ids are dotted paths, "move.word.next", from general to specific
|
|
21
|
+
# (doc/action_names_plan.md). Older ids are symbols (:close_current_buffer).
|
|
22
|
+
ACTION_ID_RE = /\A[a-z][a-z0-9_]*(\.[a-z0-9_]+)+\z/
|
|
23
|
+
|
|
24
|
+
# Old id => new dotted id. ActionList, bindkey, unbindkey and macros resolve
|
|
25
|
+
# these, so users' custom.rb and saved macros keep working. Keep each alias
|
|
26
|
+
# for at least two releases.
|
|
27
|
+
ACTION_ALIASES = {
|
|
28
|
+
# Duplicates merged (2026-11-20)
|
|
29
|
+
undo: "undo.last", edit_undo: "undo.last",
|
|
30
|
+
redo: "undo.redo", edit_redo: "undo.redo",
|
|
31
|
+
jump_last_edit: "jump.edit.prev", jump_to_last_edit: "jump.edit.prev",
|
|
32
|
+
move_backward_char: "move.char.prev", e_move_backward_char: "move.char.prev",
|
|
33
|
+
e_move_forward_char: "move.char.next",
|
|
34
|
+
move_next_line: "move.line.next", forward_line: "move.line.next",
|
|
35
|
+
move_prev_line: "move.line.prev", backward_line: "move.line.prev",
|
|
36
|
+
grep_buffer: "grep.buf", invoke_grep_search: "grep.buf",
|
|
37
|
+
# app namespace (2026-11-20)
|
|
38
|
+
quit: "app.quit",
|
|
39
|
+
restart_editor: "app.restart",
|
|
40
|
+
show_settings: "app.settings",
|
|
41
|
+
reload_customrb: "app.customrb.reload",
|
|
42
|
+
edit_customrb: "app.customrb.edit",
|
|
43
|
+
install_demo_files: "app.demo",
|
|
44
|
+
# mode namespace (2026-11-20)
|
|
45
|
+
insert_mode: "mode.insert",
|
|
46
|
+
start_visual_mode: "mode.visual",
|
|
47
|
+
prev_mode: "mode.prev",
|
|
48
|
+
start_cmd_line: "mode.cmdline",
|
|
49
|
+
notepad_escape: "mode.notepad.escape",
|
|
50
|
+
start_browse_mode: "mode.browse",
|
|
51
|
+
exit_browse_mode: "mode.browse.exit",
|
|
52
|
+
toggle_kbd_passthrough: "mode.passthrough.toggle",
|
|
53
|
+
minibuffer_end: "mode.minibuffer.end",
|
|
54
|
+
# help namespace (2026-11-20)
|
|
55
|
+
show_key_bindings: "help.keys",
|
|
56
|
+
show_free_key_bindings: "help.keys.free",
|
|
57
|
+
show_vim_binding_conflicts: "help.vim_conflicts",
|
|
58
|
+
show_message_history: "help.messages",
|
|
59
|
+
# debug namespace (2026-11-20)
|
|
60
|
+
enable_debug: "debug.on",
|
|
61
|
+
disable_debug: "debug.off",
|
|
62
|
+
savedebug: "debug.save",
|
|
63
|
+
eval_buf: "debug.eval.buf",
|
|
64
|
+
experimental_eval: "debug.eval.sel",
|
|
65
|
+
command_to_buf: "debug.command",
|
|
66
|
+
debug_buf_hex: "debug.buf.sha256",
|
|
67
|
+
print_buffer_access_list: "debug.buf.access",
|
|
68
|
+
run_tests: "debug.tests",
|
|
69
|
+
kbd_dump_state: "debug.kbd",
|
|
70
|
+
# move namespace (2026-11-20)
|
|
71
|
+
jump_beginning_of_line: "move.line.start",
|
|
72
|
+
jump_end_of_line: "move.line.end",
|
|
73
|
+
jump_next_word_start: "move.word.next",
|
|
74
|
+
jump_prev_word_start: "move.word.prev",
|
|
75
|
+
jump_next_word_end: "move.word.end",
|
|
76
|
+
jump_start_of_buffer: "move.buf.start",
|
|
77
|
+
jump_to_start_of_buffer: "move.buf.start",
|
|
78
|
+
jump_end_of_buffer: "move.buf.end",
|
|
79
|
+
jump_to_end_of_buffer: "move.buf.end",
|
|
80
|
+
jump_to_random: "move.random",
|
|
81
|
+
page_down: "move.page.next",
|
|
82
|
+
page_up: "move.page.prev",
|
|
83
|
+
# jump namespace (2026-11-20)
|
|
84
|
+
jump_to_next_edit: "jump.edit.next",
|
|
85
|
+
easy_jump: "jump.easy",
|
|
86
|
+
open_file_under_cursor: "jump.file",
|
|
87
|
+
line_action: "jump.line",
|
|
88
|
+
# search namespace (2026-11-20)
|
|
89
|
+
find_in_buffer: "search.buf",
|
|
90
|
+
find_next: "search.next",
|
|
91
|
+
gui_search_replace: "search.replace",
|
|
92
|
+
invoke_replace: "search.replace.cmd",
|
|
93
|
+
search_actions: "search.actions",
|
|
94
|
+
# grep namespace (2026-11-20)
|
|
95
|
+
grep_refresh: "grep.refresh",
|
|
96
|
+
ack_search: "ack.search",
|
|
97
|
+
content_search: "grep.files",
|
|
98
|
+
# edit namespace (2026-11-20)
|
|
99
|
+
delete_char_forward: "edit.delete.char",
|
|
100
|
+
vim_delete_char: "edit.delete.char.inline",
|
|
101
|
+
vim_delete_char_backward: "edit.delete.char.prev",
|
|
102
|
+
vim_delete_to_eol: "edit.delete.eol",
|
|
103
|
+
delete_to_word_end: "edit.delete.word.end",
|
|
104
|
+
delete_to_next_word_start: "edit.delete.word.next",
|
|
105
|
+
delete_to_line_start: "edit.delete.line.start",
|
|
106
|
+
delete_line: "edit.delete.line",
|
|
107
|
+
insert_backspace: "edit.backspace",
|
|
108
|
+
insert_delete: "edit.delete.char_or_sel",
|
|
109
|
+
vim_change_line: "edit.change.line",
|
|
110
|
+
vim_change_word: "edit.change.word",
|
|
111
|
+
vim_change_to_eol: "edit.change.eol",
|
|
112
|
+
vim_substitute_char: "edit.change.char",
|
|
113
|
+
vim_open_line_above: "edit.line.above",
|
|
114
|
+
insert_new_line: "edit.newline",
|
|
115
|
+
copy_cur_line: "edit.line.copy",
|
|
116
|
+
paste_after_cursor: "edit.paste.after",
|
|
117
|
+
paste_before_cursor: "edit.paste.before",
|
|
118
|
+
paste_over_after: "edit.paste.over.after",
|
|
119
|
+
paste_over_before: "edit.paste.over.before",
|
|
120
|
+
increment_word: "edit.word.increment",
|
|
121
|
+
auto_indent_buffer: "edit.indent.buf",
|
|
122
|
+
comment_selection: "edit.comment",
|
|
123
|
+
autocp_manual_trigger: "edit.complete",
|
|
124
|
+
toggle_autocomplete: "edit.complete.toggle",
|
|
125
|
+
# undo namespace (2026-11-20)
|
|
126
|
+
vim_repeat_last_action: "undo.repeat",
|
|
127
|
+
# case namespace (2026-11-20)
|
|
128
|
+
word_upcase: "case.word.upper",
|
|
129
|
+
word_downcase: "case.word.lower",
|
|
130
|
+
word_swapcase: "case.word.swap",
|
|
131
|
+
line_upcase: "case.line.upper",
|
|
132
|
+
line_downcase: "case.line.lower",
|
|
133
|
+
line_swapcase: "case.line.swap",
|
|
134
|
+
selection_upcase: "case.sel.upper",
|
|
135
|
+
selection_downcase: "case.sel.lower",
|
|
136
|
+
selection_swapcase: "case.sel.swap",
|
|
137
|
+
selection_capitalize: "case.sel.capitalize",
|
|
138
|
+
vim_toggle_case: "case.char.toggle",
|
|
139
|
+
# sel namespace (2026-11-20)
|
|
140
|
+
select_all: "sel.all",
|
|
141
|
+
insert_select_up: "sel.line.prev",
|
|
142
|
+
insert_select_down: "sel.line.next",
|
|
143
|
+
copy_selection: "sel.copy",
|
|
144
|
+
cut_selection: "sel.cut",
|
|
145
|
+
vim_change_selection: "sel.change",
|
|
146
|
+
selection_reverse: "sel.reverse",
|
|
147
|
+
selection_remove_indent: "sel.unindent",
|
|
148
|
+
selection_remove_common_indent: "sel.unindent.common",
|
|
149
|
+
V_join_lines: "sel.join",
|
|
150
|
+
V_to_latex_itemize: "sel.latex_itemize",
|
|
151
|
+
delete_selection: "sel.delete",
|
|
152
|
+
delete_append_selection: "sel.delete.append",
|
|
153
|
+
# buf namespace (2026-11-20)
|
|
154
|
+
buf_save: "buf.save",
|
|
155
|
+
buf_save_as: "buf.save.as",
|
|
156
|
+
buf_revert: "buf.revert",
|
|
157
|
+
buf_backup: "buf.backup",
|
|
158
|
+
backup_all_buffers: "buf.backup.all",
|
|
159
|
+
buf_new: "buf.new",
|
|
160
|
+
create_new_file: "buf.new",
|
|
161
|
+
close_current_buffer: "buf.close",
|
|
162
|
+
gui_select_buffer: "buf.switcher",
|
|
163
|
+
start_buf_manager: "buf.manager",
|
|
164
|
+
history_switch_backwards: "buf.history.prev",
|
|
165
|
+
history_switch_forwards: "buf.history.next",
|
|
166
|
+
select_buffer_language: "buf.language",
|
|
167
|
+
encrypt_file: "buf.encrypt",
|
|
168
|
+
set_unencrypted: "buf.encrypt.off",
|
|
169
|
+
git_diff_buffer: "buf.diff.git",
|
|
170
|
+
diff_buffer: "buf.diff",
|
|
171
|
+
diff_buffer_jump_to_source: "diffview.source",
|
|
172
|
+
# file namespace (2026-11-20)
|
|
173
|
+
git_diff_w: "file.diff.repo",
|
|
174
|
+
open_file_dialog: "file.open",
|
|
175
|
+
gui_file_finder: "file.finder",
|
|
176
|
+
start_file_selector: "file.explorer",
|
|
177
|
+
update_file_index: "file.finder.reindex",
|
|
178
|
+
gui_file_history_finder: "file.history",
|
|
179
|
+
fhist_remove_nonexisting: "file.history.prune",
|
|
180
|
+
delete_current_file: "file.delete",
|
|
181
|
+
set_executable: "file.executable",
|
|
182
|
+
put_file_path_to_clipboard: "file.path.copy",
|
|
183
|
+
put_file_ref_to_clipboard: "file.ref.copy",
|
|
184
|
+
extract_file_links: "file.links",
|
|
185
|
+
# panel namespace (2026-11-20)
|
|
186
|
+
toggle_file_panel: "panel.files.toggle",
|
|
187
|
+
toggle_func_panel: "panel.funcs.toggle",
|
|
188
|
+
toggle_keylog_panel: "panel.keylog.toggle",
|
|
189
|
+
refresh_func_panel: "panel.funcs.refresh",
|
|
190
|
+
file_panel_next_file: "panel.files.next",
|
|
191
|
+
file_panel_prev_file: "panel.files.prev",
|
|
192
|
+
file_panel_easy_jump: "panel.files.jump",
|
|
193
|
+
# view namespace (2026-11-20)
|
|
194
|
+
toggle_two_column: "view.columns.toggle",
|
|
195
|
+
toggle_active_window: "view.columns.switch",
|
|
196
|
+
center_on_current_line: "view.center",
|
|
197
|
+
gui_ensure_cursor_visible: "view.cursor.show",
|
|
198
|
+
gui_refresh_cursor: "view.cursor.refresh",
|
|
199
|
+
refresh_colors: "view.colors.reload",
|
|
200
|
+
# style namespace (2026-11-20)
|
|
201
|
+
set_line_style_h1: "style.line.h1",
|
|
202
|
+
set_line_style_h2: "style.line.h2",
|
|
203
|
+
set_line_style_h3: "style.line.h3",
|
|
204
|
+
set_line_style_h4: "style.line.h4",
|
|
205
|
+
set_line_style_heading: "style.line.heading",
|
|
206
|
+
set_line_style_title: "style.line.title",
|
|
207
|
+
set_line_style_bold: "style.line.bold",
|
|
208
|
+
set_line_style_italic: "style.line.italic",
|
|
209
|
+
clear_line_styles: "style.line.clear",
|
|
210
|
+
set_style_bold: "style.bold",
|
|
211
|
+
set_style_italic: "style.italic",
|
|
212
|
+
set_style_link: "style.link",
|
|
213
|
+
clear_formats: "style.clear",
|
|
214
|
+
show_images: "style.images",
|
|
215
|
+
# mark namespace (2026-11-20)
|
|
216
|
+
bookmark_add: "mark.add",
|
|
217
|
+
bookmark_list: "mark.list",
|
|
218
|
+
# term_lsp_macro namespace (2026-11-20)
|
|
219
|
+
execute_current_line_in_terminal: "term.line",
|
|
220
|
+
execute_current_line_in_terminal_autoclose: "term.line.autoclose",
|
|
221
|
+
lsp_jump_to_definition: "lsp.definition",
|
|
222
|
+
lsp_print_functions: "lsp.functions",
|
|
223
|
+
lsp_restart: "lsp.restart",
|
|
224
|
+
lsp_debug: "lsp.debug",
|
|
225
|
+
run_last_macro: "macro.run.last",
|
|
226
|
+
find_macro_gui: "macro.find",
|
|
227
|
+
gui_name_macro: "macro.name",
|
|
228
|
+
# modules namespace (2026-11-20)
|
|
229
|
+
insert_terminal: "terminal.insert",
|
|
230
|
+
insert_calculator: "calculator.insert",
|
|
231
|
+
toggle_highlight_colors: "color_highlight.toggle",
|
|
232
|
+
audio_stop: "audio.stop",
|
|
233
|
+
audio_forward: "audio.forward",
|
|
234
|
+
audio_backward: "audio.backward",
|
|
235
|
+
dictation_toggle: "dictation.toggle",
|
|
236
|
+
dictation_toggle_dialog: "dictation.toggle_dialog",
|
|
237
|
+
dictation_release_vram: "dictation.release_vram",
|
|
238
|
+
dictation_enter_mode: "dictation.enter_mode",
|
|
239
|
+
dictation_toggle_stay: "dictation.toggle_stay",
|
|
240
|
+
dictation_newline: "dictation.newline",
|
|
241
|
+
dictation_exit_mode: "dictation.exit_mode",
|
|
242
|
+
dictation_select_model: "dictation.select_model",
|
|
243
|
+
tts_speak_selection: "tts.speak_selection",
|
|
244
|
+
tts_stop: "tts.stop",
|
|
245
|
+
ollama_improve_selection: "ollama.improve_selection",
|
|
246
|
+
ollama_improve_selection_multi: "ollama.improve_selection_multi",
|
|
247
|
+
fexp_chdir_parent: "fexp.chdir_parent",
|
|
248
|
+
fexp_select: "fexp.select",
|
|
249
|
+
fexp_sort_mtime: "fexp.sort_mtime",
|
|
250
|
+
fexp_sort_fname: "fexp.sort_fname",
|
|
251
|
+
fexp_cut_file: "fexp.cut_file",
|
|
252
|
+
fexp_copy_file: "fexp.copy_file",
|
|
253
|
+
fexp_delete_file: "fexp.delete_file",
|
|
254
|
+
fexp_paste_files: "fexp.paste_files",
|
|
255
|
+
fexp_quit: "fexp.quit",
|
|
256
|
+
bmgr_select: "bmgr.select",
|
|
257
|
+
bmgr_close: "bmgr.close",
|
|
258
|
+
bmark_select: "bmark.select",
|
|
259
|
+
bmark_delete: "bmark.delete",
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
# A reference to an action by its dotted id, built by chaining: a.move.word.next
|
|
263
|
+
# is the reference "move.word.next" (nothing runs), and a trailing "!" runs
|
|
264
|
+
# it: a.buf.save!. Based on BasicObject, so ids like a.class or a.send work.
|
|
265
|
+
# Use a.… only in custom.rb and on the command line: in lib/, a local
|
|
266
|
+
# variable named "a" hides the method, so lib/ code uses the string form.
|
|
267
|
+
class ActionRef < BasicObject
|
|
268
|
+
def initialize(path)
|
|
269
|
+
@path = path
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def to_s
|
|
273
|
+
@path.join(".")
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
alias to_str to_s
|
|
277
|
+
|
|
278
|
+
def inspect
|
|
279
|
+
"a." + to_s
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def respond_to?(name, _priv = false)
|
|
283
|
+
[:to_s, :to_str, :inspect].include?(name)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def method_missing(name, *args)
|
|
287
|
+
s = name.to_s
|
|
288
|
+
# Conversion hooks Ruby probes for (to_ary, to_hash, ...) and predicates
|
|
289
|
+
# aren't path segments
|
|
290
|
+
::Kernel.raise ::NoMethodError, "undefined method '#{s}' for #{inspect}" if s.start_with?("to_") || s.end_with?("?", "=")
|
|
291
|
+
if s.end_with?("!")
|
|
292
|
+
id = (@path + [s.chomp("!")]).join(".")
|
|
293
|
+
if !$vma.actions.include?(id)
|
|
294
|
+
::Kernel.raise ::NameError, "Unknown action #{id}#{$vma.actions.did_you_mean(id)}"
|
|
295
|
+
end
|
|
296
|
+
return $vma.actions.call(id, *args)
|
|
297
|
+
end
|
|
298
|
+
ActionRef.new(@path + [s])
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
# Root of the action references: a.move.word.next, a.buf.save!
|
|
303
|
+
def a
|
|
304
|
+
ActionRef.new([])
|
|
12
305
|
end
|
|
13
306
|
|
|
14
307
|
def unreg_act(id)
|
|
15
308
|
vma.actions.unregister(id)
|
|
16
309
|
end
|
|
17
310
|
|
|
311
|
+
# id: a dotted id string ("buf.save"), an a.… reference, or an old symbol
|
|
18
312
|
def reg_act(id, callfunc, name = "", opt = {})
|
|
313
|
+
id = id.to_s if ActionRef === id
|
|
19
314
|
if callfunc.class == Proc
|
|
20
315
|
a = Action.new(id, name, callfunc, opt)
|
|
21
316
|
else
|
|
@@ -45,27 +340,77 @@ class ActionList
|
|
|
45
340
|
@actions = {}
|
|
46
341
|
end
|
|
47
342
|
|
|
343
|
+
# The registry key for id: an a.… reference becomes its string, and an old
|
|
344
|
+
# id listed in ACTION_ALIASES becomes its new id (noted once per old id).
|
|
345
|
+
def resolve(id)
|
|
346
|
+
id = id.to_s if ActionRef === id
|
|
347
|
+
if (id.class == Symbol || id.class == String) && (new_id = ACTION_ALIASES[id.to_sym])
|
|
348
|
+
@aliases_noted ||= {}
|
|
349
|
+
if !@aliases_noted[id.to_sym]
|
|
350
|
+
@aliases_noted[id.to_sym] = true
|
|
351
|
+
message("action :#{id} is now #{new_id}")
|
|
352
|
+
end
|
|
353
|
+
return new_id
|
|
354
|
+
end
|
|
355
|
+
id
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# " (did you mean x.y?)" for an unknown id, or ""
|
|
359
|
+
def did_you_mean(id)
|
|
360
|
+
ids = @actions.keys.select { |k| k.class == String && k.match?(ACTION_ID_RE) } +
|
|
361
|
+
@actions.keys.select { |k| k.class == Symbol }.map(&:to_s)
|
|
362
|
+
c = DidYouMean::SpellChecker.new(dictionary: ids).correct(id.to_s).first
|
|
363
|
+
c ? " (did you mean #{c}?)" : ""
|
|
364
|
+
end
|
|
365
|
+
|
|
48
366
|
def register(id, obj)
|
|
49
|
-
@actions[id] = obj
|
|
367
|
+
@actions[resolve(id)] = obj
|
|
50
368
|
end
|
|
51
369
|
|
|
52
370
|
def unregister(id)
|
|
53
|
-
@actions.delete(id)
|
|
371
|
+
@actions.delete(resolve(id))
|
|
54
372
|
end
|
|
55
373
|
|
|
56
374
|
def include?(act)
|
|
57
|
-
return @actions.has_key?(act)
|
|
375
|
+
return @actions.has_key?(resolve(act))
|
|
58
376
|
end
|
|
59
377
|
|
|
60
378
|
def [](id)
|
|
61
|
-
@actions[id]
|
|
379
|
+
@actions[resolve(id)]
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
def ids
|
|
383
|
+
@actions.keys
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
# Dotted action ids (no Ruby-code bindings, no old symbol ids)
|
|
387
|
+
def dotted_ids
|
|
388
|
+
@actions.keys.select { |k| k.class == String && k.match?(ACTION_ID_RE) && !@actions[k].opt&.[](:code) }
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
# The next level of ids below prefix, sorted: complete("move.") =>
|
|
392
|
+
# ["move.buf.", "move.char.", ..., "move.random"]. An entry ending in "."
|
|
393
|
+
# has more below it; one that is also an action itself appears both ways
|
|
394
|
+
# ("buf.save" and "buf.save."). complete("") lists the namespaces.
|
|
395
|
+
def complete(prefix)
|
|
396
|
+
out = []
|
|
397
|
+
dotted_ids.each { |id|
|
|
398
|
+
next if !id.start_with?(prefix)
|
|
399
|
+
rest = id[prefix.size..]
|
|
400
|
+
seg, more = rest.split(".", 2)
|
|
401
|
+
next if seg.nil? || seg.empty?
|
|
402
|
+
out << (more ? "#{prefix}#{seg}." : "#{prefix}#{seg}")
|
|
403
|
+
}
|
|
404
|
+
out.uniq.sort
|
|
62
405
|
end
|
|
63
406
|
|
|
64
|
-
|
|
407
|
+
# args: the typed character for an action bound to a "<char>" key
|
|
408
|
+
def call(id, *args)
|
|
409
|
+
id = resolve(id)
|
|
65
410
|
@acth << id
|
|
66
411
|
a = @actions[id]
|
|
67
412
|
if a
|
|
68
|
-
a.method.call()
|
|
413
|
+
a.method.call(*args)
|
|
69
414
|
else
|
|
70
415
|
message("Unknown action: " + id.inspect)
|
|
71
416
|
end
|
|
@@ -77,8 +422,8 @@ class ActionList
|
|
|
77
422
|
|
|
78
423
|
def gui_search()
|
|
79
424
|
l = []
|
|
80
|
-
opt = { :title => "Search for actions", :desc => "Fuzzy search for actions. <up> or <down> to change
|
|
81
|
-
:columns => [{ :title => "Shortcut", :id => 0 }, { :title => "Action", :id => 1 }] }
|
|
425
|
+
opt = { :title => "Search for actions", :desc => "Fuzzy search for actions. <up> or <down> to change selected. <enter> to select current.",
|
|
426
|
+
:columns => [{ :title => "Shortcut", :id => 0 }, { :title => "Action", :id => 1 }, { :title => "Description", :id => 2 }] }
|
|
82
427
|
|
|
83
428
|
@select_keys = ["h", "l", "f", "d", "s", "a", "g", "z"]
|
|
84
429
|
|
|
@@ -90,15 +435,24 @@ class ActionList
|
|
|
90
435
|
|
|
91
436
|
@item_list = []
|
|
92
437
|
|
|
438
|
+
# Rows for Search for Actions: [key, id, description]. A query that
|
|
439
|
+
# starts with a namespace and a dot ("move." or "move.wo") searches only that
|
|
440
|
+
# namespace, and "move." alone lists all of it. An old id finds the action
|
|
441
|
+
# it was renamed to.
|
|
93
442
|
def search_actions_update_callback(search_str = "")
|
|
94
443
|
return [] if search_str == ""
|
|
95
444
|
|
|
96
|
-
|
|
445
|
+
old_ids = Hash.new { |h, k| h[k] = [] }
|
|
446
|
+
ACTION_ALIASES.each { |o, n| old_ids[n] << o.to_s }
|
|
447
|
+
|
|
448
|
+
ns = search_str[/\A[a-z_]+\./]
|
|
449
|
+
ns = nil if ns && !dotted_ids.any? { |id| id.start_with?(ns) }
|
|
450
|
+
|
|
451
|
+
item_list = []
|
|
97
452
|
for act_id in @actions.keys
|
|
453
|
+
next if ns && !act_id.to_s.start_with?(ns)
|
|
98
454
|
act = @actions[act_id]
|
|
99
|
-
item = {}
|
|
100
|
-
item[:key] = ""
|
|
101
|
-
|
|
455
|
+
item = { key: "" }
|
|
102
456
|
for mode_str in ["C", "V"]
|
|
103
457
|
c_kbd = vma.kbd.act_bindings[mode_str][act_id]
|
|
104
458
|
if c_kbd.class == String
|
|
@@ -107,26 +461,21 @@ class ActionList
|
|
|
107
461
|
break
|
|
108
462
|
end
|
|
109
463
|
end
|
|
110
|
-
# c_kbd = vma.kbd.act_bindings[mode_str][nfo[:action]]
|
|
111
464
|
item[:action] = act_id
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
465
|
+
desc = act.method_name.to_s
|
|
466
|
+
item[:desc] = desc == act_id.to_s ? "" : desc
|
|
467
|
+
item[:str] = item[:desc].empty? ? act_id.to_s : "#{act_id} #{desc}"
|
|
468
|
+
item[:match] = ([item[:str]] + old_ids[act_id]).join(" ")
|
|
469
|
+
item_list << item
|
|
117
470
|
end
|
|
118
471
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
@item_list = r
|
|
127
|
-
|
|
128
|
-
r = a.collect { |x| [x[0][:key], x[0][:str]] }
|
|
129
|
-
return r
|
|
472
|
+
if ns && search_str == ns
|
|
473
|
+
found = item_list.sort_by { |x| x[:action].to_s }.map { |x| [x] }
|
|
474
|
+
else
|
|
475
|
+
found = filter_items(item_list, 0, ns ? search_str[ns.size..] : search_str)
|
|
476
|
+
end
|
|
477
|
+
@item_list = found.collect { |x| [x[0][0], 0, x] }
|
|
478
|
+
return found.collect { |x| [x[0][:key], x[0][:action].to_s, x[0][:desc]] }
|
|
130
479
|
end
|
|
131
480
|
|
|
132
481
|
def search_actions_select_callback(search_str, idx)
|
|
@@ -136,12 +485,8 @@ class ActionList
|
|
|
136
485
|
debug "Selected:" + acc.to_s
|
|
137
486
|
gui_select_window_close(0)
|
|
138
487
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
elsif acc.class == Symbol
|
|
142
|
-
debug "Symbol"
|
|
143
|
-
call(acc)
|
|
144
|
-
end
|
|
488
|
+
# Dotted ids, old symbol ids and Ruby-code bindings alike
|
|
489
|
+
exec_action(acc)
|
|
145
490
|
end
|
|
146
491
|
|
|
147
492
|
def filter_items(item_list, item_key, search_str)
|
|
@@ -152,7 +497,7 @@ class ActionList
|
|
|
152
497
|
puts item.inspect
|
|
153
498
|
exit!
|
|
154
499
|
end
|
|
155
|
-
[item, srn_dst(search_str, item[:str])]
|
|
500
|
+
[item, srn_dst(search_str, item[:match] || item[:str])]
|
|
156
501
|
end
|
|
157
502
|
scores.sort_by! { |x| -x[1] }
|
|
158
503
|
debug scores.inspect
|
data/lib/vimamsa/bookmarks.rb
CHANGED
|
@@ -17,14 +17,14 @@ class Bookmarks
|
|
|
17
17
|
|
|
18
18
|
def self.init()
|
|
19
19
|
vma.kbd.add_minor_mode("bmark", :bmark, :command)
|
|
20
|
-
reg_act(
|
|
21
|
-
reg_act(
|
|
22
|
-
reg_act(
|
|
23
|
-
reg_act(
|
|
24
|
-
|
|
25
|
-
bindkey "bmark enter",
|
|
26
|
-
bindkey "bmark d",
|
|
27
|
-
bindkey "bmark x",
|
|
20
|
+
reg_act("mark.add", proc { vma.bookmarks.add }, "Add bookmark at cursor (persistent, across files)")
|
|
21
|
+
reg_act("mark.list", proc { BookmarkList.new.run; vma.kbd.set_mode(:bmark) }, "List bookmarks")
|
|
22
|
+
reg_act("bmark.select", proc { buf.module.select_line }, "")
|
|
23
|
+
reg_act("bmark.delete", proc { buf.module.delete_selected }, "")
|
|
24
|
+
|
|
25
|
+
bindkey "bmark enter", "bmark.select"
|
|
26
|
+
bindkey "bmark d", "bmark.delete"
|
|
27
|
+
bindkey "bmark x", "buf.close"
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def initialize()
|