vimamsa 0.1.13 → 0.1.15
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/custom_example.rb +12 -0
- data/lib/vimamsa/ack.rb +3 -4
- data/lib/vimamsa/actions.rb +1 -2
- data/lib/vimamsa/audio.rb +25 -1
- data/lib/vimamsa/buffer.rb +116 -591
- data/lib/vimamsa/buffer_changetext.rb +272 -0
- data/lib/vimamsa/buffer_cursor.rb +303 -0
- data/lib/vimamsa/buffer_list.rb +137 -133
- data/lib/vimamsa/buffer_manager.rb +15 -15
- data/lib/vimamsa/clipboard.rb +36 -0
- data/lib/vimamsa/conf.rb +136 -5
- data/lib/vimamsa/constants.rb +0 -10
- data/lib/vimamsa/debug.rb +9 -8
- data/lib/vimamsa/editor.rb +57 -84
- data/lib/vimamsa/encrypt.rb +6 -11
- data/lib/vimamsa/file_history.rb +0 -8
- data/lib/vimamsa/file_manager.rb +142 -10
- data/lib/vimamsa/gui.rb +106 -85
- data/lib/vimamsa/gui_dialog.rb +113 -0
- data/lib/vimamsa/gui_menu.rb +5 -1
- data/lib/vimamsa/gui_sourceview.rb +46 -29
- data/lib/vimamsa/gui_sourceview_autocomplete.rb +141 -0
- data/lib/vimamsa/gui_text.rb +49 -0
- data/lib/vimamsa/hyper_plain_text.rb +19 -5
- data/lib/vimamsa/key_actions.rb +41 -202
- data/lib/vimamsa/key_binding_tree.rb +129 -41
- data/lib/vimamsa/key_bindings_vimlike.rb +58 -48
- data/lib/vimamsa/langservp.rb +23 -3
- data/lib/vimamsa/macro.rb +35 -25
- data/lib/vimamsa/main.rb +7 -10
- data/lib/vimamsa/rbvma.rb +13 -11
- data/lib/vimamsa/search.rb +1 -1
- data/lib/vimamsa/search_replace.rb +106 -160
- data/lib/vimamsa/terminal.rb +34 -0
- data/lib/vimamsa/tests.rb +122 -0
- data/lib/vimamsa/util.rb +43 -4
- data/lib/vimamsa/version.rb +1 -1
- data/vimamsa.gemspec +5 -2
- metadata +59 -9
- /data/lib/vimamsa/{form_generator.rb → gui_form_generator.rb} +0 -0
data/lib/vimamsa/buffer_list.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
1
|
def save_buffer_list()
|
3
2
|
message("Save buffer list")
|
4
3
|
buffn = get_dot_path("buffers.txt")
|
5
4
|
f = File.open(buffn, "w")
|
6
|
-
bufstr = vma.buffers.collect { |buf| buf.fname }.inspect
|
5
|
+
bufstr = vma.buffers.list.collect { |buf| buf.fname }.inspect
|
7
6
|
f.write(bufstr)
|
8
7
|
f.close()
|
9
8
|
end
|
@@ -20,73 +19,93 @@ def load_buffer_list()
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
class BufferList
|
24
|
-
attr_reader :current_buf, :last_dir, :buffer_history
|
22
|
+
class BufferList
|
23
|
+
attr_reader :current_buf, :last_dir, :last_file, :buffer_history
|
24
|
+
attr_accessor :list
|
25
25
|
|
26
26
|
def initialize()
|
27
27
|
@last_dir = File.expand_path(".")
|
28
28
|
@buffer_history = []
|
29
29
|
super
|
30
|
-
@current_buf=0
|
30
|
+
@current_buf = 0
|
31
|
+
@list = []
|
32
|
+
@h = {}
|
33
|
+
reset_navigation
|
31
34
|
end
|
32
35
|
|
33
36
|
# lastdir = File.expand_path(".") if lastdir.nil?
|
34
37
|
def <<(_buf)
|
35
|
-
super
|
36
38
|
vma.buf = _buf
|
37
|
-
|
38
|
-
|
39
|
-
@recent_ind = 0
|
39
|
+
self.add(_buf)
|
40
|
+
|
40
41
|
$hook.call(:change_buffer, vma.buf)
|
41
|
-
vma.gui.set_current_buffer(vma.buf.id)
|
42
|
-
|
42
|
+
vma.gui.set_current_buffer(vma.buf.id) #TODO: handle elswhere?
|
43
|
+
# vma.buf.view.set_cursor_pos(vma.buf.pos) #TODO: handle elswhere?
|
43
44
|
update_last_dir(_buf)
|
44
45
|
end
|
45
46
|
|
46
47
|
def add(_buf)
|
47
|
-
|
48
|
-
@
|
48
|
+
@buffer_history << _buf.id
|
49
|
+
# @navigation_idx = _buf.id #TODO:??
|
50
|
+
@list << _buf
|
51
|
+
@h[_buf.id] = _buf
|
49
52
|
end
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
#NOTE: unused. enable?
|
55
|
+
# def switch()
|
56
|
+
# debug "SWITCH BUF. bufsize:#{self.size}, curbuf: #{@current_buf}"
|
57
|
+
# @current_buf += 1
|
58
|
+
# @current_buf = 0 if @current_buf >= self.size
|
59
|
+
# m = method("switch")
|
60
|
+
# set_last_command({ method: m, params: [] })
|
61
|
+
# set_current_buffer(@current_buf)
|
62
|
+
# end
|
63
|
+
|
64
|
+
def slist
|
65
|
+
# TODO: implement using heap/priorityque
|
66
|
+
@list.sort_by! { |x| x.access_time }
|
58
67
|
end
|
59
68
|
|
60
69
|
def get_last_visited_id
|
61
|
-
last_buf =
|
62
|
-
|
70
|
+
last_buf = nil
|
71
|
+
for i in 0..(slist.size - 1)
|
72
|
+
next if slist[i].is_active?
|
73
|
+
last_buf = slist[i].id
|
74
|
+
end
|
75
|
+
return last_buf
|
63
76
|
end
|
64
77
|
|
65
78
|
def switch_to_last_buf()
|
66
79
|
debug "SWITCH TO LAST BUF:"
|
67
|
-
debug @buffer_history
|
68
|
-
last_buf = @buffer_history[-2]
|
69
|
-
|
70
|
-
|
80
|
+
# debug @buffer_history
|
81
|
+
# last_buf = @buffer_history[-2]
|
82
|
+
|
83
|
+
last_buf = slist[-2]
|
84
|
+
if !last_buf.nil?
|
85
|
+
set_current_buffer(last_buf.id)
|
71
86
|
end
|
72
87
|
end
|
73
88
|
|
89
|
+
def size
|
90
|
+
return @list.size
|
91
|
+
end
|
92
|
+
|
74
93
|
def get_buffer_by_filename(fname)
|
75
94
|
#TODO: check using stat/inode? http://ruby-doc.org/core-1.9.3/File/Stat.html#method-i-ino
|
76
|
-
|
77
|
-
return
|
95
|
+
b = @list.find { |b| b.fname == fname }
|
96
|
+
return b.id unless b.nil?
|
97
|
+
return nil
|
78
98
|
end
|
79
99
|
|
80
100
|
def get_buffer_by_id(id)
|
81
|
-
|
82
|
-
return buf_idx
|
101
|
+
return @h[id]
|
83
102
|
end
|
84
103
|
|
85
104
|
def add_buf_to_history(buf_idx)
|
86
|
-
if
|
105
|
+
if @list.include?(buf_idx)
|
87
106
|
@buffer_history << @buf_idx
|
88
|
-
@
|
89
|
-
compact_buf_history()
|
107
|
+
@navigation_idx = 0
|
108
|
+
# compact_buf_history()
|
90
109
|
else
|
91
110
|
debug "buffer_list, no such id:#{buf_idx}"
|
92
111
|
return
|
@@ -94,40 +113,40 @@ class BufferList < Array
|
|
94
113
|
end
|
95
114
|
|
96
115
|
def add_current_buf_to_history()
|
97
|
-
@
|
98
|
-
@buffer_history << @current_buf
|
99
|
-
compact_buf_history()
|
116
|
+
@h[@current_buf].update_access_time
|
100
117
|
end
|
101
118
|
|
102
|
-
def set_current_buffer_by_id(
|
103
|
-
idx = get_buffer_by_id(buf_id)
|
104
|
-
if idx.nil?
|
105
|
-
debug "IDX=nil"
|
106
|
-
return
|
107
|
-
end
|
119
|
+
def set_current_buffer_by_id(idx, update_history = true)
|
108
120
|
set_current_buffer(idx, update_history)
|
109
121
|
end
|
110
122
|
|
111
|
-
def set_current_buffer(
|
112
|
-
|
113
|
-
buffer_i = 0 if buffer_i < 0
|
114
|
-
vma.buf = self[buffer_i]
|
115
|
-
return if !vma.buf
|
116
|
-
@current_buf = buffer_i
|
117
|
-
debug "SWITCH BUF2. bufsize:#{self.size}, curbuf: #{@current_buf}"
|
118
|
-
fpath = vma.buf.fname
|
119
|
-
if fpath and fpath.size > 50
|
120
|
-
fpath = fpath[-50..-1]
|
121
|
-
end
|
123
|
+
def set_current_buffer(idx, update_history = true)
|
124
|
+
# Set update_history = false if we are only browsing
|
122
125
|
|
123
|
-
if
|
124
|
-
|
126
|
+
if !vma.buf.nil? and vma.kbd.get_scope != :editor
|
127
|
+
# Save keyboard mode status of old buffer when switching buffer
|
128
|
+
vma.buf.mode_stack = vma.kbd.default_mode_stack.clone
|
125
129
|
end
|
130
|
+
return if !@h[idx]
|
131
|
+
vma.buf = bu = @h[idx]
|
132
|
+
update_last_dir(vma.buf)
|
133
|
+
@current_buf = idx
|
134
|
+
debug "SWITCH BUF. bufsize:#{@list.size}, curbuf: #{@current_buf}"
|
126
135
|
|
127
136
|
vma.hook.call(:change_buffer, vma.buf)
|
128
|
-
vma.buf.set_active
|
129
137
|
|
130
|
-
|
138
|
+
bu.set_active # TODO
|
139
|
+
bu.update_access_time if update_history
|
140
|
+
vma.gui.set_current_buffer(idx)
|
141
|
+
|
142
|
+
#TODO: delete?
|
143
|
+
# if !vma.buf.mode_stack.nil? and vma.kbd.get_scope != :editor #TODO
|
144
|
+
# debug "set kbd mode stack #{vma.buf.mode_stack} #{vma.buf.id}", 2
|
145
|
+
# Reload previously saved keyboard mode status
|
146
|
+
# vma.kbd.set_mode_stack(vma.buf.mode_stack.clone) #TODO:needed?
|
147
|
+
# vma.kbd.set_mode_stack([vma.buf.default_mode])
|
148
|
+
# end
|
149
|
+
# vma.kbd.set_mode_to_default if vma.kbd.get_scope != :editor
|
131
150
|
|
132
151
|
gui_set_window_title(vma.buf.title, vma.buf.subtitle)
|
133
152
|
|
@@ -135,12 +154,17 @@ class BufferList < Array
|
|
135
154
|
@last_dir = File.dirname(vma.buf.fname)
|
136
155
|
end
|
137
156
|
|
138
|
-
# hpt_scan_images() if
|
157
|
+
# hpt_scan_images() if cnf.debug? # experimental
|
158
|
+
end
|
159
|
+
|
160
|
+
def to_s
|
161
|
+
return self.class.to_s
|
139
162
|
end
|
140
163
|
|
141
164
|
def update_last_dir(buf)
|
142
165
|
if buf.fname
|
143
166
|
@last_dir = File.dirname(buf.fname)
|
167
|
+
@last_file = buf.fname
|
144
168
|
end
|
145
169
|
end
|
146
170
|
|
@@ -152,100 +176,80 @@ class BufferList < Array
|
|
152
176
|
return @last_dir
|
153
177
|
end
|
154
178
|
|
155
|
-
def
|
156
|
-
|
157
|
-
@buffer_history.reverse.each { |x| bufs << x if !b[x] && x < self.size; b[x] = true }
|
158
|
-
return bufs
|
179
|
+
def reset_navigation
|
180
|
+
@navigation_idx = 0
|
159
181
|
end
|
160
182
|
|
161
|
-
def history_switch_backwards
|
162
|
-
|
163
|
-
@
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
set_current_buffer(bufid, false)
|
183
|
+
def history_switch_backwards
|
184
|
+
@navigation_idx += 1
|
185
|
+
@navigation_idx = 0 if @navigation_idx >= list.size
|
186
|
+
b = slist[-1 - @navigation_idx]
|
187
|
+
debug "IND:#{@navigation_idx} RECENT:#{slist.collect { |x| x.fname }.join(" ")}"
|
188
|
+
set_current_buffer(b.id, false)
|
168
189
|
end
|
169
190
|
|
170
191
|
def history_switch_forwards()
|
171
|
-
|
172
|
-
@
|
173
|
-
|
174
|
-
|
175
|
-
debug "IND:#{@
|
176
|
-
set_current_buffer(
|
192
|
+
@navigation_idx -= 1
|
193
|
+
@navigation_idx = list.size - 1 if @navigation_idx < 0
|
194
|
+
|
195
|
+
b = slist[-1 - @navigation_idx]
|
196
|
+
debug "IND:#{@navigation_idx} RECENT:#{slist.collect { |x| x.fname }.join(" ")}"
|
197
|
+
set_current_buffer(b.id, false)
|
177
198
|
end
|
178
199
|
|
179
|
-
def
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
200
|
+
def get_last_non_active_buffer
|
201
|
+
for bu in slist.reverse
|
202
|
+
return bu.id if !bu.is_active
|
203
|
+
end
|
204
|
+
return nil
|
184
205
|
end
|
185
206
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
return if
|
190
|
-
return if @current_buf == buffer_i
|
207
|
+
def close_buffer(idx, from_recent = false, auto_open: true)
|
208
|
+
return if idx.nil?
|
209
|
+
bu = @h[idx]
|
210
|
+
return if bu.nil?
|
191
211
|
|
192
|
-
bufname =
|
212
|
+
bufname = bu.basename
|
193
213
|
message("Closed buffer #{bufname}")
|
194
214
|
|
195
|
-
|
196
|
-
@
|
197
|
-
end
|
215
|
+
@list.delete(@h[idx])
|
216
|
+
@h.delete(idx)
|
198
217
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
recent = get_recent_buffers
|
206
|
-
jump_to_buf = recent[@recent_ind + 1]
|
207
|
-
jump_to_buf = 0 if jump_to_buf == nil
|
208
|
-
|
209
|
-
self.slice!(buffer_i)
|
210
|
-
@buffer_history = @buffer_history.collect { |x| r = x; r = x - 1 if x > buffer_i; r = nil if x == buffer_i; r }.compact
|
211
|
-
|
212
|
-
if @current_buf == buffer_i
|
213
|
-
if from_recent
|
214
|
-
@current_buf = jump_to_buf
|
215
|
-
else
|
216
|
-
# Find last edited buffer that is not already open
|
217
|
-
@current_buf = @buffer_history.filter{|x| !vma.gui.is_buffer_open(self[x].id)}.last
|
218
|
+
if auto_open
|
219
|
+
@current_buf = get_last_non_active_buffer
|
220
|
+
if @list.size == 0 or @current_buf.nil?
|
221
|
+
bu = Buffer.new("\n")
|
222
|
+
add(bu)
|
223
|
+
@current_buf = bu.id
|
218
224
|
end
|
225
|
+
set_current_buffer(@current_buf, false)
|
219
226
|
end
|
220
|
-
if self.size == 0 or @current_buf.nil?
|
221
|
-
self << Buffer.new("\n")
|
222
|
-
@current_buf = 0
|
223
|
-
else
|
224
|
-
@current_buf = 0 if @current_buf >= self.size
|
225
|
-
end
|
226
|
-
set_current_buffer(@current_buf, false)
|
227
227
|
end
|
228
228
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
if self.size == 1
|
233
|
-
close_buffer(0)
|
234
|
-
break
|
235
|
-
else
|
236
|
-
close_buffer(0)
|
237
|
-
end
|
238
|
-
end
|
239
|
-
# self << Buffer.new("\n")
|
229
|
+
# Close buffer in the background
|
230
|
+
def close_other_buffer(idx)
|
231
|
+
close_buffer(idx, auto_open: false)
|
240
232
|
end
|
241
233
|
|
234
|
+
#TODO
|
235
|
+
# def close_all_buffers()
|
236
|
+
# message("Closing all buffers")
|
237
|
+
# while @list.size > 0
|
238
|
+
# if self.size == 1
|
239
|
+
# close_buffer(0)
|
240
|
+
# break
|
241
|
+
# else
|
242
|
+
# close_buffer(0)
|
243
|
+
# end
|
244
|
+
# end
|
245
|
+
# # self << Buffer.new("\n")
|
246
|
+
# end
|
247
|
+
|
242
248
|
def close_scrap_buffers()
|
243
|
-
|
244
|
-
|
245
|
-
if !
|
246
|
-
close_buffer(
|
247
|
-
else
|
248
|
-
i += 1
|
249
|
+
l = @list.clone
|
250
|
+
for bu in l
|
251
|
+
if !bu.pathname
|
252
|
+
close_buffer(bu.id)
|
249
253
|
end
|
250
254
|
end
|
251
255
|
end
|
@@ -256,7 +260,7 @@ class BufferList < Array
|
|
256
260
|
|
257
261
|
def delete_current_buffer(from_recent = false)
|
258
262
|
fn = buf.fname
|
259
|
-
close_buffer(@current_buf
|
263
|
+
close_buffer(@current_buf)
|
260
264
|
#TODO: confirm with user, "Do you want to delete file X"
|
261
265
|
if is_existing_file(fn)
|
262
266
|
message("Deleting file: #{fn}")
|
@@ -7,11 +7,12 @@ class BufferManager
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.init()
|
10
|
-
vma.kbd.add_minor_mode("bmgr", :buf_mgr, :command)
|
10
|
+
# vma.kbd.add_minor_mode("bmgr", :buf_mgr, :command)
|
11
|
+
vma.kbd.add_minor_mode("bmgr", :bmgr, :command)
|
11
12
|
reg_act(:bmgr_select, proc { buf.module.select_line }, "")
|
12
13
|
reg_act(:bmgr_close, proc { buf.module.close_selected }, "")
|
13
14
|
|
14
|
-
reg_act(:start_buf_manager, proc { BufferManager.new.run; vma.kbd.set_mode(:
|
15
|
+
reg_act(:start_buf_manager, proc { BufferManager.new.run; vma.kbd.set_mode(:bmgr) }, "Buffer manager")
|
15
16
|
|
16
17
|
bindkey "bmgr enter", :bmgr_select
|
17
18
|
bindkey "bmgr c", :bmgr_close
|
@@ -27,28 +28,26 @@ class BufferManager
|
|
27
28
|
l = @buf.lpos - @header.size
|
28
29
|
return nil if l < 0
|
29
30
|
bufid = @line_to_id[l]
|
30
|
-
|
31
|
-
return buf_i
|
31
|
+
return bufid
|
32
32
|
end
|
33
33
|
|
34
34
|
def close_selected
|
35
|
-
|
36
|
-
|
35
|
+
idx = buf_of_current_line()
|
36
|
+
r = @buf.current_line_range
|
37
|
+
Gui.hilight_range(@buf,r, color:"#666666ff")
|
38
|
+
if idx.nil?
|
37
39
|
message("buf already closed")
|
38
40
|
return
|
39
41
|
end
|
40
|
-
vma.buffers.close_other_buffer(
|
42
|
+
vma.buffers.close_other_buffer(idx)
|
41
43
|
end
|
42
44
|
|
43
45
|
def select_line
|
44
|
-
|
45
|
-
return if
|
46
|
+
idx = buf_of_current_line()
|
47
|
+
return if idx.nil?
|
46
48
|
|
47
|
-
|
48
|
-
vma.buffers.
|
49
|
-
|
50
|
-
bid = vma.buffers.get_buffer_by_id(@buf.id)
|
51
|
-
vma.buffers.close_other_buffer(bid)
|
49
|
+
vma.buffers.set_current_buffer(idx)
|
50
|
+
vma.buffers.close_other_buffer(@buf.id)
|
52
51
|
@@cur = nil
|
53
52
|
end
|
54
53
|
|
@@ -69,7 +68,7 @@ class BufferManager
|
|
69
68
|
s << "\n"
|
70
69
|
i = 0
|
71
70
|
jump_to_line = 0
|
72
|
-
for b in vma.buffers.sort_by { |x| x.list_str }
|
71
|
+
for b in vma.buffers.list.sort_by { |x| x.list_str }
|
73
72
|
if b.id == vma.buf.id # current file
|
74
73
|
# s << " "
|
75
74
|
jump_to_line = i
|
@@ -84,6 +83,7 @@ class BufferManager
|
|
84
83
|
|
85
84
|
if @buf.nil?
|
86
85
|
@buf = create_new_buffer(s,"bufmgr")
|
86
|
+
@buf.default_mode = :buf_mgr
|
87
87
|
@buf.module = self
|
88
88
|
@buf.active_kbd_mode = :buf_mgr
|
89
89
|
else
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Clipboard
|
2
|
+
def initialize
|
3
|
+
@clipboard = []
|
4
|
+
end
|
5
|
+
|
6
|
+
def [](key)
|
7
|
+
return @clipboard[key]
|
8
|
+
end
|
9
|
+
|
10
|
+
def <<(str)
|
11
|
+
return @clipboard << str
|
12
|
+
end
|
13
|
+
|
14
|
+
def set(s)
|
15
|
+
if !(s.class <= String) or s.size == 0
|
16
|
+
debug s.inspect
|
17
|
+
debug [s, s.class, s.size]
|
18
|
+
log_error("s.class != String or s.size == 0")
|
19
|
+
return
|
20
|
+
end
|
21
|
+
@clipboard << s
|
22
|
+
set_system_clipboard(s)
|
23
|
+
vma.register[vma.cur_register] = s
|
24
|
+
debug "SET CLIPBOARD: [#{s}]"
|
25
|
+
debug "REGISTER: #{vma.cur_register}:#{vma.register[vma.cur_register]}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def get()
|
29
|
+
return @clipboard[-1]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_system_clipboard(arg)
|
34
|
+
debug arg,2
|
35
|
+
vma.gui.window.display.clipboard.set(arg)
|
36
|
+
end
|
data/lib/vimamsa/conf.rb
CHANGED
@@ -13,18 +13,149 @@ def setcnf(id, val)
|
|
13
13
|
end
|
14
14
|
|
15
15
|
setcnf :custom_lsp, {}
|
16
|
-
conf(:custom_lsp)[:ruby] = {name: "solargraph", command:"solargraph stdio", type: "stdio"}
|
17
|
-
conf(:custom_lsp)[:cpp] = {name: "clangd", command:"clangd-12 --offset-encoding=utf-8", type: "stdio"}
|
18
|
-
conf(:custom_lsp)[:python] = {name: "pyright", command:"pyright-langserver --stdio --verbose", type: "stdio"}
|
19
16
|
|
20
17
|
setcnf :indent_based_on_last_line, true
|
21
18
|
setcnf :extensions_to_open, [".txt", ".h", ".c", ".cpp", ".hpp", ".rb", ".inc", ".php", ".sh", ".m", ".gd", ".js", ".py"]
|
22
19
|
setcnf :default_search_extensions, ["txt", "rb"]
|
23
20
|
|
24
|
-
|
25
21
|
setcnf "log.verbose", 1
|
26
|
-
setcnf :tab_width, 4
|
27
22
|
setcnf :enable_lsp, false
|
28
23
|
|
24
|
+
setcnf :tab_width, 2
|
25
|
+
setcnf :tab_to_spaces_default, false
|
26
|
+
setcnf :tab_to_spaces_languages, ["c", "java", "ruby", "hyperplaintext", "php"]
|
27
|
+
setcnf :tab_to_spaces_not_languages, ["makefile"]
|
28
|
+
|
29
29
|
setcnf :workspace_folders, []
|
30
30
|
|
31
|
+
|
32
|
+
# New way to configure:
|
33
|
+
# To set conf value:
|
34
|
+
# cnf.foo.bar.baz = 3
|
35
|
+
|
36
|
+
#To get conf value:
|
37
|
+
# cnf.foo.bar.baz?
|
38
|
+
# cnf.foo.bar.baz!
|
39
|
+
# get(cnf.foo.bar.baz)
|
40
|
+
# (All get the same result)
|
41
|
+
|
42
|
+
class ConfId
|
43
|
+
def initialize(first)
|
44
|
+
@id = [first]
|
45
|
+
end
|
46
|
+
|
47
|
+
def method_missing(method_name, *args)
|
48
|
+
# pp "asize:#{args.size}"
|
49
|
+
if m = method_name.match(/(.*)=$/)
|
50
|
+
@id << m[1].to_sym
|
51
|
+
# pp [@id, args[0]]
|
52
|
+
set(self, args[0])
|
53
|
+
return args[0]
|
54
|
+
elsif m = method_name.match(/(.*)[\!\?]$/)
|
55
|
+
@id << m[1].to_sym
|
56
|
+
r = get(self)
|
57
|
+
|
58
|
+
if r.class == Hash and r.empty?
|
59
|
+
# The accessed key was not defined
|
60
|
+
return nil
|
61
|
+
else
|
62
|
+
return r
|
63
|
+
end
|
64
|
+
else
|
65
|
+
@id << method_name
|
66
|
+
end
|
67
|
+
|
68
|
+
return self
|
69
|
+
end
|
70
|
+
|
71
|
+
def to_s
|
72
|
+
@id.join(".")
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_a
|
76
|
+
return @id
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class Conf
|
81
|
+
attr_reader :confh
|
82
|
+
|
83
|
+
def initialize()
|
84
|
+
@id = []
|
85
|
+
@confh = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
|
86
|
+
end
|
87
|
+
|
88
|
+
def method_missing(method_name, *args)
|
89
|
+
c = ConfId.new(method_name)
|
90
|
+
|
91
|
+
#TODO: improve
|
92
|
+
if m = method_name.match(/(.*)[\!\?]$/)
|
93
|
+
c = ConfId.new(m[1])
|
94
|
+
return get(c)
|
95
|
+
end
|
96
|
+
|
97
|
+
if m = method_name.match(/(.*)=$/)
|
98
|
+
c = ConfId.new(m[1])
|
99
|
+
set(c, args[0])
|
100
|
+
return args[0]
|
101
|
+
end
|
102
|
+
|
103
|
+
return c
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
$confh = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
|
110
|
+
# set cnf.foo.bar.baz, 3
|
111
|
+
# => $confh = {:foo=>{:bar=>{:baz=>3}}}
|
112
|
+
def set(_id, val)
|
113
|
+
a = $confh
|
114
|
+
id = _id.to_a
|
115
|
+
last = id.pop
|
116
|
+
for x in id
|
117
|
+
a = a[x]
|
118
|
+
end
|
119
|
+
a[last] = val
|
120
|
+
end
|
121
|
+
|
122
|
+
def get(id)
|
123
|
+
id = id.to_a
|
124
|
+
a = $confh
|
125
|
+
for x in id
|
126
|
+
return nil if a[x].nil?
|
127
|
+
return nil if a.empty?
|
128
|
+
a = a[x]
|
129
|
+
end
|
130
|
+
return a
|
131
|
+
end
|
132
|
+
|
133
|
+
$vimamsa_conf = Conf.new
|
134
|
+
|
135
|
+
def cnf()
|
136
|
+
return $vimamsa_conf
|
137
|
+
end
|
138
|
+
|
139
|
+
cnf.indent_based_on_last_line = true
|
140
|
+
cnf.extensions_to_open = [".txt", ".h", ".c", ".cpp", ".hpp", ".rb", ".inc", ".php", ".sh", ".m", ".gd", ".js", ".py"]
|
141
|
+
cnf.default_search_extensions = ["txt", "rb"]
|
142
|
+
|
143
|
+
cnf.log.verbose = 1
|
144
|
+
cnf.lsp.enabled = false
|
145
|
+
cnf.fexp.experimental = false
|
146
|
+
cnf.experimental = false
|
147
|
+
|
148
|
+
cnf.tab.width = 2
|
149
|
+
cnf.tab.to_spaces_default = false
|
150
|
+
cnf.tab.to_spaces_languages = ["c", "java", "ruby", "hyperplaintext", "php"]
|
151
|
+
cnf.tab.to_spaces_not_languages = ["makefile"]
|
152
|
+
cnf.workspace_folders = []
|
153
|
+
|
154
|
+
cnf.match.highlight.color = "#10bd8e"
|
155
|
+
|
156
|
+
cnf.lsp.enabled = false
|
157
|
+
|
158
|
+
cnf.font.size = 11
|
159
|
+
cnf.font.family = "Monospace"
|
160
|
+
|
161
|
+
|
data/lib/vimamsa/constants.rb
CHANGED
@@ -15,8 +15,6 @@ CURRENT_CHAR_FORWARD = 2005
|
|
15
15
|
CURRENT_CHAR_BACKWARD = 2006
|
16
16
|
START_OF_BUFFER = 2007
|
17
17
|
END_OF_BUFFER = 2008
|
18
|
-
BACKWARD = 2009
|
19
|
-
FORWARD = 2010
|
20
18
|
END_OF_LINE = 2011
|
21
19
|
BEGINNING_OF_LINE = 2012
|
22
20
|
WORD_START = 2013
|
@@ -30,14 +28,6 @@ REPLACE = 3002
|
|
30
28
|
KEY_PRESS = 6
|
31
29
|
KEY_RELEASE = 7 # QEvent::KeyRelease
|
32
30
|
|
33
|
-
# http://qt-project.org/doc/qt-5.0/qtcore/qt.html#KeyboardModifier-enum
|
34
|
-
ALTMODIFIER = 0x08000000
|
35
|
-
NOMODIFIER = 0x00000000 # No modifier key is pressed.
|
36
|
-
SHIFTMODIFIER = 0x02000000 # A Shift key on the keyboard is pressed.
|
37
|
-
CONTROLMODIFIER = 0x04000000 # A Ctrl key on the keyboard is pressed.
|
38
|
-
ALTMODIFIER = 0x08000000 # An Alt key on the keyboard is pressed.
|
39
|
-
METAMODIFIER = 0x10000000 # A Meta key on the keyboard is pressed.
|
40
|
-
KEYPADMODIFIER = 0x20000000 # A keypad button is pressed.
|
41
31
|
|
42
32
|
|
43
33
|
|