vimamsa 0.1.27 → 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/README.md +139 -89
- data/custom_example.rb +18 -6
- data/doc/TODO.md +327 -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/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/exe/run_tests.rb +8 -1
- 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 +83 -37
- 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 +458 -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 +89 -46
- 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 +83 -13
- data/lib/vimamsa/gui_command_line.rb +44 -5
- data/lib/vimamsa/gui_form_generator.rb +17 -6
- 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 +15 -81
- data/lib/vimamsa/gui_theme.rb +11 -2
- data/lib/vimamsa/hook.rb +2 -0
- data/lib/vimamsa/intro_page.rb +368 -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 +47 -297
- data/lib/vimamsa/key_bindings_vimlike.rb +347 -339
- data/lib/vimamsa/key_names.rb +80 -0
- 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_core.rb +355 -0
- 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 +138 -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 +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 +301 -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_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 +122 -0
- data/tests/test_run_ruby.rb +77 -0
- data/tests/test_startup_file.rb +1 -1
- 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 +22 -2
- metadata +58 -3
- data/run_tests_vm.sh +0 -130
data/lib/vimamsa/editor.rb
CHANGED
|
@@ -7,7 +7,7 @@ class Editor
|
|
|
7
7
|
attr_reader :file_content_search_paths, :file_name_search_paths, :gui, :hook, :macro, :actions
|
|
8
8
|
# @!attribute [rw] kbd
|
|
9
9
|
# @return [KeyBindingTree]
|
|
10
|
-
attr_accessor :converters, :fh, :bookmarks, :paint_stack, :kbd, :langsrv, :
|
|
10
|
+
attr_accessor :converters, :fh, :bookmarks, :paint_stack, :kbd, :langsrv, :registers, :clipboard, :dot
|
|
11
11
|
#attr_writer :call_func, :update_highlight
|
|
12
12
|
|
|
13
13
|
def initialize()
|
|
@@ -24,19 +24,14 @@ class Editor
|
|
|
24
24
|
@paint_stack = []
|
|
25
25
|
@_plugins = {}
|
|
26
26
|
@errors
|
|
27
|
-
@
|
|
28
|
-
@
|
|
27
|
+
@registers = Registers.new
|
|
28
|
+
@dot = DotRepeat.new
|
|
29
29
|
@clipboard = Clipboard.new
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
# "x: use register char for the next copy, delete or put (registers.rb)
|
|
32
33
|
def set_register(char)
|
|
33
|
-
@
|
|
34
|
-
message("Set register #{char}")
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def paste_register(char)
|
|
38
|
-
$c = @cur_register #TODO:??
|
|
39
|
-
message("Paste: #{$c}")
|
|
34
|
+
@registers.select(char)
|
|
40
35
|
end
|
|
41
36
|
|
|
42
37
|
def open_file_listener(added)
|
|
@@ -100,7 +95,12 @@ class Editor
|
|
|
100
95
|
end
|
|
101
96
|
}
|
|
102
97
|
|
|
103
|
-
|
|
98
|
+
# A mode change starts a new undo step, except inside a group run as one
|
|
99
|
+
# step (a macro, a "." repeat)
|
|
100
|
+
@kbd.on(:mode_set) { |label|
|
|
101
|
+
b = vma.buf
|
|
102
|
+
b.new_undo_group if b && !b.instance_variable_get(:@macro_group_active)
|
|
103
|
+
}
|
|
104
104
|
@kbd.on(:mode_changed) { |label|
|
|
105
105
|
if label != :insert
|
|
106
106
|
# Dismiss the autocomplete popup when leaving insert mode
|
|
@@ -117,18 +117,41 @@ class Editor
|
|
|
117
117
|
}
|
|
118
118
|
@kbd.on(:key_no_match) { |c, trail| vma.gui.keylog_panel&.log_nomatch(c, trail) }
|
|
119
119
|
@kbd.on(:key_pending) { |trail| vma.gui.keylog_panel&.log_pending(trail) }
|
|
120
|
-
@kbd.on(:key_action) { |trail, action|
|
|
120
|
+
@kbd.on(:key_action) { |trail, action|
|
|
121
|
+
vma.gui.keylog_panel&.log_action(trail, action)
|
|
122
|
+
@dot.before(action) # "." (dot_repeat.rb)
|
|
123
|
+
}
|
|
121
124
|
@kbd.on(:action_executed) { |action, ret|
|
|
122
125
|
if vma.macro.is_recording and ret != false
|
|
123
126
|
debug "RECORD ACTION:#{action}", 2
|
|
124
127
|
vma.macro.record_action(action)
|
|
125
128
|
end
|
|
126
129
|
}
|
|
127
|
-
@kbd.on(:action_handled) { |trail, action|
|
|
130
|
+
@kbd.on(:action_handled) { |trail, action|
|
|
131
|
+
vma.gui.show_action_trail(trail, action)
|
|
132
|
+
# A "x register applies to the next command only (counts may come
|
|
133
|
+
# between: "a3yy)
|
|
134
|
+
a = action.to_s
|
|
135
|
+
@registers.clear_pending if !a.include?("edit.register!") && !a.include?("kbd.count.digit")
|
|
136
|
+
@dot.after(action)
|
|
137
|
+
}
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Moves the files of older versions to their new places, once
|
|
141
|
+
# (UserDirs.migrate). Only with the default dirs: with --user-dir (tests,
|
|
142
|
+
# --tmp-user-dir) config and data share one dir and nothing moves.
|
|
143
|
+
def migrate_user_files
|
|
144
|
+
return if !UserDirs.default_config_dir?(vma_user_dir)
|
|
145
|
+
UserDirs.migrate(config_dir: vma_user_dir, data_dir: vma_data_dir).each { |from, to|
|
|
146
|
+
puts "vimamsa: moved #{from} to #{to}"
|
|
147
|
+
}
|
|
148
|
+
rescue => e
|
|
149
|
+
debug "migrate_user_files: #{e}"
|
|
128
150
|
end
|
|
129
151
|
|
|
130
152
|
def start
|
|
131
153
|
@gui = $vmag #TODO
|
|
154
|
+
migrate_user_files
|
|
132
155
|
|
|
133
156
|
$hook = Hook.new
|
|
134
157
|
@hook = $hook
|
|
@@ -170,6 +193,9 @@ class Editor
|
|
|
170
193
|
require "vimamsa/key_bindings_vimlike"
|
|
171
194
|
end
|
|
172
195
|
|
|
196
|
+
# Form input mode and its keys, in every scheme (form_input.rb)
|
|
197
|
+
form_input_setup
|
|
198
|
+
|
|
173
199
|
$buffers = BufferList.new
|
|
174
200
|
$minibuffer = Buffer.new(">", "")
|
|
175
201
|
@langsrv = {}
|
|
@@ -186,8 +212,8 @@ class Editor
|
|
|
186
212
|
@gui.init_menu
|
|
187
213
|
|
|
188
214
|
mkdir_if_not_exists(get_dot_path(""))
|
|
189
|
-
mkdir_if_not_exists(
|
|
190
|
-
listen_dir =
|
|
215
|
+
mkdir_if_not_exists(get_data_path("backup"))
|
|
216
|
+
listen_dir = get_data_path("listen")
|
|
191
217
|
mkdir_if_not_exists(listen_dir)
|
|
192
218
|
listener = Listen.to(listen_dir) do |modified, added, removed|
|
|
193
219
|
debug([modified: modified, added: added, removed: removed])
|
|
@@ -209,7 +235,8 @@ class Editor
|
|
|
209
235
|
# they register goes in phase 2 (hook_custom_after_init, called at the end of
|
|
210
236
|
# start; see call_custom_after_init).
|
|
211
237
|
custom_script = read_file("", custom_fn)
|
|
212
|
-
|
|
238
|
+
# bindings made by custom.rb get the keyword "custom" (key bindings page)
|
|
239
|
+
vma.kbd.with_keywords(["custom"]) { eval(custom_script) } if custom_script
|
|
213
240
|
|
|
214
241
|
Grep.init
|
|
215
242
|
FileManager.init
|
|
@@ -237,7 +264,8 @@ class Editor
|
|
|
237
264
|
load main_file
|
|
238
265
|
# Call <name>_init if the module defines it.
|
|
239
266
|
init_fn = "#{mod_name}_init"
|
|
240
|
-
|
|
267
|
+
# bindings made by the module get the keyword module:<name>
|
|
268
|
+
vma.kbd.with_keywords(["module:#{mod_name}"]) { send(init_fn) } if respond_to?(init_fn, true)
|
|
241
269
|
end
|
|
242
270
|
end
|
|
243
271
|
end
|
|
@@ -299,6 +327,9 @@ class Editor
|
|
|
299
327
|
@kbd.set_state_to_root
|
|
300
328
|
@kbd.show_state_trail
|
|
301
329
|
|
|
330
|
+
# The introduction page on the first start, or with --intro (intro_page.rb)
|
|
331
|
+
show_intro_on_startup
|
|
332
|
+
|
|
302
333
|
# AppImage: from here on, started programs get the user's environment
|
|
303
334
|
restore_host_env
|
|
304
335
|
|
|
@@ -358,8 +389,16 @@ class Editor
|
|
|
358
389
|
end
|
|
359
390
|
end
|
|
360
391
|
|
|
392
|
+
# marshal_save files the program generates, kept in the data dir; the
|
|
393
|
+
# others (bookmarks, named_macros) are the user's, in the config dir
|
|
394
|
+
DATA_VARS = %w[file_index file_history file_panel_shown macros]
|
|
395
|
+
|
|
396
|
+
def var_file_path(varname)
|
|
397
|
+
DATA_VARS.include?(varname.to_s) ? get_data_path(varname) : get_dot_path(varname)
|
|
398
|
+
end
|
|
399
|
+
|
|
361
400
|
def save_var_to_file(varname, vardata)
|
|
362
|
-
fn =
|
|
401
|
+
fn = var_file_path(varname)
|
|
363
402
|
#TODO: check that save path is safe
|
|
364
403
|
f = File.open(fn, "w")
|
|
365
404
|
File.binwrite(f, vardata)
|
|
@@ -367,7 +406,7 @@ class Editor
|
|
|
367
406
|
end
|
|
368
407
|
|
|
369
408
|
def load_var_from_file(varname)
|
|
370
|
-
fn =
|
|
409
|
+
fn = var_file_path(varname)
|
|
371
410
|
if File.exist?(fn)
|
|
372
411
|
vardata = IO.binread(fn)
|
|
373
412
|
if vardata
|
|
@@ -399,13 +438,13 @@ class Editor
|
|
|
399
438
|
.map { |b| b.fname }
|
|
400
439
|
.compact
|
|
401
440
|
.select { |f| File.exist?(f) }
|
|
402
|
-
IO.write(
|
|
441
|
+
IO.write(get_data_path("session.txt"), fnames.join("\n") + "\n")
|
|
403
442
|
rescue => ex
|
|
404
443
|
debug "save_session failed: #{ex}"
|
|
405
444
|
end
|
|
406
445
|
|
|
407
446
|
def check_session_restore
|
|
408
|
-
session_path =
|
|
447
|
+
session_path = get_data_path("session.txt")
|
|
409
448
|
return unless File.exist?(session_path)
|
|
410
449
|
|
|
411
450
|
fnames = File.read(session_path).lines.map(&:strip).reject(&:empty?)
|
|
@@ -460,7 +499,9 @@ class Editor
|
|
|
460
499
|
# Register converter
|
|
461
500
|
def reg_conv(converter, converter_id)
|
|
462
501
|
@converters[converter_id] = converter
|
|
463
|
-
|
|
502
|
+
id = "sel.convert.#{converter_id}"
|
|
503
|
+
ACTION_ALIASES[converter_id.to_sym] = id # the old action id was the converter id
|
|
504
|
+
reg_act(id, proc { vma.buf.convert_selected_text(converter_id) }, "Converter #{converter_id}", { :scope => [:selection] })
|
|
464
505
|
end
|
|
465
506
|
|
|
466
507
|
def apply_conv(converter_id, txt)
|
|
@@ -744,13 +785,13 @@ def scan_word_start_marks(search_str)
|
|
|
744
785
|
return wsmarks
|
|
745
786
|
end
|
|
746
787
|
|
|
747
|
-
# Base directory for user config
|
|
748
|
-
#
|
|
749
|
-
#
|
|
750
|
-
# before startup. Tests point this at an
|
|
751
|
-
# or write the real user config.
|
|
788
|
+
# Base directory for user-edited config (settings.rb, custom.rb, styles,
|
|
789
|
+
# bookmarks, named macros): $XDG_CONFIG_HOME/vimamsa, by default
|
|
790
|
+
# ~/.config/vimamsa (user_dirs.rb). Can be overridden with the --user-dir
|
|
791
|
+
# switch or by setting $vma_user_dir before startup. Tests point this at an
|
|
792
|
+
# isolated directory so they never read or write the real user config.
|
|
752
793
|
def vma_user_dir
|
|
753
|
-
$vma_user_dir ||=
|
|
794
|
+
$vma_user_dir ||= UserDirs.default_config_dir
|
|
754
795
|
end
|
|
755
796
|
|
|
756
797
|
def get_dot_path(sfx)
|
|
@@ -760,20 +801,13 @@ def get_dot_path(sfx)
|
|
|
760
801
|
return dpath
|
|
761
802
|
end
|
|
762
803
|
|
|
763
|
-
# Base directory for files the program generates (
|
|
764
|
-
#
|
|
765
|
-
# ~/.local/share/vimamsa. When the user
|
|
766
|
-
# data goes there too, so those runs stay
|
|
804
|
+
# Base directory for files the program generates (session, histories,
|
|
805
|
+
# backups, crash reports, listen dir, window layout, ...):
|
|
806
|
+
# $XDG_DATA_HOME/vimamsa, by default ~/.local/share/vimamsa. When the user
|
|
807
|
+
# dir was moved (--user-dir, tests), data goes there too, so those runs stay
|
|
808
|
+
# isolated (user_dirs.rb).
|
|
767
809
|
def vma_data_dir
|
|
768
|
-
$vma_data_dir ||=
|
|
769
|
-
if File.expand_path(vma_user_dir) != File.expand_path("~/.config/vimamsa")
|
|
770
|
-
vma_user_dir
|
|
771
|
-
else
|
|
772
|
-
base = ENV["XDG_DATA_HOME"].to_s
|
|
773
|
-
base = File.expand_path("~/.local/share") if base.empty?
|
|
774
|
-
File.join(base, "vimamsa")
|
|
775
|
-
end
|
|
776
|
-
end
|
|
810
|
+
$vma_data_dir ||= UserDirs.data_dir_for(vma_user_dir)
|
|
777
811
|
end
|
|
778
812
|
|
|
779
813
|
def get_data_path(sfx)
|
|
@@ -851,7 +885,16 @@ def restart_editor
|
|
|
851
885
|
script = $PROGRAM_NAME
|
|
852
886
|
message("Restarting...")
|
|
853
887
|
# Signal the new instance to restore the session without prompting.
|
|
854
|
-
|
|
888
|
+
env = { "VIMAMSA_RESTORE_SESSION" => "1" }
|
|
889
|
+
# The same user dir: a --tmp-user-dir one (kept, deleted by the new
|
|
890
|
+
# process at quit) or a --user-dir one
|
|
891
|
+
args = []
|
|
892
|
+
if $vma_tmp_user_dir
|
|
893
|
+
env[TmpUserDir::ENV_KEY] = $vma_tmp_user_dir
|
|
894
|
+
elsif !UserDirs.default_config_dir?(vma_user_dir)
|
|
895
|
+
args = ["--user-dir", vma_user_dir]
|
|
896
|
+
end
|
|
897
|
+
exec(env, ruby, script, *args)
|
|
855
898
|
rescue => ex
|
|
856
899
|
message("Restart failed: #{ex}")
|
|
857
900
|
end
|
|
@@ -859,7 +902,7 @@ end
|
|
|
859
902
|
def reload_customrb
|
|
860
903
|
custom_fn = get_dot_path("custom.rb")
|
|
861
904
|
custom_script = read_file("", custom_fn)
|
|
862
|
-
eval(custom_script) if custom_script
|
|
905
|
+
vma.kbd.with_keywords(["custom"]) { eval(custom_script) } if custom_script
|
|
863
906
|
call_custom_after_init # everything is loaded already: run phase 2 right away
|
|
864
907
|
gui_refresh_colors # apply any cnf.theme.colors/cyber overrides live
|
|
865
908
|
message("Reloaded #{custom_fn}")
|
|
@@ -875,7 +918,7 @@ end
|
|
|
875
918
|
def call_custom_after_init
|
|
876
919
|
return if !respond_to?(:hook_custom_after_init, true)
|
|
877
920
|
begin
|
|
878
|
-
send(:hook_custom_after_init)
|
|
921
|
+
vma.kbd.with_keywords(["custom"]) { send(:hook_custom_after_init) }
|
|
879
922
|
rescue Exception => e
|
|
880
923
|
warn e.inspect
|
|
881
924
|
warn e.backtrace
|
|
@@ -883,7 +926,7 @@ def call_custom_after_init
|
|
|
883
926
|
end
|
|
884
927
|
end
|
|
885
928
|
|
|
886
|
-
def save_settings_to_file
|
|
929
|
+
def save_settings_to_file(quiet: false)
|
|
887
930
|
settings_path = get_dot_path("settings.rb")
|
|
888
931
|
lines = all_settings_defs.flat_map { |section| section[:settings] }.map do |s|
|
|
889
932
|
key_str = "cnf." + s[:key].join(".")
|
|
@@ -891,7 +934,7 @@ def save_settings_to_file
|
|
|
891
934
|
"#{key_str} = #{val.inspect}"
|
|
892
935
|
end
|
|
893
936
|
IO.write(settings_path, lines.join("\n") + "\n")
|
|
894
|
-
message("Settings saved to #{settings_path}")
|
|
937
|
+
message("Settings saved to #{settings_path}") if !quiet
|
|
895
938
|
end
|
|
896
939
|
|
|
897
940
|
DEMO_FILES = ["demo.txt", "sheep.jpg", "README.md"]
|
data/lib/vimamsa/file_history.rb
CHANGED
|
@@ -10,7 +10,7 @@ class FileHistory
|
|
|
10
10
|
vma.hook.register(:change_buffer, self.method("update"))
|
|
11
11
|
vma.hook.register(:shutdown, self.method("save"))
|
|
12
12
|
|
|
13
|
-
reg_act(
|
|
13
|
+
reg_act("file.history.prune", proc { remove_nonexisting }, "Cleanup history, remove non-existing files")
|
|
14
14
|
|
|
15
15
|
@history = vma.marshal_load("file_history", {})
|
|
16
16
|
$search_list = []
|
data/lib/vimamsa/file_manager.rb
CHANGED
|
@@ -30,42 +30,42 @@ class FileManager
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def self.init()
|
|
33
|
-
reg_act(
|
|
33
|
+
reg_act("file.explorer", proc { FileManager.new.run; vma.kbd.set_mode(:file_exp) }, "File selector")
|
|
34
34
|
|
|
35
|
-
reg_act(
|
|
36
|
-
reg_act(
|
|
35
|
+
reg_act("fexp.chdir_parent", proc { FileManager.chdir_parent }, "File selector")
|
|
36
|
+
reg_act("fexp.select", proc { buf.module.select_line }, "")
|
|
37
37
|
|
|
38
|
-
reg_act(
|
|
39
|
-
reg_act(
|
|
38
|
+
reg_act("fexp.sort_mtime", proc { FileManager.with_cur { |fm| fm.sort_mtime } }, "Sort based on time")
|
|
39
|
+
reg_act("fexp.sort_fname", proc { FileManager.with_cur { |fm| fm.sort_fname } }, "Sort based on file name")
|
|
40
40
|
|
|
41
|
-
bindkey "C , j f",
|
|
42
|
-
bindkey "C , f",
|
|
41
|
+
bindkey "C , j f", "file.explorer"
|
|
42
|
+
bindkey "C , f", "file.explorer"
|
|
43
43
|
|
|
44
44
|
# bindkey "C o", :delete_state
|
|
45
45
|
|
|
46
46
|
vma.kbd.add_minor_mode("fexp", :file_exp, :command)
|
|
47
47
|
|
|
48
|
-
bindkey "fexp o m",
|
|
49
|
-
bindkey "fexp o f",
|
|
48
|
+
bindkey "fexp o m", "fexp.sort_mtime"
|
|
49
|
+
bindkey "fexp o f", "fexp.sort_fname"
|
|
50
50
|
|
|
51
51
|
# These are not yet safe to use
|
|
52
52
|
if cnf.fexp.experimental?
|
|
53
|
-
reg_act(
|
|
54
|
-
reg_act(
|
|
55
|
-
reg_act(
|
|
56
|
-
reg_act(
|
|
57
|
-
|
|
58
|
-
bindkey "fexp d d",
|
|
59
|
-
bindkey "fexp y y",
|
|
60
|
-
bindkey "fexp d D",
|
|
61
|
-
bindkey "fexp p p",
|
|
53
|
+
reg_act("fexp.cut_file", proc { FileManager.with_cur { |fm| fm.cut_file } }, "Cut file (to paste elsewhere)")
|
|
54
|
+
reg_act("fexp.copy_file", proc { FileManager.with_cur { |fm| fm.copy_file } }, "Copy file (to paste elsewhere)")
|
|
55
|
+
reg_act("fexp.delete_file", proc { FileManager.with_cur { |fm| fm.delete_file } }, "Delete current file")
|
|
56
|
+
reg_act("fexp.paste_files", proc { FileManager.with_cur { |fm| fm.paste_files } }, "Move previously cut files here")
|
|
57
|
+
|
|
58
|
+
bindkey "fexp d d", "fexp.cut_file"
|
|
59
|
+
bindkey "fexp y y", "fexp.copy_file"
|
|
60
|
+
bindkey "fexp d D", "fexp.delete_file"
|
|
61
|
+
bindkey "fexp p p", "fexp.paste_files"
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
# bindkey "fexp l", [
|
|
65
|
-
bindkey "fexp h",
|
|
66
|
-
bindkey "fexp esc", [
|
|
67
|
-
bindkey "fexp enter",
|
|
68
|
-
bindkey "fexp l",
|
|
64
|
+
# bindkey "fexp l", ["fexp.right", proc { debug "==fexp_right==" }, ""]
|
|
65
|
+
bindkey "fexp h", "fexp.chdir_parent"
|
|
66
|
+
bindkey "fexp esc", ["fexp.quit", proc { FileManager.with_cur { |fm| fm.quit } }, ""]
|
|
67
|
+
bindkey "fexp enter", "fexp.select"
|
|
68
|
+
bindkey "fexp l", "fexp.select"
|
|
69
69
|
|
|
70
70
|
@sort_by = :name
|
|
71
71
|
end
|