vimamsa 0.1.14 → 0.1.16

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.
@@ -1,11 +1,41 @@
1
1
  module Gui
2
- def self.highlight_match(bf, str, color: "#aa0000ff")
2
+ def self.hilight_range(bf, r, color: "#aa0000ff", weight: nil, tag: nil)
3
+ vbuf = bf.view.buffer
4
+
5
+ if tag.nil?
6
+ tag = vma.gui.view.buffer.create_tag
7
+ tag.weight = weight if !weight.nil?
8
+ tag.foreground = color
9
+ end
10
+
11
+ itr = vbuf.get_iter_at(:offset => r.begin)
12
+ itr2 = vbuf.get_iter_at(:offset => r.last)
13
+ vbuf.apply_tag(tag, itr, itr2)
14
+ end
15
+
16
+ def self.highlight_match(bf, str, color: "#aa0000ff", weight: 650)
17
+ r = Regexp.new(Regexp.escape(str), Regexp::IGNORECASE)
18
+ tag = vma.gui.view.buffer.create_tag
19
+ tag.weight = weight
20
+ tag.foreground = color
21
+ ind = scan_indexes(bf, r)
22
+ ind.each { |x|
23
+ r = x..(x + str.size)
24
+ self.hilight_range(bf, r, tag: tag)
25
+ }
26
+ end
27
+
28
+ def self.highlight_match_old(bf, str, color: "#aa0000ff")
3
29
  vbuf = bf.view.buffer
4
30
  r = Regexp.new(Regexp.escape(str), Regexp::IGNORECASE)
5
31
 
6
32
  hlparts = []
7
33
 
8
- tt = vma.gui.view.buffer.create_tag("highlight_match_tag")
34
+ tt = vma.gui.view.buffer.tag_table.lookup("highlight_match_tag")
35
+ if tt.nil?
36
+ tt = vma.gui.view.buffer.create_tag("highlight_match_tag")
37
+ end
38
+
9
39
  tt.weight = 650
10
40
  tt.foreground = color
11
41
 
@@ -39,12 +39,23 @@ def hpt_check_cur_word(w)
39
39
  # return true
40
40
  else
41
41
  message "File not found: #{fpfx}"
42
+ newfn = fcands[0]
43
+ if File.extname(newfn) == ""
44
+ newfn = fcands[1]
45
+ end
46
+ Gui.confirm("File does not exist. Create a new file? \r #{newfn}",
47
+ proc{hpt_create_new_file(newfn)})
48
+
42
49
  end
43
50
  end
44
51
  end
45
52
  return nil
46
53
  end
47
54
 
55
+ def hpt_create_new_file(fn)
56
+ create_new_file(fn)
57
+ end
58
+
48
59
  def translate_path(fn, bf)
49
60
  if File.exist?(fn)
50
61
  outfn = fn
@@ -28,6 +28,8 @@ def is_visual_mode()
28
28
  return 0
29
29
  end
30
30
 
31
+ reg_act(:command_to_buf, proc { command_to_buf }, "Execute command, output to buffer")
32
+
31
33
  reg_act(:lsp_debug, proc { vma.buf.lsp_get_def }, "LSP get definition")
32
34
  reg_act(:lsp_jump_to_definition, proc { vma.buf.lsp_jump_to_def }, "LSP jump to definition")
33
35
 
@@ -38,8 +40,6 @@ reg_act(:easy_jump, proc { EasyJump.start }, "Easy jump")
38
40
  reg_act(:gui_ensure_cursor_visible, proc { vma.gui.view.ensure_cursor_visible }, "Scroll to current cursor position")
39
41
  reg_act(:gui_refresh_cursor, proc { vma.buf.refresh_cursor }, "Refresh cursor")
40
42
 
41
-
42
-
43
43
  reg_act(:savedebug, "savedebug", "Save debug info", { :group => :debug })
44
44
  reg_act(:open_file_dialog, "open_file_dialog", "Open file", { :group => :file })
45
45
  reg_act(:create_new_file, "create_new_file", "Create new file", { :group => :file })
