vimamsa 0.1.10 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -3
- data/custom_example.rb +11 -1
- data/demo.txt +2 -2
- data/exe/vimamsa +1 -4
- data/lib/vimamsa/ack.rb +57 -9
- data/lib/vimamsa/actions.rb +1 -1
- data/lib/vimamsa/buffer.rb +270 -45
- data/lib/vimamsa/buffer_list.rb +57 -16
- data/lib/vimamsa/buffer_manager.rb +21 -4
- data/lib/vimamsa/conf.rb +10 -1
- data/lib/vimamsa/debug.rb +7 -3
- data/lib/vimamsa/easy_jump.rb +10 -6
- data/lib/vimamsa/editor.rb +57 -43
- data/lib/vimamsa/file_finder.rb +69 -71
- data/lib/vimamsa/file_history.rb +2 -3
- data/lib/vimamsa/file_manager.rb +1 -1
- data/lib/vimamsa/form_generator.rb +122 -0
- data/lib/vimamsa/gui.rb +518 -180
- data/lib/vimamsa/gui_image.rb +12 -6
- data/lib/vimamsa/gui_menu.rb +29 -20
- data/lib/vimamsa/gui_select_window.rb +40 -21
- data/lib/vimamsa/gui_sourceview.rb +264 -86
- data/lib/vimamsa/hyper_plain_text.rb +34 -1
- data/lib/vimamsa/key_actions.rb +13 -1
- data/lib/vimamsa/key_binding_tree.rb +26 -14
- data/lib/vimamsa/key_bindings_vimlike.rb +56 -26
- data/lib/vimamsa/langservp.rb +172 -0
- data/lib/vimamsa/macro.rb +9 -8
- data/lib/vimamsa/main.rb +0 -1
- data/lib/vimamsa/rbvma.rb +7 -4
- data/lib/vimamsa/search.rb +2 -1
- data/lib/vimamsa/search_replace.rb +36 -106
- data/lib/vimamsa/util.rb +55 -1
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa.rb +1 -6
- data/styles/molokai_edit.xml +3 -0
- data/vimamsa.gemspec +10 -10
- metadata +24 -22
@@ -36,15 +36,17 @@ setcnf :indent_based_on_last_line, true
|
|
36
36
|
setcnf :extensions_to_open, [".txt", ".h", ".c", ".cpp", ".hpp", ".rb", ".inc", ".php", ".sh", ".m", ".gd", ".js"]
|
37
37
|
|
38
38
|
class State
|
39
|
-
attr_accessor :key_name, :eval_rule, :children, :action, :label, :major_modes, :level
|
39
|
+
attr_accessor :key_name, :eval_rule, :children, :action, :label, :major_modes, :level, :cursor_type
|
40
|
+
attr_reader :cur_mode
|
40
41
|
|
41
|
-
def initialize(key_name, eval_rule = "")
|
42
|
+
def initialize(key_name, eval_rule = "", ctype = :command)
|
42
43
|
@key_name = key_name
|
43
44
|
@eval_rule = eval_rule
|
44
45
|
@children = []
|
45
46
|
@major_modes = []
|
46
47
|
@action = nil
|
47
48
|
@level = 0
|
49
|
+
@cursor_type = ctype
|
48
50
|
end
|
49
51
|
|
50
52
|
def to_s()
|
@@ -53,7 +55,7 @@ class State
|
|
53
55
|
end
|
54
56
|
|
55
57
|
class KeyBindingTree
|
56
|
-
attr_accessor :C, :I, :cur_state, :root, :match_state, :last_action, :cur_action
|
58
|
+
attr_accessor :C, :I, :cur_state, :root, :match_state, :last_action, :cur_action, :modifiers
|
57
59
|
attr_reader :mode_root_state, :state_trail, :act_bindings
|
58
60
|
|
59
61
|
def initialize()
|
@@ -66,7 +68,7 @@ class KeyBindingTree
|
|
66
68
|
@last_action = nil
|
67
69
|
@cur_action = nil
|
68
70
|
|
69
|
-
@modifiers =
|
71
|
+
@modifiers = { :ctrl => false, :shift => false, :alt => false } # TODO: create a queue
|
70
72
|
@last_event = [nil, nil, nil, nil, nil]
|
71
73
|
|
72
74
|
@override_keyhandling_callback = nil
|
@@ -84,9 +86,8 @@ class KeyBindingTree
|
|
84
86
|
set_mode(@default_mode)
|
85
87
|
end
|
86
88
|
|
87
|
-
|
88
|
-
|
89
|
-
mode = State.new(id)
|
89
|
+
def add_mode(id, label, cursortype = :command, name: nil)
|
90
|
+
mode = State.new(id, "", cursortype)
|
90
91
|
mode.level = 1
|
91
92
|
@modes[label] = mode
|
92
93
|
@root.children << mode
|
@@ -95,6 +96,7 @@ class KeyBindingTree
|
|
95
96
|
end
|
96
97
|
end
|
97
98
|
|
99
|
+
# Add keyboard key binding mode based on another mode
|
98
100
|
def add_minor_mode(id, label, major_mode_label)
|
99
101
|
mode = State.new(id)
|
100
102
|
@modes[label] = mode
|
@@ -103,7 +105,7 @@ class KeyBindingTree
|
|
103
105
|
end
|
104
106
|
|
105
107
|
def clear_modifiers()
|
106
|
-
@modifiers = []
|
108
|
+
# @modifiers = [] #TODO:remove?
|
107
109
|
end
|
108
110
|
|
109
111
|
def find_state(key_name, eval_rule)
|
@@ -174,14 +176,27 @@ class KeyBindingTree
|
|
174
176
|
end
|
175
177
|
end
|
176
178
|
end
|
179
|
+
@cur_mode = label
|
180
|
+
|
181
|
+
if !vma.gui.view.nil?
|
182
|
+
vma.gui.view.draw_cursor() #TODO: handle outside this class
|
177
183
|
|
178
|
-
|
184
|
+
# Ripl.start :binding => binding
|
185
|
+
end
|
179
186
|
end
|
180
187
|
|
181
188
|
def cur_mode_str()
|
182
189
|
return @mode_root_state.key_name
|
183
190
|
end
|
184
191
|
|
192
|
+
def get_cursor_type
|
193
|
+
@mode_root_state.cursor_type
|
194
|
+
end
|
195
|
+
|
196
|
+
def get_mode
|
197
|
+
return @cur_mode
|
198
|
+
end
|
199
|
+
|
185
200
|
def set_state(key_name, eval_rule = "")
|
186
201
|
new_state = find_state(key_name, eval_rule)
|
187
202
|
if new_state != nil
|
@@ -201,8 +216,6 @@ class KeyBindingTree
|
|
201
216
|
end
|
202
217
|
|
203
218
|
@state_trail = [@mode_root_state]
|
204
|
-
# debug get_state_trail_str()
|
205
|
-
# $next_command_count = nil # TODO: set somewhere else?
|
206
219
|
end
|
207
220
|
|
208
221
|
# Print key bindings to show as documentation or for debugging
|
@@ -274,8 +287,7 @@ class KeyBindingTree
|
|
274
287
|
# if yes, change state to child
|
275
288
|
# if no, go back to root
|
276
289
|
def match_key_conf(c, translated_c, event_type)
|
277
|
-
|
278
|
-
print "MATCH KEY CONF: #{[c, translated_c]}" if $debug
|
290
|
+
debug "MATCH KEY CONF: #{[c, translated_c]}"
|
279
291
|
|
280
292
|
if !@override_keyhandling_callback.nil?
|
281
293
|
ret = @override_keyhandling_callback.call(c, event_type)
|
@@ -333,7 +345,7 @@ class KeyBindingTree
|
|
333
345
|
end
|
334
346
|
|
335
347
|
if new_state == nil
|
336
|
-
|
348
|
+
debug("NO MATCH")
|
337
349
|
if event_type == :key_press and c != "shift"
|
338
350
|
# TODO:include other modifiers in addition to shift?
|
339
351
|
set_state_to_root
|
@@ -1,3 +1,14 @@
|
|
1
|
+
vma.kbd.add_mode("C", :command)
|
2
|
+
vma.kbd.add_mode("I", :insert, :insert)
|
3
|
+
vma.kbd.add_mode("V", :visual, :visual)
|
4
|
+
vma.kbd.add_mode("M", :minibuffer) #TODO: needed?
|
5
|
+
vma.kbd.add_mode("R", :readchar)
|
6
|
+
vma.kbd.add_mode("B", :browse, :command)
|
7
|
+
vma.kbd.add_mode("X", :replace, :command, name: "Replace")
|
8
|
+
vma.kbd.set_default_mode(:command)
|
9
|
+
vma.kbd.set_mode(:command)
|
10
|
+
vma.kbd.show_state_trail
|
11
|
+
|
1
12
|
bindkey ["VCB M", "B m"], :run_last_macro
|
2
13
|
|
3
14
|
bindkey "VC s", :easy_jump
|
@@ -15,6 +26,11 @@ bindkey "C x", :delete_char_forward
|
|
15
26
|
bindkey "C , , l t", :load_theme
|
16
27
|
bindkey "C , f", :gui_file_finder
|
17
28
|
bindkey "C , h", :gui_file_history_finder
|
29
|
+
bindkey "C , z", :gui_file_finder
|
30
|
+
|
31
|
+
bindkey "C ` k", :lsp_debug
|
32
|
+
bindkey "C ` j", :lsp_jump_to_definition
|
33
|
+
|
18
34
|
bindkey "C , r r", :gui_search_replace
|
19
35
|
bindkey "V , r r", :gui_search_replace
|
20
36
|
bindkey "V , t b", :set_style_bold
|
@@ -30,11 +46,15 @@ bindkey "C , t b", :set_line_style_bold
|
|
30
46
|
bindkey "C , t t", :set_line_style_title
|
31
47
|
bindkey "C , t c", :clear_line_styles
|
32
48
|
bindkey "C , b", :start_buf_manager
|
49
|
+
bindkey "C , w", :toggle_active_window
|
50
|
+
bindkey "C , , w", :toggle_two_column
|
51
|
+
|
33
52
|
# bindkey "C , f o", :open_file_dialog
|
34
53
|
bindkey "CI ctrl-o", :open_file_dialog
|
35
54
|
# bindkey "M enter", :minibuffer_end
|
36
55
|
bindkey "C , a", :ack_search
|
37
|
-
bindkey "C d w", :
|
56
|
+
bindkey "C d w", :delete_to_next_word_start
|
57
|
+
|
38
58
|
bindkey "C d 0", :delete_to_line_start
|
39
59
|
bindkey "C , , f", :file_finder
|
40
60
|
bindkey "VC h", :e_move_backward_char
|
@@ -55,7 +75,7 @@ bindkey "B c", :close_current_buffer
|
|
55
75
|
bindkey "B ;", "buf.jump_to_last_edit"
|
56
76
|
bindkey "B q", :jump_to_last_edit
|
57
77
|
bindkey "B w", :jump_to_next_edit
|
58
|
-
bindkey "C , d", :diff_buffer
|
78
|
+
# bindkey "C , d", :diff_buffer
|
59
79
|
bindkey "C , g", :invoke_grep_search
|
60
80
|
#bindkey 'C , g', proc{invoke_grep_search}
|
61
81
|
bindkey "C , v", :auto_indent_buffer
|
@@ -66,6 +86,7 @@ bindkey "C d d", [:delete_line, proc { buf.delete_line }, "Delete current line"]
|
|
66
86
|
bindkey "C enter || C return", [:line_action, proc { buf.handle_line_action() }, "Line action"]
|
67
87
|
bindkey "C p", [:paste_after, proc { buf.paste(AFTER) }, ""] # TODO: implement as replace for visual mode
|
68
88
|
bindkey "V d", [:delete_selection, proc { buf.delete(SELECTION) }, ""]
|
89
|
+
bindkey "V a d", [:delete_append_selection, proc { buf.delete(SELECTION, :append) }, "Delete and append selection"]
|
69
90
|
|
70
91
|
default_keys = {
|
71
92
|
|
@@ -78,7 +99,7 @@ default_keys = {
|
|
78
99
|
# 'C , s'=> 'gui_select_buffer',
|
79
100
|
"C , r v b" => :buf_revert,
|
80
101
|
"C , c b" => "bufs.close_current_buffer",
|
81
|
-
#"C , b" => '
|
102
|
+
#"C , b" => 'vma.kbd.set_mode("S");gui_select_buffer',
|
82
103
|
"C , n b" => :buf_new,
|
83
104
|
# "C , , ." => "backup_all_buffers()",
|
84
105
|
"VC , , s" => :search_actions,
|
@@ -92,10 +113,10 @@ default_keys = {
|
|
92
113
|
"VC pagedown" => "page_down",
|
93
114
|
"VC pageup" => "page_up",
|
94
115
|
|
95
|
-
"
|
96
|
-
"
|
97
|
-
"
|
98
|
-
"
|
116
|
+
"VCIX left" => "buf.move(BACKWARD_CHAR)",
|
117
|
+
"VCIX right" => "buf.move(FORWARD_CHAR)",
|
118
|
+
"VCIX down" => "buf.move(FORWARD_LINE)",
|
119
|
+
"VCIX up" => "buf.move(BACKWARD_LINE)",
|
99
120
|
|
100
121
|
"VC w" => "buf.jump_word(FORWARD,WORD_START)",
|
101
122
|
"VC b" => "buf.jump_word(BACKWARD,WORD_START)",
|
@@ -131,11 +152,11 @@ default_keys = {
|
|
131
152
|
"C n" => "$search.jump_to_next()",
|
132
153
|
"C N" => "$search.jump_to_previous()",
|
133
154
|
|
134
|
-
|
135
155
|
"C C" => :content_search,
|
136
156
|
|
137
157
|
# Debug
|
138
158
|
"C , d r p" => "start_ripl",
|
159
|
+
"C , d o" => "vma.gui.clear_overlay",
|
139
160
|
"C , D" => "debug_print_buffer",
|
140
161
|
"C , c s" => "bufs.close_scrap_buffers",
|
141
162
|
"C , d b" => "debug_print_buffer",
|
@@ -144,11 +165,11 @@ default_keys = {
|
|
144
165
|
"VC O" => "buf.jump(END_OF_LINE)",
|
145
166
|
"VC $" => "buf.jump(END_OF_LINE)",
|
146
167
|
|
147
|
-
"C o" => 'buf.jump(END_OF_LINE);buf.insert_txt("\n")
|
168
|
+
"C o" => 'buf.jump(END_OF_LINE);buf.insert_txt("\n");vma.kbd.set_mode(:insert)',
|
148
169
|
"C X" => 'buf.jump(END_OF_LINE);buf.insert_txt("\n");',
|
149
|
-
"C A" => "buf.jump(END_OF_LINE)
|
150
|
-
"C I" => "buf.jump(FIRST_NON_WHITESPACE)
|
151
|
-
"C a" => "buf.move(FORWARD_CHAR)
|
170
|
+
"C A" => "buf.jump(END_OF_LINE);vma.kbd.set_mode(:insert)",
|
171
|
+
"C I" => "buf.jump(FIRST_NON_WHITESPACE);vma.kbd.set_mode(:insert)",
|
172
|
+
"C a" => "buf.move(FORWARD_CHAR);vma.kbd.set_mode(:insert)",
|
152
173
|
"C J" => "buf.join_lines()",
|
153
174
|
"C u" => "buf.undo()",
|
154
175
|
|
@@ -197,7 +218,7 @@ default_keys = {
|
|
197
218
|
"V g c" => :selection_capitalize,
|
198
219
|
"V g s" => :selection_swapcase,
|
199
220
|
"V g r" => :selection_reverse,
|
200
|
-
|
221
|
+
|
201
222
|
"VC j" => :forward_line,
|
202
223
|
"VC k" => :backward_line,
|
203
224
|
|
@@ -213,8 +234,17 @@ default_keys = {
|
|
213
234
|
'CV \' <char>' => "buf.jump_to_mark(<char>)",
|
214
235
|
# "CV ''" =>'jump_to_mark(NEXT_MARK)', #TODO
|
215
236
|
|
216
|
-
|
217
|
-
"C
|
237
|
+
# Switch to other mode
|
238
|
+
"C i" => "vma.kbd.set_mode(:insert)",
|
239
|
+
"C R" => "vma.kbd.set_mode(:replace)",
|
240
|
+
"C ctrl!" => "vma.kbd.set_mode(:insert)",
|
241
|
+
"C ctrl!" => "vma.kbd.set_mode(:insert)",
|
242
|
+
|
243
|
+
|
244
|
+
# "R esc || R ctrl!" => "vma.kbd.set_mode(:command)",
|
245
|
+
"X esc" => "vma.kbd.set_mode(:command)",
|
246
|
+
"X ctrl!" => "vma.kbd.set_mode(:command)",
|
247
|
+
"X <char>" => "buf.replace_with_char(<char>);buf.move(FORWARD_CHAR)",
|
218
248
|
|
219
249
|
# Macros
|
220
250
|
# (experimental, may not work correctly)
|
@@ -235,22 +265,22 @@ default_keys = {
|
|
235
265
|
# "CV Q" => :quit,
|
236
266
|
"CV ctrl-q" => :quit,
|
237
267
|
"CV , R" => "restart_application",
|
238
|
-
"I ctrl!" => "
|
268
|
+
"I ctrl!" => "vma.kbd.set_mode(:command)",
|
239
269
|
"C shift!" => "buf.save",
|
240
270
|
"I <char>" => "buf.insert_txt(<char>)",
|
241
|
-
"I esc" => "
|
271
|
+
"I esc" => "vma.kbd.set_mode(:command)",
|
242
272
|
|
243
273
|
"I ctrl-d" => "buf.delete2(:to_word_end)",
|
244
274
|
|
245
|
-
#
|
246
|
-
"
|
247
|
-
"
|
248
|
-
"
|
249
|
-
"
|
250
|
-
"
|
251
|
-
"
|
252
|
-
"
|
253
|
-
"
|
275
|
+
# Insert and Replace modes: Moving
|
276
|
+
"IX ctrl-a" => "buf.jump(BEGINNING_OF_LINE)",
|
277
|
+
"IX ctrl-b" => "buf.move(BACKWARD_CHAR)",
|
278
|
+
"IX ctrl-f" => "buf.move(FORWARD_CHAR)",
|
279
|
+
"IX ctrl-n" => "buf.move(FORWARD_LINE)",
|
280
|
+
"IX ctrl-p" => "buf.move(BACKWARD_LINE)",
|
281
|
+
"IX ctrl-e" => "buf.jump(END_OF_LINE)", # context: mode:I, buttons down: {C}
|
282
|
+
"IX alt-f" => "buf.jump_word(FORWARD,WORD_START)",
|
283
|
+
"IX alt-b" => "buf.jump_word(BACKWARD,WORD_START)",
|
254
284
|
|
255
285
|
"I tab" => 'buf.insert_txt(" ")',
|
256
286
|
"I space" => 'buf.insert_txt(" ")',
|
@@ -0,0 +1,172 @@
|
|
1
|
+
require "language_server-protocol"
|
2
|
+
LSP = LanguageServer::Protocol
|
3
|
+
|
4
|
+
class LangSrv
|
5
|
+
@@languages = {}
|
6
|
+
attr_accessor :error
|
7
|
+
|
8
|
+
def self.get(lang)
|
9
|
+
if @@languages[lang].nil?
|
10
|
+
@@languages[lang] = LangSrv.new(lang)
|
11
|
+
@@languages[lang] = nil if @@languages[lang].error
|
12
|
+
end
|
13
|
+
return @@languages[lang]
|
14
|
+
end
|
15
|
+
|
16
|
+
def new_id()
|
17
|
+
return @id += 1
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(lang)
|
21
|
+
@error = true
|
22
|
+
clsp = conf(:custom_lsp)
|
23
|
+
|
24
|
+
# Use LSP server specified by user if available
|
25
|
+
@lang = lang
|
26
|
+
lspconf = clsp[lang]
|
27
|
+
if !lspconf.nil?
|
28
|
+
@io = IO.popen(lspconf[:command], "r+")
|
29
|
+
else
|
30
|
+
return nil
|
31
|
+
end
|
32
|
+
@writer = LSP::Transport::Io::Writer.new(@io)
|
33
|
+
@reader = LSP::Transport::Io::Reader.new(@io)
|
34
|
+
@id = 0
|
35
|
+
|
36
|
+
wf = []
|
37
|
+
for c in conf(:workspace_folders)
|
38
|
+
wf << LSP::Interface::WorkspaceFolder.new(uri: c[:uri], name: c[:name])
|
39
|
+
end
|
40
|
+
|
41
|
+
pid = Process.pid
|
42
|
+
|
43
|
+
if lspconf[:name] == "phpactor"
|
44
|
+
initp = LSP::Interface::InitializeParams.new(
|
45
|
+
process_id: pid,
|
46
|
+
root_uri: lspconf[:rooturi],
|
47
|
+
workspace_folders: wf,
|
48
|
+
capabilities: { 'workspace': { 'workspaceFolders': true } },
|
49
|
+
)
|
50
|
+
else
|
51
|
+
initp = LSP::Interface::InitializeParams.new(
|
52
|
+
process_id: pid,
|
53
|
+
root_uri: "null",
|
54
|
+
workspace_folders: wf,
|
55
|
+
capabilities: { 'workspace': { 'workspaceFolders': true } },
|
56
|
+
)
|
57
|
+
end
|
58
|
+
@resp = {}
|
59
|
+
|
60
|
+
@writer.write(id: new_id, params: initp, method: "initialize")
|
61
|
+
|
62
|
+
@lst = Thread.new {
|
63
|
+
@reader.read do |r|
|
64
|
+
@resp[r[:id]] = r
|
65
|
+
pp r
|
66
|
+
# exit
|
67
|
+
end
|
68
|
+
}
|
69
|
+
@error = false
|
70
|
+
end
|
71
|
+
|
72
|
+
def handle_delta(delta, fpath, version)
|
73
|
+
fpuri = URI.join("file:///", fpath).to_s
|
74
|
+
|
75
|
+
# delta[0]: char position
|
76
|
+
# delta[1]: INSERT or DELETE
|
77
|
+
# delta[2]: number of chars affected
|
78
|
+
# delta[3]: text to add in case of insert
|
79
|
+
|
80
|
+
changes = nil
|
81
|
+
if delta[1] == INSERT
|
82
|
+
changes = [{ 'rangeLength': 0, 'range': { 'start': { 'line': delta[4][0], 'character': delta[4][1] }, 'end': { 'line': delta[4][0], 'character': delta[4][1] } }, 'text': delta[3] }]
|
83
|
+
elsif delta[1] == DELETE
|
84
|
+
changes = [{ 'rangeLength': delta[2], 'range': { 'start': { 'line': delta[4][0], 'character': delta[4][1] }, 'end': { 'line': delta[5][0], 'character': delta[5][1] } }, 'text': "" }]
|
85
|
+
end
|
86
|
+
debug changes.inspect, 2
|
87
|
+
|
88
|
+
if !changes.nil?
|
89
|
+
a = LSP::Interface::DidChangeTextDocumentParams.new(
|
90
|
+
text_document: LSP::Interface::VersionedTextDocumentIdentifier.new(uri: fpuri, version: version),
|
91
|
+
content_changes: changes,
|
92
|
+
)
|
93
|
+
id = new_id
|
94
|
+
pp a
|
95
|
+
@writer.write(id: id, params: a, method: "textDocument/didChange")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def wait_for_response(id)
|
100
|
+
t = Time.now
|
101
|
+
debug "Waiting for response id:#{id}"
|
102
|
+
while @resp[id].nil?
|
103
|
+
sleep 0.03
|
104
|
+
if Time.now - t > 5
|
105
|
+
debug "Timeout LSP call id:#{id}"
|
106
|
+
return nil
|
107
|
+
end
|
108
|
+
end
|
109
|
+
debug "End waiting id:#{id}"
|
110
|
+
return @resp[id]
|
111
|
+
end
|
112
|
+
|
113
|
+
def add_workspaces() # TODO
|
114
|
+
# https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_workspaceFolders
|
115
|
+
debug "Add workspaces", 2
|
116
|
+
a = [LSP::Interface::WorkspaceFolder.new(uri: "file:///...", name: "vimamsa")]
|
117
|
+
id = new_id
|
118
|
+
# @writer.write(id: id, params: a, method: "textDocument/definition")
|
119
|
+
# @writer.write(id: id, params: a, method: "workspace/workspaceFolders")
|
120
|
+
@writer.write(id: id, params: a, method: "workspace/didChangeWorkspaceFolders")
|
121
|
+
r = wait_for_response(id)
|
122
|
+
pp r
|
123
|
+
end
|
124
|
+
|
125
|
+
def handle_responses()
|
126
|
+
#TODO
|
127
|
+
# r = @resp.delete_at(0)
|
128
|
+
end
|
129
|
+
|
130
|
+
def get_definition(fpuri, lpos, cpos)
|
131
|
+
a = LSP::Interface::DefinitionParams.new(
|
132
|
+
position: LSP::Interface::Position.new(line: lpos, character: cpos),
|
133
|
+
text_document: LSP::Interface::TextDocumentIdentifier.new(uri: fpuri),
|
134
|
+
)
|
135
|
+
id = new_id
|
136
|
+
pp a
|
137
|
+
@writer.write(id: id, params: a, method: "textDocument/definition")
|
138
|
+
r = wait_for_response(id)
|
139
|
+
return nil if r.nil?
|
140
|
+
# Ripl.start :binding => binding
|
141
|
+
pp r
|
142
|
+
line = HSafe.new(r)[:result][0][:range][:start][:line].val
|
143
|
+
uri = HSafe.new(r)[:result][0][:uri].val
|
144
|
+
|
145
|
+
if !uri.nil? and !line.nil?
|
146
|
+
puts "LINE:" + line.to_s
|
147
|
+
puts "URI:" + uri
|
148
|
+
fpath = URI.parse(uri).path
|
149
|
+
line = line + 1
|
150
|
+
return [fpath, line]
|
151
|
+
end
|
152
|
+
|
153
|
+
return nil
|
154
|
+
end
|
155
|
+
|
156
|
+
def open_file(fp, fc = nil)
|
157
|
+
debug "open_file", 2
|
158
|
+
fc = IO.read(fp) if fc.nil?
|
159
|
+
fpuri = URI.join("file:///", fp).to_s
|
160
|
+
|
161
|
+
a = LSP::Interface::DidOpenTextDocumentParams.new(
|
162
|
+
text_document: LSP::Interface::TextDocumentItem.new(
|
163
|
+
uri: fpuri,
|
164
|
+
text: fc,
|
165
|
+
language_id: "c++",
|
166
|
+
version: 1,
|
167
|
+
),
|
168
|
+
)
|
169
|
+
|
170
|
+
@writer.write(method: "textDocument/didOpen", params: a)
|
171
|
+
end
|
172
|
+
end
|
data/lib/vimamsa/macro.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
def gui_find_macro_update_callback(search_str = "")
|
3
2
|
debug "gui_find_macro_update_callback: #{search_str}"
|
4
3
|
heystack = $macro.named_macros
|
@@ -24,7 +23,7 @@ def gui_find_macro_select_callback(search_str, idx)
|
|
24
23
|
end
|
25
24
|
|
26
25
|
class Macro
|
27
|
-
|
26
|
+
attr_reader :running_macro
|
28
27
|
attr_accessor :recorded_macros, :recording, :named_macros, :last_macro
|
29
28
|
|
30
29
|
def initialize()
|
@@ -33,11 +32,12 @@ class Macro
|
|
33
32
|
@current_recording = []
|
34
33
|
@current_name = nil
|
35
34
|
@last_macro = "a"
|
35
|
+
@running_macro = false
|
36
36
|
|
37
37
|
#TODO:
|
38
38
|
@recorded_macros = vma.marshal_load("macros", {})
|
39
39
|
@named_macros = vma.marshal_load("named_macros", {})
|
40
|
-
|
40
|
+
vma.hook.register(:shutdown, self.method("save"))
|
41
41
|
end
|
42
42
|
|
43
43
|
def save()
|
@@ -52,15 +52,13 @@ class Macro
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def find_macro_gui()
|
55
|
-
# Ripl.start :binding => binding
|
56
|
-
|
57
55
|
l = $macro.named_macros.keys.sort.collect { |x| [x, 0] }
|
58
56
|
$macro_search_list = l
|
59
57
|
$select_keys = ["h", "l", "f", "d", "s", "a", "g", "z"]
|
60
58
|
|
61
59
|
gui_select_update_window(l, $select_keys.collect { |x| x.upcase },
|
62
|
-
|
63
|
-
|
60
|
+
"gui_find_macro_select_callback",
|
61
|
+
"gui_find_macro_update_callback")
|
64
62
|
end
|
65
63
|
|
66
64
|
def name_macro(name, id = nil)
|
@@ -129,14 +127,16 @@ class Macro
|
|
129
127
|
end
|
130
128
|
acts = @recorded_macros[name]
|
131
129
|
if acts.kind_of?(Array) and acts.any?
|
130
|
+
@running_macro = true
|
132
131
|
set_last_command({ method: $macro.method("run_macro"), params: [name] })
|
133
132
|
#
|
134
|
-
# Ripl.start :binding => binding
|
135
133
|
for a in acts
|
136
134
|
ret = exec_action(a)
|
137
135
|
debug ret
|
138
136
|
if ret == false
|
139
137
|
message("Error while running macro")
|
138
|
+
Ripl.start :binding => binding
|
139
|
+
|
140
140
|
break
|
141
141
|
end
|
142
142
|
end
|
@@ -144,6 +144,7 @@ class Macro
|
|
144
144
|
# debug(eval_str)
|
145
145
|
# eval(eval_str)
|
146
146
|
end
|
147
|
+
@running_macro = false
|
147
148
|
buf.set_pos(buf.pos)
|
148
149
|
end
|
149
150
|
|
data/lib/vimamsa/main.rb
CHANGED
data/lib/vimamsa/rbvma.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
#require "gtksourceview4"
|
2
1
|
require "date"
|
3
2
|
require "fileutils"
|
4
|
-
|
5
|
-
require "
|
3
|
+
|
4
|
+
require "gtk4"
|
5
|
+
require "gtksourceview5"
|
6
|
+
|
6
7
|
require "json"
|
7
8
|
require "listen"
|
8
9
|
require "pathname"
|
@@ -10,9 +11,11 @@ require "ripl"
|
|
10
11
|
require "ripl/multi_line"
|
11
12
|
require "shellwords"
|
12
13
|
require "cgi"
|
13
|
-
|
14
|
+
require "uri"
|
14
15
|
require "vimamsa/util"
|
16
|
+
# exit!
|
15
17
|
require "vimamsa/main"
|
18
|
+
require "vimamsa/form_generator"
|
16
19
|
|
17
20
|
require "vimamsa/actions"
|
18
21
|
require "vimamsa/key_binding_tree"
|
data/lib/vimamsa/search.rb
CHANGED
@@ -44,6 +44,8 @@ class Search
|
|
44
44
|
else
|
45
45
|
return false
|
46
46
|
end
|
47
|
+
|
48
|
+
return nil
|
47
49
|
end
|
48
50
|
|
49
51
|
def update_search()
|
@@ -54,7 +56,6 @@ class Search
|
|
54
56
|
if startpos != nil
|
55
57
|
@cur_search_i = @search_indexes.find_index(startpos)
|
56
58
|
end
|
57
|
-
# Ripl.start :binding => binding
|
58
59
|
end
|
59
60
|
|
60
61
|
def jump_to_next()
|