@@ -62,7 +62,7 @@ reg_act(:put_file_ref_to_clipboard, proc { buf.put_file_ref_to_clipboard }, "Put
62
62
  reg_act(:encrypt_file, proc { encrypt_cur_buffer }, "Set current file to encrypt on save")
63
63
  reg_act(:set_unencrypted, proc { buf.set_unencrypted }, "Set current file to save unencrypted")
64
64
  reg_act(:set_executable, proc { buf.set_executable }, "Set current file permissions to executable")
65
- reg_act(:close_all_buffers, proc { bufs.close_all_buffers() }, "Close all buffers")
65
+ # reg_act(:close_all_buffers, proc { bufs.close_all_buffers() }, "Close all buffers")
66
66
  reg_act(:close_current_buffer, proc { bufs.close_current_buffer(true) }, "Close current buffer")
67
67
  reg_act(:comment_selection, proc { buf.comment_selection }, "")
68
68
  reg_act(:delete_char_forward, proc { buf.delete(CURRENT_CHAR_FORWARD) }, "Delete char forward", { :group => [:edit, :basic] })
@@ -94,15 +94,23 @@ reg_act :update_file_index, proc { FileFinder.update_index }, "Update file index
94
94
  reg_act :delete_to_word_end, proc { buf.delete2(:to_word_end) }, "Delete to file end", { :group => [:edit, :basic] }
95
95
  reg_act :delete_to_next_word_start, proc { buf.delete2(:to_next_word) }, "Delete to start of next word", { :group => [:edit, :basic] }
96
96
  reg_act :delete_to_line_start, proc { buf.delete2(:to_line_start) }, "Delete to line start", { :group => [:edit, :basic] }
97
- reg_act :start_browse_mode, proc { $kbd.set_mode(:browse); $kbd.set_default_mode(:browse) }, "Start browse mode"
97
+
98
+ reg_act :start_browse_mode, proc {
99
+ vma.kbd.set_mode(:browse)
100
+ bufs.reset_navigation
101
+ }, "Start browse mode"
102
+ reg_act :kbd_dump_state, proc { vma.kbd.dump_state }, "Dump keyboard tree state"
103
+
98
104
  reg_act :exit_browse_mode, proc {
99
- bufs.add_current_buf_to_history;
100
- vma.kbd.set_mode_stack([vma.buf.default_mode])
101
- vma.kbd.set_mode_to_default
105
+ bufs.add_current_buf_to_history
106
+ # Load previously saved buffer specific mode stack
107
+ buf.restore_kbd_mode
102
108
  }, "Exit browse mode"
103
109
 
104
- reg_act :page_down, proc { page_down }, "Page down", :group => [:move, :basic]
105
- reg_act :page_up, proc { page_up }, "Page up", :group => [:move, :basic]
110
+ # reg_act :page_down, proc { page_down }, "Page down", :group => [:move, :basic]
111
+ reg_act :page_down, proc { vma.gui.page_down }, "Page down", :group => [:move, :basic]
112
+
113
+ reg_act :page_up, proc { vma.gui.page_up }, "Page up", :group => [:move, :basic]
106
114
  reg_act :jump_to_start_of_buffer, proc { buf.jump(START_OF_BUFFER) }, "Jump to start of buffer"
107
115
  reg_act :jump_to_end_of_buffer, proc { buf.jump(END_OF_BUFFER) }, "Jump to end of buffer"
108
116
  reg_act(:auto_indent_buffer, proc { buf.indent }, "Auto format buffer")
@@ -164,7 +172,7 @@ act_list = {
164
172
  :toggle_active_window => { :proc => proc { vma.gui.toggle_active_window },
165
173
  :desc => "Toggle active window", :group => :search },
166
174
 
167
- :toggle_two_column => { :proc => proc { vma.gui.set_two_column },
175
+ :toggle_two_column => { :proc => proc { vma.gui.toggle_two_column },
168
176
  :desc => "Set two column mode", :group => :search },
169
177
 
170
178
  :content_search => { :proc => proc { FileContentSearch.start_gui },
@@ -179,6 +187,17 @@ act_list = {
179
187
  :debug_buf_hex => { :proc => proc { puts "SHA256: " + (Digest::SHA2.hexdigest vma.buf.to_s) },
180
188
  :desc => "Output SHA256 hex digest of curent buffer" },
181
189
 
190
+ :start_autocomplete => { :proc => proc { vma.buf.view.start_autocomplete },
191
+ :desc => "Start autocomplete" },
192
+
193
+ :show_autocomplete => { :proc => proc {
194
+ # vma.buf.view.signal_emit("show-completion")
195
+ # vma.buf.view.show_completion
196
+ vma.buf.view.show_completions
197
+ },
198
+ :desc => "Show autocomplete" },
199
+
200
+
182
201
  }
183
202
 
184
203
  for k, v in act_list
@@ -23,12 +23,13 @@ setcnf :extensions_to_open, [".txt", ".h", ".c", ".cpp", ".hpp", ".rb", ".inc",
23
23
 
24
24
  class State
25
25
  attr_accessor :key_name, :eval_rule, :children, :action, :label, :major_modes, :level, :cursor_type
26
- attr_reader :cur_mode
26
+ attr_reader :cur_mode, :scope
27
27
 
28
- def initialize(key_name, eval_rule = "", ctype = :command)
28
+ def initialize(key_name, eval_rule = "", ctype = :command, scope: :buffer)
29
29
  @key_name = key_name
30
30
  @eval_rule = eval_rule
31
31
  @children = []
32
+ @scope = scope
32
33
  @major_modes = []
33
34
  @action = nil
34
35
  @level = 0
@@ -41,7 +42,7 @@ class State
41
42
  end
42
43
 
43
44
  class KeyBindingTree
44
- attr_accessor :C, :I, :cur_state, :root, :match_state, :last_action, :cur_action, :modifiers, :next_command_count, :method_handles_repeat
45
+ attr_accessor :C, :I, :cur_state, :root, :match_state, :last_action, :cur_action, :modifiers, :next_command_count, :method_handles_repeat, :default_mode
45
46
  attr_reader :mode_root_state, :state_trail, :act_bindings, :default_mode_stack
46
47
 
47
48
  def initialize()
@@ -65,34 +66,62 @@ class KeyBindingTree
65
66
  @act_bindings = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
66
67
  end
67
68
 
68
- def set_default_mode(label)
69
+ def set_mode(label)
69
70
  @match_state = [@modes[label]] # used for matching input
70
71
  @mode_root_state = @modes[label]
71
- @default_mode = label
72
+ # @default_mode = label
72
73
  @default_mode_stack << label
74
+
75
+ __set_mode(label)
73
76
  if !vma.buf.nil?
74
77
  # vma.buf.mode_stack = @default_mode_stack.clone
75
78
  end
76
79
  end
77
80
 
81
+ def set_default_mode(label)
82
+ @match_state = [@modes[label]]
83
+ @mode_root_state = @modes[label]
84
+ @default_mode = label
85
+ set_mode_stack [label]
86
+ end
87
+
78
88
  def set_mode_stack(ms)
89
+ debug "set_mode_stack(#{ms})", 2
90
+ show_caller if cnf.debug? # TODO: remove
79
91
  @default_mode_stack = ms
92
+ label = @default_mode_stack[-1]
93
+ @match_state = [@modes[label]]
94
+ @mode_root_state = @modes[label]
95
+ end
96
+
97
+ def dump_state
98
+ debug "dump_state", 2
99
+ pp ["@default_mode_stack", @default_mode_stack]
100
+ pp ["@default_mode", @default_mode]
101
+ pp ["vma.buf.mode_stack", vma.buf.mode_stack]
102
+ pp ["scope", self.get_scope]
103
+ # pp ["@mode_root_state", @mode_root_state]
104
+ # pp ["@match_state", @match_state]
80
105
  end
81
106
 
82
107
  def set_mode_to_default()
83
108
  # set_mode(@default_mode)
84
- set_mode(@default_mode_stack[-1])
109
+ set_mode_stack [@default_mode_stack[0]]
110
+ __set_mode(@default_mode_stack[0])
85
111
  end
86
112
 
87
113
  def to_previous_mode()
114
+ debug "to_previous_mode",2
115
+ debug @default_mode_stack
88
116
  if @default_mode_stack.size > 1
89
117
  @default_mode_stack.pop
90
118
  end
91
- set_mode_to_default()
119
+ debug @default_mode_stack
120
+ __set_mode(@default_mode_stack[-1])
92
121
  end
93
122
 
94
- def add_mode(id, label, cursortype = :command, name: nil)
95
- mode = State.new(id, "", cursortype)
123
+ def add_mode(id, label, cursortype = :command, name: nil, scope: :buffer)
124
+ mode = State.new(id, "", cursortype, scope: scope)
96
125
  mode.level = 1
97
126
  @modes[label] = mode
98
127
  @root.children << mode
@@ -105,6 +134,10 @@ class KeyBindingTree
105
134
  def add_minor_mode(id, label, major_mode_label)
106
135
  mode = State.new(id)
107
136
  @modes[label] = mode
137
+ if @root.nil?
138
+ show_caller
139
+ Ripl.start :binding => binding
140
+ end
108
141
  @root.children << mode
109
142
  mode.major_modes << major_mode_label
110
143
  end
@@ -166,7 +199,8 @@ class KeyBindingTree
166
199
  vma.gui.statnfo.markup = "<span weight='ultrabold'>#{st}</span>"
167
200
  end
168
201
 
169
- def set_mode(label)
202
+ def __set_mode(label)
203
+ debug "__set_mode(#{label})"
170
204
  @mode_history << @mode_root_state
171
205
 
172
206
  # Check if label in form :label
@@ -183,11 +217,19 @@ class KeyBindingTree
183
217
  end
184
218
  @cur_mode = label
185
219
 
220
+ if self.get_scope != :editor and !vma.buf.nil?
221
+ vma.buf.mode_stack = @default_mode_stack.clone
222
+ end
223
+
186
224
  if !vma.gui.view.nil?
187
225
  vma.gui.view.draw_cursor() #TODO: handle outside this class
188
226
  end
189
227
  end
190
228
 
229
+ def get_scope
230
+ @mode_root_state.scope
231
+ end
232
+
191
233
  def cur_mode_str()
192
234
  return @mode_root_state.key_name
193
235
  end
@@ -410,6 +452,8 @@ class KeyBindingTree
410
452
 
411
453
  def bindkey(key, action)
412
454
  if key.class != Array
455
+ # Handle syntax like :
456
+ # "X esc || X ctrl!" => "vma.kbd.to_previous_mode",
413
457
  key = key.split("||")
414
458
  end
415
459
 
@@ -440,10 +484,19 @@ class KeyBindingTree
440
484
  end
441
485
 
442
486
  m = key.match(/^(\S+)\s(\S.*)$/)
487
+ # Match/split e.g. "VC , , s" to "VC" and ", , s"
443
488
  if m
444
489
  modetmp = m[1]
445
490
  debug [key, modetmp, m].inspect
491
+
492
+ # If all of first word are uppercase, e.g. in
493
+ # "VCIX left" => "buf.move(BACKWARD_CHAR)",
494
+ # interpret as each char representing a mode
446
495
  modes = modetmp.split("") if modetmp.match(/^\p{Lu}+$/) # Uppercase
496
+
497
+ # If all of first word is down case, like in:
498
+ # bindkey "audio space", :audio_stop
499
+ # interpret as whole word representing a mode.
447
500
  modes = [modetmp] if modetmp.match(/^\p{Ll}+$/) # Lowercase
448
501
  keydef = m[2]
449
502
  else
@@ -456,7 +509,15 @@ class KeyBindingTree
456
509
  }
457
510
  end
458
511
 
512
+ # Binds a keyboard key combination to an action,
513
+ # for a given keyboard mode like insert ("I") or command ("C")
459
514
  def mode_bind_key(mode_id, keydef, action)
515
+ # debug "mode_bind_key #{mode_id.inspect}, #{keydef.inspect}, #{action.inspect}", 2
516
+ # Example:
517
+ # bindkey "C , f", :gui_file_finder
518
+ # mode_id = "C", keydef = ", f"
519
+ # and action = :gui_file_finder
520
+
460
521
  set_state(mode_id, "") # TODO: check is ok?
461
522
  start_state = @cur_state
462
523
 
@@ -464,23 +525,32 @@ class KeyBindingTree
464
525
 
465
526
  prev_state = nil
466
527
  s1 = start_state
467
- k_arr.each { |i|
528
+
529
+ k_arr.each_with_index { |k, idx|
468
530
  # check if key has rules for context like q has in
469
531
  # "C q(cntx.recording_macro==true)"
470
- match = /(.+)\((.*)\)/.match(i)
532
+ last_item = false
533
+ if k_arr.size - 1 == idx
534
+ last_item = true
535
+ end
536
+ match = /(.+)\((.*)\)/.match(k)
471
537
  eval_rule = ""
472
538
  if match
473
539
  key_name = match[1]
474
540
  eval_rule = match[2]
475
541
  else
476
- key_name = i
542
+ key_name = k
477
543
  end
478
544
 
479
545
  prev_state = s1
480
546
  # Create a new state for key if it doesn't exist
481
547
  s1 = find_state(key_name, eval_rule)
482
- if s1 == nil
548
+ if s1 == nil or last_item
483
549
  new_state = State.new(key_name, eval_rule)
550
+ if last_item
551
+ # Override existing key definition
552
+ @cur_state.children.delete(s1)
553
+ end
484
554
  s1 = new_state
485
555
  @cur_state.children << new_state
486
556
  end
@@ -4,20 +4,27 @@ vma.kbd.add_mode("V", :visual, :visual)
4
4
  vma.kbd.add_mode("M", :minibuffer) #TODO: needed?
5
5
  vma.kbd.add_mode("R", :readchar)
6
6
  vma.kbd.add_minor_mode("audio", :audio, :command)
7
- vma.kbd.add_mode("B", :browse, :command)
8
- vma.kbd.add_mode("X", :replace, :command, name: "Replace")
7
+ vma.kbd.add_mode("B", :browse, :browse, scope: :editor)
8
+ vma.kbd.add_mode("X", :replace, :replace, name: "Replace")
9
9
  vma.kbd.set_default_mode(:command)
10
- vma.kbd.set_mode(:command)
10
+ vma.kbd.__set_mode(:command) #TODO:needed?
11
+ # cnf.mode.command.cursor.background = "#fc6f03"
12
+ cnf.mode.command.cursor.background = "#05c5a0"
13
+ cnf.mode.default.cursor.background = "#03fcca"
14
+ # cnf.mode.visual.cursor.background = "#10bd8e"
15
+ # cnf.mode.visual.cursor.background = "#e95420"
16
+ # cnf.mode.visual.cursor.background = "#cb3804"
17
+ cnf.mode.visual.cursor.background = "#bc6040"
18
+ cnf.mode.replace.cursor.background = "#fc0331"
19
+ cnf.mode.browse.cursor.background = "#f803fc"
11
20
  # vma.kbd.show_state_trail
12
21
 
13
-
14
22
  bindkey ["VCB M", "B m"], :run_last_macro
15
23
 
16
24
  bindkey "VC s", :easy_jump
17
25
  bindkey "VC , m f", [:find_macro_gui, proc { vma.macro.find_macro_gui }, "Find named macro"]
18
26
  bindkey "C , m n", [:gui_name_macro, proc { vma.macro.gui_name_macro }, "Name last macro"]
19
27
  bindkey "C , j r", :jump_to_random
20
- bindkey "I enter", :insert_new_line
21
28
  bindkey "C , ; s k", :show_key_bindings #TODO: better binding
22
29
  bindkey "C , , c b", :put_file_path_to_clipboard #TODO: better binding or remove?
23
30
  bindkey "C , , e", :encrypt_file #TODO: better binding
@@ -58,7 +65,7 @@ bindkey "audio f || audio right", [:audio_forward, proc { Audio.seek_forward },
58
65
  bindkey "audio left", [:audio_backward, proc { Audio.seek_forward(-5.0) }, "Seek backward in audio stream"]
59
66
 
60
67
  bindkey "audio space", :audio_stop
61
- bindkey "audio q || audio esc", "vma.kbd.set_mode_to_default"
68
+ bindkey "audio q || audio esc", "vma.kbd.to_previous_mode"
62
69
 
63
70
  # bindkey "C , f o", :open_file_dialog
64
71
  bindkey "CI ctrl-o", :open_file_dialog
@@ -79,8 +86,9 @@ bindkey "B z", "center_on_current_line();call_action(:exit_browse_mode)"
79
86
  bindkey "B enter || B return || B esc || B j || B ctrl!", :exit_browse_mode
80
87
  bindkey "B s", :page_up
81
88
  bindkey "B d", :page_down
82
- bindkey "B s", :page_up
83
- bindkey "B d", :page_down
89
+ bindkey "B r", proc { vma.gui.page_down(multip:0.25)}
90
+ bindkey "B e", proc { vma.gui.page_up(multip:0.25)}
91
+
84
92
  bindkey "B i", :jump_to_start_of_buffer
85
93
  bindkey "B o", :jump_to_end_of_buffer
86
94
  bindkey "B c", :close_current_buffer
@@ -105,7 +113,7 @@ default_keys = {
105
113
  "C ctrl-s" => :buf_save,
106
114
 
107
115
  # Buffer handling
108
- "C B" => "bufs.switch",
116
+ # "C B" => "bufs.switch",
109
117
  "C tab" => "bufs.switch_to_last_buf",
110
118
  # 'C , s'=> 'gui_select_buffer',
111
119
  "C , r v b" => :buf_revert,
@@ -117,11 +125,22 @@ default_keys = {
117
125
  # MOVING
118
126
  # 'VC h' => 'buf.move(BACKWARD_CHAR)',
119
127
  "VC l" => "buf.move(FORWARD_CHAR)",
120
- "VC j" => "buf.move(FORWARD_LINE)",
121
- "VC k" => "buf.move(BACKWARD_LINE)",
128
+ # "VC j" => "buf.move(FORWARD_LINE)",
129
+ # "VC k" => "buf.move(BACKWARD_LINE)",
130
+
131
+ "VC pagedown" => :page_down,
132
+ "VC pageup" => :page_up,
122
133
 
123
- "VC pagedown" => "page_down",
124
- "VC pageup" => "page_up",
134
+ "I down(vma.buf.view.autocp_active)" => "vma.buf.view.autocp_select_next",
135
+ "I tab(vma.buf.view.autocp_active)" => "vma.buf.view.autocp_select_next",
136
+ "I up(vma.buf.view.autocp_active)" => "vma.buf.view.autocp_select_previous",
137
+ "I shift-tab(vma.buf.view.autocp_active)" => "vma.buf.view.autocp_select_previous",
138
+ "I enter(vma.buf.view.autocp_active)" => "vma.buf.view.autocp_select",
139
+
140
+ "I tab" => 'buf.insert_tab',
141
+ "I shift-tab" => 'buf.unindent',
142
+
143
+ "I enter" => :insert_new_line,
125
144
 
126
145
  "VCIX left" => "buf.move(BACKWARD_CHAR)",
127
146
  "VCIX right" => "buf.move(FORWARD_CHAR)",
@@ -172,6 +191,7 @@ default_keys = {
172
191
  "C , d b" => "debug_print_buffer",
173
192
  "C , d c" => "debug_dump_clipboard",
174
193
  "C , d d" => "debug_dump_deltas",
194
+ "C , d m" => :kbd_dump_state,
175
195
 
176
196
  "VC O" => "buf.jump(END_OF_LINE)",
177
197
  "VC $" => "buf.jump(END_OF_LINE)",
@@ -189,7 +209,6 @@ default_keys = {
189
209
 
190
210
  # Command mode only:
191
211
  "C ctrl-r" => "buf.redo()", # TODO:???
192
- "C R" => "buf.redo()",
193
212
  "C v" => "buf.start_visual_mode",
194
213
  "C P" => "buf.paste(BEFORE)", # TODO: implement as replace for visual mode
195
214
  "C space <char>" => "buf.insert_txt(<char>)",
@@ -246,16 +265,13 @@ default_keys = {
246
265
  'CV \' <char>' => "buf.jump_to_mark(<char>)",
247
266
  # "CV ''" =>'jump_to_mark(NEXT_MARK)', #TODO
248
267
 
249
- # Switch to other mode
268
+ # Switch to another mode
250
269
  "C i" => "vma.kbd.set_mode(:insert)",
251
270
  "C R" => "vma.kbd.set_mode(:replace)",
252
271
  "C ctrl!" => "vma.kbd.set_mode(:insert)",
253
- "C ctrl!" => "vma.kbd.set_mode(:insert)",
254
272
 
255
-
256
- # "R esc || R ctrl!" => "vma.kbd.set_mode(:command)",
257
- "X esc" => "vma.kbd.set_mode(:command)",
258
- "X ctrl!" => "vma.kbd.set_mode(:command)",
273
+ # Replace mode
274
+ "X esc || X ctrl!" => "vma.kbd.to_previous_mode",
259
275
  "X <char>" => "buf.replace_with_char(<char>);buf.move(FORWARD_CHAR)",
260
276
 
261
277
  # Macros
@@ -280,7 +296,7 @@ default_keys = {
280
296
  # "I ctrl!" => "vma.kbd.to_previous_mode",
281
297
  "C shift!" => "buf.save",
282
298
  "I <char>" => "buf.insert_txt(<char>)",
283
- "I esc || I ctrl!" => "vma.kbd.set_mode_to_default",
299
+ "I esc || I ctrl!" => "vma.kbd.to_previous_mode",
284
300
 
285
301
  "I ctrl-d" => "buf.delete2(:to_word_end)",
286
302
 
@@ -294,12 +310,17 @@ default_keys = {
294
310
  "IX alt-f" => "buf.jump_word(FORWARD,WORD_START)",
295
311
  "IX alt-b" => "buf.jump_word(BACKWARD,WORD_START)",
296
312
 
297
- "I tab" => 'buf.insert_tab',
298
- "I shift-tab" => 'buf.unindent',
313
+ "I ctrl-h" => :show_autocomplete,
314
+ "I ctrl-j" => "vma.buf.view.hide_completions",
315
+
316
+
299
317
  "I space" => 'buf.insert_txt(" ")',
300
318
  # "I return" => 'buf.insert_new_line()',
301
319
  }
302
320
 
321
+ bindkey "C , i p", "generate_password_to_buf(15)"
322
+
323
+
303
324
  default_keys.each { |key, value|
304
325
  bindkey(key, value)
305
326
  }
@@ -19,13 +19,31 @@ class LangSrv
19
19
 
20
20
  def initialize(lang)
21
21
  @error = true
22
- clsp = conf(:custom_lsp)
23
22
 
24
23
  # Use LSP server specified by user if available
25
24
  @lang = lang
26
- lspconf = clsp[lang]
25
+
26
+ lspconf = nil
27
+ ret = cnf.lsp.server?.find { |k, v| v[:languages].include?(@lang) }
28
+ lspconf = ret[1] unless ret.nil?
29
+
27
30
  if !lspconf.nil?
28
- @io = IO.popen(lspconf[:command], "r+")
31
+ error = false
32
+ begin
33
+ @io = IO.popen(lspconf[:command], "r+")
34
+ rescue Errno::ENOENT => e
35
+ pp e
36
+ error = true
37
+ rescue StandardError => e
38
+ debug "StandardError @io = IO.popen(lspconf[:command] ...", 2
39
+ pp e
40
+ error = true
41
+ end
42
+ if error or @io.nil?
43
+ message("Could not start lsp server #{lspconf[:name]}")
44
+ error = true
45
+ return nil
46
+ end
29
47
  else
30
48
  return nil
31
49
  end
@@ -37,6 +55,8 @@ class LangSrv
37
55
  for c in conf(:workspace_folders)
38
56
  wf << LSP::Interface::WorkspaceFolder.new(uri: c[:uri], name: c[:name])
39
57
  end
58
+ debug "WORKSPACE FOLDERS", 2
59
+ debug wf.inspect, 2
40
60
 
41
61
  pid = Process.pid
42
62
 
data/lib/vimamsa/main.rb CHANGED
@@ -32,6 +32,10 @@ def buf()
32
32
  return vma.buf
33
33
  end
34
34
 
35
+ def hook
36
+ return vma.hook
37
+ end
38
+
35
39
  def bufs()
36
40
  return vma.buffers
37
41
  end
data/lib/vimamsa/rbvma.rb CHANGED
@@ -32,6 +32,7 @@ require "vimamsa/gui_menu"
32
32
  require "vimamsa/gui_dialog"
33
33
  require "vimamsa/gui_select_window"
34
34
  require "vimamsa/gui_sourceview"
35
+ require "vimamsa/gui_sourceview_autocomplete"
35
36
  require "vimamsa/gui_image"
36
37
  require "vimamsa/hyper_plain_text"
37
38
 
@@ -39,6 +40,7 @@ require "vimamsa/ack"
39
40
  require "vimamsa/buffer"
40
41
  require "vimamsa/buffer_cursor"
41
42
  require "vimamsa/buffer_changetext"
43
+ # require "vimamsa/buffer_list"
42
44
  require "vimamsa/buffer_list"
43
45
  require "vimamsa/buffer_manager"
44
46
  require "vimamsa/constants"