neovim 0.5.0 → 0.5.1
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/.travis.yml +7 -6
- data/CHANGELOG.md +4 -0
- data/Rakefile +2 -7
- data/lib/neovim/version.rb +1 -1
- data/spec/integration/runtime/vader.vim/autoload/vader.vim +348 -0
- data/spec/integration/runtime/vader.vim/autoload/vader/assert.vim +116 -0
- data/spec/integration/runtime/vader.vim/autoload/vader/helper.vim +43 -0
- data/spec/integration/runtime/vader.vim/autoload/vader/parser.vim +179 -0
- data/spec/integration/runtime/vader.vim/autoload/vader/syntax.vim +73 -0
- data/spec/integration/runtime/vader.vim/autoload/vader/window.vim +205 -0
- data/spec/integration/runtime/vader.vim/plugin/vader.vim +37 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64c75505d6b6148e56df55a0f63f20dcc33ff329
|
4
|
+
data.tar.gz: 23581eb000bf8165fcbccc01b1ef004c86f57aac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea759f8fe2edd4b37c2646245deffb627466633f7424e7ce0ff563e32c141d113cd4b7a2094c82cd62fbeb5238cd9bf512521ccbe3ba376996f45021f9451d10
|
7
|
+
data.tar.gz: '08498a8f0928796988e6e4abe2c3e27fc1c70b8c59786898649e2acbdfd9f9f8e333dae0438b15b04fd3a51189ae421570bc91de7eb6bbe8230faaef4f7b9ae7'
|
data/.travis.yml
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
|
+
dist: trusty
|
3
4
|
|
4
5
|
branches:
|
5
6
|
only: master
|
6
7
|
|
7
8
|
rvm:
|
8
|
-
- 1.9
|
9
|
-
- 2.0
|
10
|
-
- 2.1
|
11
|
-
- 2.2
|
12
|
-
- 2.3
|
13
|
-
- 2.4
|
9
|
+
- 1.9
|
10
|
+
- 2.0
|
11
|
+
- 2.1
|
12
|
+
- 2.2
|
13
|
+
- 2.3
|
14
|
+
- 2.4
|
14
15
|
- ruby-head
|
15
16
|
|
16
17
|
before_install:
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -11,11 +11,6 @@ task :api do
|
|
11
11
|
sh File.expand_path("../script/dump_api", __FILE__)
|
12
12
|
end
|
13
13
|
|
14
|
-
desc "Initialize and update git submodules"
|
15
|
-
task :submodules do
|
16
|
-
sh "git submodule update --init"
|
17
|
-
end
|
18
|
-
|
19
14
|
namespace :spec do
|
20
15
|
desc "Run functional specs"
|
21
16
|
RSpec::Core::RakeTask.new(:functional) do |t|
|
@@ -23,10 +18,10 @@ namespace :spec do
|
|
23
18
|
end
|
24
19
|
|
25
20
|
desc "Run integration specs"
|
26
|
-
RSpec::Core::RakeTask.new(:integration
|
21
|
+
RSpec::Core::RakeTask.new(:integration) do |t|
|
27
22
|
t.pattern = "spec/integration_spec.rb"
|
28
23
|
end
|
29
24
|
end
|
30
25
|
|
31
|
-
RSpec::Core::RakeTask.new(:spec
|
26
|
+
RSpec::Core::RakeTask.new(:spec)
|
32
27
|
task :default => :spec
|
data/lib/neovim/version.rb
CHANGED
@@ -0,0 +1,348 @@
|
|
1
|
+
" Copyright (c) 2015 Junegunn Choi
|
2
|
+
"
|
3
|
+
" MIT License
|
4
|
+
"
|
5
|
+
" Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
" a copy of this software and associated documentation files (the
|
7
|
+
" "Software"), to deal in the Software without restriction, including
|
8
|
+
" without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
" distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
" permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
" the following conditions:
|
12
|
+
"
|
13
|
+
" The above copyright notice and this permission notice shall be
|
14
|
+
" included in all copies or substantial portions of the Software.
|
15
|
+
"
|
16
|
+
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
let s:register = {}
|
25
|
+
let s:register_undefined = []
|
26
|
+
let s:indent = 2
|
27
|
+
|
28
|
+
function! vader#run(bang, ...) range
|
29
|
+
let s:error_line = 0
|
30
|
+
|
31
|
+
if a:lastline - a:firstline > 0
|
32
|
+
if a:0 > 1
|
33
|
+
echoerr "You can't apply range on multiple files"
|
34
|
+
return
|
35
|
+
endif
|
36
|
+
let [line1, line2] = [a:firstline, a:lastline]
|
37
|
+
else
|
38
|
+
let [line1, line2] = [1, 0]
|
39
|
+
endif
|
40
|
+
|
41
|
+
let options = { 'exitfirst': index(a:000, '-x') >= 0 }
|
42
|
+
let patterns = filter(copy(a:000), "v:val !=# '-x'")
|
43
|
+
if empty(patterns)
|
44
|
+
let patterns = [expand('%')]
|
45
|
+
endif
|
46
|
+
|
47
|
+
call vader#assert#reset()
|
48
|
+
call s:prepare()
|
49
|
+
try
|
50
|
+
let all_cases = []
|
51
|
+
let qfl = []
|
52
|
+
let st = reltime()
|
53
|
+
let [success, pending, total] = [0, 0, 0]
|
54
|
+
|
55
|
+
for gl in patterns
|
56
|
+
if filereadable(gl)
|
57
|
+
let files = [gl]
|
58
|
+
else
|
59
|
+
let files = filter(split(glob(gl), "\n"),
|
60
|
+
\ "fnamemodify(v:val, ':e') ==# 'vader'")
|
61
|
+
endif
|
62
|
+
for fn in files
|
63
|
+
let afn = fnamemodify(fn, ':p')
|
64
|
+
let cases = vader#parser#parse(afn, line1, line2)
|
65
|
+
call add(all_cases, [afn, cases])
|
66
|
+
let total += len(cases)
|
67
|
+
endfor
|
68
|
+
endfor
|
69
|
+
if empty(all_cases)
|
70
|
+
throw 'Vader: no tests found for patterns ('.join(patterns).')'
|
71
|
+
endif
|
72
|
+
|
73
|
+
call vader#window#open()
|
74
|
+
call vader#window#append(
|
75
|
+
\ printf("Starting Vader: %d suite(s), %d case(s)", len(all_cases), total), 0)
|
76
|
+
|
77
|
+
for pair in all_cases
|
78
|
+
let [fn, case] = pair
|
79
|
+
let [cs, cp, ct, lqfl] = s:run(fn, case, options)
|
80
|
+
let success += cs
|
81
|
+
let pending += cp
|
82
|
+
call extend(qfl, lqfl)
|
83
|
+
call vader#window#append(
|
84
|
+
\ printf('Success/Total: %s/%s%s',
|
85
|
+
\ cs, ct, cp > 0 ? (' ('.cp.' pending)') : ''),
|
86
|
+
\ 1)
|
87
|
+
endfor
|
88
|
+
|
89
|
+
let stats = vader#assert#stat()
|
90
|
+
call vader#window#append(printf('Success/Total: %s/%s (%sassertions: %d/%d)',
|
91
|
+
\ success, total, (pending > 0 ? pending . ' pending, ' : ''),
|
92
|
+
\ stats[0], stats[1]), 0)
|
93
|
+
call vader#window#append('Elapsed time: '.
|
94
|
+
\ substitute(reltimestr(reltime(st)), '^\s*', '', '') .' sec.', 0)
|
95
|
+
call vader#window#cleanup()
|
96
|
+
|
97
|
+
let g:vader_report = join(getline(1, '$'), "\n")
|
98
|
+
let g:vader_errors = qfl
|
99
|
+
call setqflist(qfl)
|
100
|
+
|
101
|
+
if a:bang
|
102
|
+
redir => ver
|
103
|
+
silent version
|
104
|
+
redir END
|
105
|
+
|
106
|
+
call s:print_stderr(ver . "\n\n" . g:vader_report)
|
107
|
+
if success + pending == total
|
108
|
+
qall!
|
109
|
+
else
|
110
|
+
cq
|
111
|
+
endif
|
112
|
+
elseif !empty(qfl)
|
113
|
+
call vader#window#copen()
|
114
|
+
endif
|
115
|
+
catch
|
116
|
+
let error = 'Vader error: '.v:exception.' (in '.v:throwpoint.')'
|
117
|
+
if a:bang
|
118
|
+
call s:print_stderr(error)
|
119
|
+
cq
|
120
|
+
else
|
121
|
+
echoerr error
|
122
|
+
endif
|
123
|
+
finally
|
124
|
+
call s:cleanup()
|
125
|
+
endtry
|
126
|
+
endfunction
|
127
|
+
|
128
|
+
function! s:print_stderr(output)
|
129
|
+
let lines = split(a:output, '\n')
|
130
|
+
if filewritable($VADER_OUTPUT_FILE)
|
131
|
+
call writefile(lines, $VADER_OUTPUT_FILE, 'a')
|
132
|
+
else
|
133
|
+
let tmp = tempname()
|
134
|
+
call writefile(lines, tmp)
|
135
|
+
execute 'silent !cat '.tmp.' 1>&2'
|
136
|
+
call delete(tmp)
|
137
|
+
endif
|
138
|
+
endfunction
|
139
|
+
|
140
|
+
function! s:split_args(arg)
|
141
|
+
let varnames = split(a:arg, ',')
|
142
|
+
let names = []
|
143
|
+
for varname in varnames
|
144
|
+
let name = substitute(varname, '^\s*\(.*\)\s*$', '\1', '')
|
145
|
+
let name = substitute(name, '^''\(.*\)''$', '\1', '')
|
146
|
+
let name = substitute(name, '^"\(.*\)"$', '\1', '')
|
147
|
+
call add(names, name)
|
148
|
+
endfor
|
149
|
+
return names
|
150
|
+
endfunction
|
151
|
+
|
152
|
+
function! vader#log(msg)
|
153
|
+
let msg = type(a:msg) == 1 ? a:msg : string(a:msg)
|
154
|
+
call vader#window#append('> ' . msg, s:indent)
|
155
|
+
endfunction
|
156
|
+
|
157
|
+
function! vader#save(args)
|
158
|
+
for varname in s:split_args(a:args)
|
159
|
+
if exists(varname)
|
160
|
+
let s:register[varname] = eval(varname)
|
161
|
+
else
|
162
|
+
let s:register_undefined += [varname]
|
163
|
+
endif
|
164
|
+
endfor
|
165
|
+
endfunction
|
166
|
+
|
167
|
+
function! vader#restore(args)
|
168
|
+
let varnames = s:split_args(a:args)
|
169
|
+
for varname in empty(varnames) ? keys(s:register) : varnames
|
170
|
+
if has_key(s:register, varname)
|
171
|
+
execute printf("let %s = s:register['%s']", varname, varname)
|
172
|
+
endif
|
173
|
+
endfor
|
174
|
+
let undefined = empty(varnames) ? s:register_undefined
|
175
|
+
\ : filter(copy(varnames), 'index(s:register_undefined, v:val) != -1')
|
176
|
+
for varname in undefined
|
177
|
+
if varname[0] ==# '$'
|
178
|
+
execute printf('let %s = ""', varname)
|
179
|
+
else
|
180
|
+
execute printf('unlet! %s', varname)
|
181
|
+
endif
|
182
|
+
endfor
|
183
|
+
endfunction
|
184
|
+
|
185
|
+
function! s:prepare()
|
186
|
+
command! -nargs=+ Log :call vader#log(<args>)
|
187
|
+
command! -nargs=+ Save :call vader#save(<q-args>)
|
188
|
+
command! -nargs=* Restore :call vader#restore(<q-args>)
|
189
|
+
command! -nargs=+ Assert :call vader#assert#true(<args>)
|
190
|
+
command! -nargs=+ AssertEqual :call vader#assert#equal(<args>)
|
191
|
+
command! -nargs=+ AssertNotEqual :call vader#assert#not_equal(<args>)
|
192
|
+
command! -nargs=+ AssertThrows :call vader#assert#throws(<q-args>)
|
193
|
+
let g:SyntaxAt = function('vader#helper#syntax_at')
|
194
|
+
let g:SyntaxOf = function('vader#helper#syntax_of')
|
195
|
+
endfunction
|
196
|
+
|
197
|
+
function! s:cleanup()
|
198
|
+
let s:register = {}
|
199
|
+
let s:register_undefined = []
|
200
|
+
delcommand Log
|
201
|
+
delcommand Save
|
202
|
+
delcommand Restore
|
203
|
+
delcommand Assert
|
204
|
+
delcommand AssertEqual
|
205
|
+
delcommand AssertNotEqual
|
206
|
+
delcommand AssertThrows
|
207
|
+
unlet g:SyntaxAt
|
208
|
+
unlet g:SyntaxOf
|
209
|
+
endfunction
|
210
|
+
|
211
|
+
function! s:comment(case, label)
|
212
|
+
return get(a:case.comment, a:label, '')
|
213
|
+
endfunction
|
214
|
+
|
215
|
+
function! s:execute(prefix, type, block, lang_if)
|
216
|
+
try
|
217
|
+
call vader#window#execute(a:block, a:lang_if)
|
218
|
+
return 1
|
219
|
+
catch
|
220
|
+
call s:append(a:prefix, a:type, v:exception, 1)
|
221
|
+
call s:print_throwpoint()
|
222
|
+
return 0
|
223
|
+
endtry
|
224
|
+
endfunction
|
225
|
+
|
226
|
+
function! s:print_throwpoint()
|
227
|
+
if v:throwpoint !~ 'vader#assert'
|
228
|
+
Log v:throwpoint
|
229
|
+
endif
|
230
|
+
endfunction
|
231
|
+
|
232
|
+
function! s:run(filename, cases, options)
|
233
|
+
let given = []
|
234
|
+
let before = []
|
235
|
+
let after = []
|
236
|
+
let then = []
|
237
|
+
let comment = { 'given': '', 'before': '', 'after': '' }
|
238
|
+
let total = len(a:cases)
|
239
|
+
let just = len(string(total))
|
240
|
+
let cnt = 0
|
241
|
+
let pending = 0
|
242
|
+
let success = 0
|
243
|
+
let exitfirst = get(a:options, 'exitfirst', 0)
|
244
|
+
let qfl = []
|
245
|
+
let g:vader_file = a:filename
|
246
|
+
|
247
|
+
call vader#window#append("Starting Vader: ". a:filename, 1)
|
248
|
+
|
249
|
+
for case in a:cases
|
250
|
+
let cnt += 1
|
251
|
+
let ok = 1
|
252
|
+
let prefix = printf('(%'.just.'d/%'.just.'d)', cnt, total)
|
253
|
+
|
254
|
+
for label in ['given', 'before', 'after', 'then']
|
255
|
+
if has_key(case, label)
|
256
|
+
execute 'let '.label.' = case[label]'
|
257
|
+
let comment[label] = get(case.comment, label, '')
|
258
|
+
endif
|
259
|
+
endfor
|
260
|
+
|
261
|
+
if !empty(given)
|
262
|
+
call s:append(prefix, 'given', comment.given)
|
263
|
+
endif
|
264
|
+
call vader#window#prepare(given, get(case, 'type', ''))
|
265
|
+
|
266
|
+
if !empty(before)
|
267
|
+
let s:indent = 2
|
268
|
+
let ok = ok && s:execute(prefix, 'before', before, '')
|
269
|
+
endif
|
270
|
+
|
271
|
+
let s:indent = 3
|
272
|
+
if has_key(case, 'execute')
|
273
|
+
call s:append(prefix, 'execute', s:comment(case, 'execute'))
|
274
|
+
let ok = ok && s:execute(prefix, 'execute', case.execute, get(case, 'lang_if', ''))
|
275
|
+
elseif has_key(case, 'do')
|
276
|
+
call s:append(prefix, 'do', s:comment(case, 'do'))
|
277
|
+
try
|
278
|
+
call vader#window#replay(case.do)
|
279
|
+
catch
|
280
|
+
call s:append(prefix, 'do', v:exception, 1)
|
281
|
+
call s:print_throwpoint()
|
282
|
+
let ok = 0
|
283
|
+
endtry
|
284
|
+
endif
|
285
|
+
|
286
|
+
if has_key(case, 'then')
|
287
|
+
call s:append(prefix, 'then', s:comment(case, 'then'))
|
288
|
+
let ok = ok && s:execute(prefix, 'then', then, '')
|
289
|
+
endif
|
290
|
+
|
291
|
+
if has_key(case, 'expect')
|
292
|
+
let result = vader#window#result()
|
293
|
+
let match = case.expect ==# result
|
294
|
+
if match
|
295
|
+
call s:append(prefix, 'expect', s:comment(case, 'expect'))
|
296
|
+
else
|
297
|
+
let begin = s:append(prefix, 'expect', s:comment(case, 'expect'), 1)
|
298
|
+
let ok = 0
|
299
|
+
let data = { 'type': get(case, 'type', ''), 'got': result, 'expect': case.expect }
|
300
|
+
call vader#window#append('- Expected:', 3)
|
301
|
+
for line in case.expect
|
302
|
+
call vader#window#append(line, 5, 0)
|
303
|
+
endfor
|
304
|
+
let end = vader#window#append('- Got:', 3)
|
305
|
+
for line in result
|
306
|
+
let end = vader#window#append(line, 5, 0)
|
307
|
+
endfor
|
308
|
+
call vader#window#set_data(begin, end, data)
|
309
|
+
endif
|
310
|
+
endif
|
311
|
+
|
312
|
+
if !empty(after)
|
313
|
+
let s:indent = 2
|
314
|
+
let ok = s:execute(prefix, 'after', after, '') && ok
|
315
|
+
endif
|
316
|
+
|
317
|
+
if ok
|
318
|
+
let success += 1
|
319
|
+
else
|
320
|
+
let pending += case.pending
|
321
|
+
let description = join(filter([
|
322
|
+
\ comment.given,
|
323
|
+
\ get(case.comment, 'do', get(case.comment, 'execute', '')),
|
324
|
+
\ get(case.comment, 'then', ''),
|
325
|
+
\ get(case.comment, 'expect', '')], '!empty(v:val)'), ' / ') .
|
326
|
+
\ ' (#'.s:error_line.')'
|
327
|
+
call add(qfl, { 'type': 'E', 'filename': a:filename, 'lnum': case.lnum, 'text': description })
|
328
|
+
if exitfirst && !case.pending
|
329
|
+
call vader#window#append('Stopping after first failure.', 2)
|
330
|
+
break
|
331
|
+
endif
|
332
|
+
endif
|
333
|
+
endfor
|
334
|
+
|
335
|
+
unlet g:vader_file
|
336
|
+
return [success, pending, total, qfl]
|
337
|
+
endfunction
|
338
|
+
|
339
|
+
function! s:append(prefix, type, message, ...)
|
340
|
+
let error = get(a:, 1, 0)
|
341
|
+
let message = (error ? '(X) ' : '') . a:message
|
342
|
+
let line = vader#window#append(printf("%s [%7s] %s", a:prefix, toupper(a:type), message), 2)
|
343
|
+
if error
|
344
|
+
let s:error_line = line
|
345
|
+
endif
|
346
|
+
return line
|
347
|
+
endfunction
|
348
|
+
|
@@ -0,0 +1,116 @@
|
|
1
|
+
" Copyright (c) 2013 Junegunn Choi
|
2
|
+
"
|
3
|
+
" MIT License
|
4
|
+
"
|
5
|
+
" Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
" a copy of this software and associated documentation files (the
|
7
|
+
" "Software"), to deal in the Software without restriction, including
|
8
|
+
" without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
" distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
" permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
" the following conditions:
|
12
|
+
"
|
13
|
+
" The above copyright notice and this permission notice shall be
|
14
|
+
" included in all copies or substantial portions of the Software.
|
15
|
+
"
|
16
|
+
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
|
25
|
+
let s:assertions = [0, 0]
|
26
|
+
|
27
|
+
let s:type_names = {
|
28
|
+
\ 0: 'Number',
|
29
|
+
\ 1: 'String',
|
30
|
+
\ 2: 'Funcref',
|
31
|
+
\ 3: 'List',
|
32
|
+
\ 4: 'Dictionary',
|
33
|
+
\ 5: 'Float',
|
34
|
+
\ 6: 'Boolean',
|
35
|
+
\ 7: 'Null' }
|
36
|
+
|
37
|
+
function! vader#assert#reset()
|
38
|
+
let s:assertions = [0, 0]
|
39
|
+
endfunction
|
40
|
+
|
41
|
+
function! vader#assert#stat()
|
42
|
+
return s:assertions
|
43
|
+
endfunction
|
44
|
+
|
45
|
+
function! vader#assert#true(...)
|
46
|
+
let s:assertions[1] += 1
|
47
|
+
|
48
|
+
if a:0 == 1
|
49
|
+
let [expr, message] = [a:1, "Assertion failure"]
|
50
|
+
elseif a:0 == 2
|
51
|
+
let [expr, message] = a:000
|
52
|
+
else
|
53
|
+
throw 'Invalid number of arguments'
|
54
|
+
endif
|
55
|
+
|
56
|
+
if !expr
|
57
|
+
throw message
|
58
|
+
endif
|
59
|
+
let s:assertions[0] += 1
|
60
|
+
return 1
|
61
|
+
endfunction
|
62
|
+
|
63
|
+
function! s:check_types(...)
|
64
|
+
let [Exp, Got] = a:000[0:1]
|
65
|
+
if type(Exp) !=# type(Got)
|
66
|
+
throw get(a:000, 2, printf("type mismatch: %s (%s) should be equal to %s (%s)",
|
67
|
+
\ string(Got), get(s:type_names, type(Got), type(Got)),
|
68
|
+
\ string(Exp), get(s:type_names, type(Exp), type(Exp))))
|
69
|
+
endif
|
70
|
+
endfunction
|
71
|
+
|
72
|
+
function! vader#assert#equal(...)
|
73
|
+
let [Exp, Got] = a:000[0:1]
|
74
|
+
let s:assertions[1] += 1
|
75
|
+
|
76
|
+
call s:check_types(Exp, Got)
|
77
|
+
if Exp !=# Got
|
78
|
+
let type = type(Exp)
|
79
|
+
let msg = (type == type({}) || type == type([]))
|
80
|
+
\ ? printf("Unequal %ss\n %%s should be equal to \n %%s", get(s:type_names, type))
|
81
|
+
\ : "%s should be equal to %s"
|
82
|
+
throw get(a:000, 2, printf(msg, string(Got), string(Exp)))
|
83
|
+
endif
|
84
|
+
let s:assertions[0] += 1
|
85
|
+
return 1
|
86
|
+
endfunction
|
87
|
+
|
88
|
+
function! vader#assert#not_equal(...)
|
89
|
+
let [Exp, Got] = a:000[0:1]
|
90
|
+
let s:assertions[1] += 1
|
91
|
+
|
92
|
+
call s:check_types(Exp, Got)
|
93
|
+
if Exp ==# Got
|
94
|
+
throw get(a:000, 2, printf("%s should not be equal to %s", string(Got), string(Exp)))
|
95
|
+
endif
|
96
|
+
let s:assertions[0] += 1
|
97
|
+
return 1
|
98
|
+
endfunction
|
99
|
+
|
100
|
+
function! vader#assert#throws(exp)
|
101
|
+
let s:assertions[1] += 1
|
102
|
+
|
103
|
+
let ok = 0
|
104
|
+
try
|
105
|
+
execute a:exp
|
106
|
+
catch
|
107
|
+
let g:vader_exception = v:exception
|
108
|
+
let g:vader_throwpoint = v:throwpoint
|
109
|
+
let ok = 1
|
110
|
+
endtry
|
111
|
+
|
112
|
+
let s:assertions[0] += ok
|
113
|
+
if ok | return 1
|
114
|
+
else | throw 'Exception expected but not raised: '.a:exp
|
115
|
+
endif
|
116
|
+
endfunction
|
@@ -0,0 +1,43 @@
|
|
1
|
+
function! vader#helper#syntax_at(...)
|
2
|
+
if a:0 < 2
|
3
|
+
let l:pos = getpos('.')
|
4
|
+
let l:cur_lnum = pos[1]
|
5
|
+
let l:cur_col = pos[2]
|
6
|
+
if a:0 == 0
|
7
|
+
let l:lnum = l:cur_lnum
|
8
|
+
let l:col = l:cur_col
|
9
|
+
else
|
10
|
+
let l:lnum = l:cur_lnum
|
11
|
+
let l:col = a:1
|
12
|
+
endif
|
13
|
+
else
|
14
|
+
let l:lnum = a:1
|
15
|
+
let l:col = a:2
|
16
|
+
endif
|
17
|
+
return synIDattr(synID(l:lnum, l:col, 1), 'name')
|
18
|
+
endfunction
|
19
|
+
|
20
|
+
function! vader#helper#syntax_of(pattern, ...)
|
21
|
+
if a:0 < 1
|
22
|
+
let l:nth = 1
|
23
|
+
else
|
24
|
+
let l:nth = a:1
|
25
|
+
endif
|
26
|
+
|
27
|
+
let l:pos_init = getpos('.')
|
28
|
+
call cursor(1, 1)
|
29
|
+
let found = search(a:pattern, 'cW')
|
30
|
+
while found != 0 && nth > 1
|
31
|
+
let found = search(a:pattern, 'W')
|
32
|
+
let nth -= 1
|
33
|
+
endwhile
|
34
|
+
|
35
|
+
if found
|
36
|
+
let l:pos = getpos('.')
|
37
|
+
let l:output = vader#helper#syntax_at(l:pos[1], l:pos[2])
|
38
|
+
else
|
39
|
+
let l:output = ''
|
40
|
+
endif
|
41
|
+
call setpos('.', l:pos_init)
|
42
|
+
return l:output
|
43
|
+
endfunction
|
@@ -0,0 +1,179 @@
|
|
1
|
+
" Copyright (c) 2013 Junegunn Choi
|
2
|
+
"
|
3
|
+
" MIT License
|
4
|
+
"
|
5
|
+
" Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
" a copy of this software and associated documentation files (the
|
7
|
+
" "Software"), to deal in the Software without restriction, including
|
8
|
+
" without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
" distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
" permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
" the following conditions:
|
12
|
+
"
|
13
|
+
" The above copyright notice and this permission notice shall be
|
14
|
+
" included in all copies or substantial portions of the Software.
|
15
|
+
"
|
16
|
+
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
function! vader#parser#parse(fn, line1, line2)
|
25
|
+
return s:parse_vader(s:read_vader(a:fn, a:line1, a:line2), a:line1)
|
26
|
+
endfunction
|
27
|
+
|
28
|
+
function! s:flush_buffer(cases, case, fn, lnum, raw, label, newlabel, buffer, final)
|
29
|
+
let is_validation = index(['then', 'expect'], a:newlabel) >= 0
|
30
|
+
let fpos = a:fn.':'.a:lnum
|
31
|
+
|
32
|
+
if empty(a:label)
|
33
|
+
if is_validation
|
34
|
+
echoerr 'Expect/Then should not appear before Do/Execute ('.fpos.')'
|
35
|
+
endif
|
36
|
+
else
|
37
|
+
let rev = reverse(copy(a:buffer))
|
38
|
+
while len(rev) > 0 && empty(rev[0])
|
39
|
+
call remove(rev, 0)
|
40
|
+
endwhile
|
41
|
+
|
42
|
+
let data = map(reverse(rev), (a:case.raw ? 'v:val' : 'strpart(v:val, 2)'))
|
43
|
+
let a:case[a:label] = data
|
44
|
+
if !empty(a:buffer)
|
45
|
+
call remove(a:buffer, 0, -1)
|
46
|
+
endif
|
47
|
+
|
48
|
+
let fulfilled = has_key(a:case, 'do') || has_key(a:case, 'execute')
|
49
|
+
if is_validation
|
50
|
+
if !fulfilled
|
51
|
+
echoerr 'Expect/Then should not appear before Do/Execute ('.fpos.')'
|
52
|
+
endif
|
53
|
+
if has_key(a:case, a:newlabel)
|
54
|
+
echoerr 'Expect/Then should appear only once for each Do/Execute ('.fpos.')'
|
55
|
+
endif
|
56
|
+
endif
|
57
|
+
|
58
|
+
if a:final ||
|
59
|
+
\ a:newlabel == 'given' ||
|
60
|
+
\ index(['before', 'after', 'do', 'execute'], a:newlabel) >= 0 && fulfilled
|
61
|
+
call add(a:cases, deepcopy(a:case))
|
62
|
+
let new = { 'comment': {}, 'lnum': a:lnum, 'pending': 0 }
|
63
|
+
if !empty(get(a:case, 'type', ''))
|
64
|
+
let new.type = a:case.type " To reuse Given block with type
|
65
|
+
endif
|
66
|
+
call extend(filter(a:case, '0'), new)
|
67
|
+
endif
|
68
|
+
endif
|
69
|
+
let a:case.raw = a:raw
|
70
|
+
endfunction
|
71
|
+
|
72
|
+
function! s:read_vader(fn, line1, line2)
|
73
|
+
let remains = readfile(a:fn)[a:line1 - 1 : a:line2 - 1]
|
74
|
+
let lnum = a:line1
|
75
|
+
let lines = []
|
76
|
+
let reserved = 0
|
77
|
+
let depth = 0 " Not a strict depth
|
78
|
+
let max_depth = 10
|
79
|
+
|
80
|
+
while len(remains) > 0
|
81
|
+
let line = remove(remains, 0)
|
82
|
+
let m = matchlist(line, '^Include\(\s*(.*)\s*\)\?:\s*\(.\{-}\)\s*$')
|
83
|
+
if !empty(m)
|
84
|
+
let file = findfile(m[2], fnamemodify(a:fn, ':h'))
|
85
|
+
if empty(file)
|
86
|
+
echoerr "Cannot find ".m[2]
|
87
|
+
endif
|
88
|
+
if reserved > 0
|
89
|
+
let depth += 1
|
90
|
+
if depth >= max_depth
|
91
|
+
echoerr 'Recursive inclusion limit exceeded'
|
92
|
+
endif
|
93
|
+
let reserved -= 1
|
94
|
+
endif
|
95
|
+
let included = readfile(file)
|
96
|
+
let reserved += len(included)
|
97
|
+
call extend(remains, included, 0)
|
98
|
+
continue
|
99
|
+
end
|
100
|
+
|
101
|
+
call add(lines, [a:fn, lnum, line])
|
102
|
+
if reserved > 0
|
103
|
+
let reserved -= 1
|
104
|
+
end
|
105
|
+
if reserved == 0
|
106
|
+
let depth = 0
|
107
|
+
let lnum += 1
|
108
|
+
endif
|
109
|
+
endwhile
|
110
|
+
|
111
|
+
return lines
|
112
|
+
endfunction
|
113
|
+
|
114
|
+
function! s:parse_vader(lines, line1)
|
115
|
+
let label = ''
|
116
|
+
let newlabel = ''
|
117
|
+
let buffer = []
|
118
|
+
let cases = []
|
119
|
+
let case = { 'lnum': a:line1, 'comment': {}, 'pending': 0, 'raw': 0 }
|
120
|
+
|
121
|
+
for [fn, lnum, line] in a:lines
|
122
|
+
" Comment / separators
|
123
|
+
if !case.raw && line =~ '^[#"=~*^-]'
|
124
|
+
continue
|
125
|
+
endif
|
126
|
+
|
127
|
+
let matched = 0
|
128
|
+
for l in ['Before', 'After', 'Given', 'Execute', 'Expect', 'Do', 'Then']
|
129
|
+
let m = matchlist(line, '^'.l.'\%(\s\+\([^:;(]\+\)\)\?\s*\%((\(.*\))\)\?\s*\([:;]\)\s*$')
|
130
|
+
if !empty(m)
|
131
|
+
let newlabel = tolower(l)
|
132
|
+
call s:flush_buffer(cases, case, fn, lnum, m[3] == ';', label, newlabel, buffer, 0)
|
133
|
+
|
134
|
+
let label = newlabel
|
135
|
+
let arg = m[1]
|
136
|
+
let comment = m[2]
|
137
|
+
if !empty(arg)
|
138
|
+
if l == 'Given' | let case.type = arg
|
139
|
+
elseif l == 'Execute' | let case.lang_if = arg
|
140
|
+
end
|
141
|
+
elseif l == 'Given'
|
142
|
+
let case.type = ''
|
143
|
+
endif
|
144
|
+
if !empty(comment)
|
145
|
+
let case.comment[tolower(l)] = comment
|
146
|
+
if index(['do', 'execute'], label) >= 0 &&
|
147
|
+
\ comment =~# '\<TODO\>\|\<FIXME\>'
|
148
|
+
let case.pending = 1
|
149
|
+
endif
|
150
|
+
endif
|
151
|
+
let matched = 1
|
152
|
+
break
|
153
|
+
endif
|
154
|
+
endfor
|
155
|
+
if matched | continue | endif
|
156
|
+
|
157
|
+
" Continuation
|
158
|
+
if !empty(line) && !case.raw && line !~ '^ '
|
159
|
+
throw 'Syntax error (line does not start with two spaces): ' . line
|
160
|
+
endif
|
161
|
+
if !empty(label)
|
162
|
+
call add(buffer, line)
|
163
|
+
endif
|
164
|
+
endfor
|
165
|
+
call s:flush_buffer(cases, case, fn, lnum, case.raw, label, '', buffer, 1)
|
166
|
+
|
167
|
+
let ret = []
|
168
|
+
let prev = {}
|
169
|
+
for case in cases
|
170
|
+
if has_key(case, "do") || has_key(case, "execute")
|
171
|
+
call add(ret, extend(prev, case))
|
172
|
+
let prev = {}
|
173
|
+
else
|
174
|
+
let prev = case
|
175
|
+
endif
|
176
|
+
endfor
|
177
|
+
return ret
|
178
|
+
endfunction
|
179
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
" Copyright (c) 2014 Junegunn Choi
|
2
|
+
"
|
3
|
+
" MIT License
|
4
|
+
"
|
5
|
+
" Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
" a copy of this software and associated documentation files (the
|
7
|
+
" "Software"), to deal in the Software without restriction, including
|
8
|
+
" without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
" distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
" permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
" the following conditions:
|
12
|
+
"
|
13
|
+
" The above copyright notice and this permission notice shall be
|
14
|
+
" included in all copies or substantial portions of the Software.
|
15
|
+
"
|
16
|
+
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
let s:ifs = ['lua', 'perl', 'ruby', 'python']
|
25
|
+
|
26
|
+
function! vader#syntax#reset()
|
27
|
+
let b:vader_types = {}
|
28
|
+
endfunction
|
29
|
+
|
30
|
+
function! vader#syntax#include(l1, l2)
|
31
|
+
let lines = filter(getline(a:l1, a:l2), '!empty(v:val) && v:val[0] != " "')
|
32
|
+
for line in lines
|
33
|
+
let match = matchlist(line, '^\(Given\|Expect\|Execute\)\s\+\([^:; (]\+\)')
|
34
|
+
if len(match) >= 3
|
35
|
+
silent! call s:load(match[2])
|
36
|
+
endif
|
37
|
+
endfor
|
38
|
+
endfunction
|
39
|
+
|
40
|
+
function! vader#syntax#_head()
|
41
|
+
return '\(\(^\(Given\|Expect\|Do\|Execute\|Then\|Before\|After\)\(\s\+[^:;(]\+\)\?\s*\((.*)\)\?\s*[:;]\s*$\)\|\(^Include\(\s*(.*)\)\?\s*:\)\)\@='
|
42
|
+
endfunction
|
43
|
+
|
44
|
+
function! s:load(type)
|
45
|
+
let b:vader_types = get(b:, 'vader_types', {})
|
46
|
+
if has_key(b:vader_types, a:type)
|
47
|
+
return
|
48
|
+
endif
|
49
|
+
|
50
|
+
if empty(globpath(&rtp, "syntax/".a:type.".vim", 1))
|
51
|
+
return
|
52
|
+
endif
|
53
|
+
|
54
|
+
let b:vader_types[a:type] = 1
|
55
|
+
|
56
|
+
unlet! b:current_syntax
|
57
|
+
execute printf('syn include @%sSnippet syntax/%s.vim', a:type, a:type)
|
58
|
+
execute printf('syn region vader_%s start=/^\s\{2,}/ end=/^\S\@=/ contains=@%sSnippet contained', a:type, a:type)
|
59
|
+
execute printf('syn region vader_raw_%s start=/\(;\s*$\)\@<=/ end=/%s/ contains=@%sSnippet contained', a:type, vader#syntax#_head(), a:type)
|
60
|
+
|
61
|
+
call s:define_syntax_region('Given', a:type)
|
62
|
+
call s:define_syntax_region('Expect', a:type)
|
63
|
+
if index(s:ifs, a:type) >= 0
|
64
|
+
call s:define_syntax_region('Execute', a:type)
|
65
|
+
endif
|
66
|
+
let b:current_syntax = 'vader'
|
67
|
+
endfunction
|
68
|
+
|
69
|
+
function! s:define_syntax_region(block, lang)
|
70
|
+
execute printf('syn region vader%s start=/^%s\s\+%s\s*\((.*)\)\?\s*:\s*$/ end=/\(^[^ ^#~=*-]\)\@=/ contains=vader%sType,vaderMessage,@vaderIgnored,vader_%s nextgroup=@vaderTopLevel skipempty keepend', a:block, a:block, a:lang, a:block, a:lang)
|
71
|
+
execute printf('syn region vader%sRaw start=/^%s\s\+%s\s*\((.*)\)\?\s*;\s*$/ end=/%s/ contains=vader%sType,vaderMessage,@vaderIgnored,vader_raw_%s nextgroup=@vaderTopLevel skipempty keepend', a:block, a:block, a:lang, vader#syntax#_head(), a:block, a:lang)
|
72
|
+
endfunction
|
73
|
+
|
@@ -0,0 +1,205 @@
|
|
1
|
+
" Copyright (c) 2013 Junegunn Choi
|
2
|
+
"
|
3
|
+
" MIT License
|
4
|
+
"
|
5
|
+
" Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
" a copy of this software and associated documentation files (the
|
7
|
+
" "Software"), to deal in the Software without restriction, including
|
8
|
+
" without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
" distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
" permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
" the following conditions:
|
12
|
+
"
|
13
|
+
" The above copyright notice and this permission notice shall be
|
14
|
+
" included in all copies or substantial portions of the Software.
|
15
|
+
"
|
16
|
+
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
let s:quickfix_bfr = 0
|
25
|
+
let s:console_bfr = 0
|
26
|
+
let s:console_tab = 0
|
27
|
+
let s:workbench_tab = 0
|
28
|
+
let s:workbench_bfr = 0
|
29
|
+
|
30
|
+
function! s:switch_to_console()
|
31
|
+
execute 'normal! '.s:console_tab.'gt'
|
32
|
+
call append(line('$') - 1, s:console_buffered)
|
33
|
+
let s:console_buffered = []
|
34
|
+
endfunction
|
35
|
+
|
36
|
+
function! s:switch_to_workbench()
|
37
|
+
execute 'normal! '.s:workbench_tab.'gt'
|
38
|
+
execute 'b!' s:workbench_bfr
|
39
|
+
endfunction
|
40
|
+
|
41
|
+
function! vader#window#open()
|
42
|
+
execute 'silent! bd' s:console_bfr
|
43
|
+
execute 'silent! bd' s:workbench_bfr
|
44
|
+
if bufexists(s:quickfix_bfr)
|
45
|
+
execute "silent! bd ".s:quickfix_bfr
|
46
|
+
endif
|
47
|
+
|
48
|
+
let s:prev_winid = exists('*win_getid') ? win_getid() : 0
|
49
|
+
tabnew
|
50
|
+
setlocal buftype=nofile noswapfile nospell
|
51
|
+
setf vader-result
|
52
|
+
silent f \[Vader\]
|
53
|
+
let s:console_tab = tabpagenr()
|
54
|
+
let s:console_bfr = bufnr('')
|
55
|
+
let s:console_buffered = []
|
56
|
+
let b:vader_data = {}
|
57
|
+
nnoremap <silent> <buffer> <CR> :call <SID>action(line('.'))<CR>
|
58
|
+
|
59
|
+
tabnew
|
60
|
+
setlocal buftype=nofile
|
61
|
+
setlocal noswapfile
|
62
|
+
silent f \[Vader-workbench\]
|
63
|
+
let s:workbench_tab = tabpagenr()
|
64
|
+
let s:workbench_bfr = bufnr('')
|
65
|
+
endfunction
|
66
|
+
|
67
|
+
function! vader#window#execute(lines, lang_if)
|
68
|
+
let temp = tempname()
|
69
|
+
try
|
70
|
+
if empty(a:lang_if)
|
71
|
+
let lines = a:lines
|
72
|
+
else
|
73
|
+
let lines = copy(a:lines)
|
74
|
+
call insert(lines, a:lang_if . ' << __VADER__LANG__IF__')
|
75
|
+
call add(lines, '__VADER__LANG__IF__')
|
76
|
+
endif
|
77
|
+
call writefile(lines, temp)
|
78
|
+
execute 'source '.temp
|
79
|
+
finally
|
80
|
+
call delete(temp)
|
81
|
+
endtry
|
82
|
+
endfunction
|
83
|
+
|
84
|
+
function! vader#window#replay(lines)
|
85
|
+
call setreg('x', substitute(join(a:lines, ''), '\\<[^>]\+>', '\=eval("\"".submatch(0)."\"")', 'g'), 'c')
|
86
|
+
normal! @x
|
87
|
+
endfunction
|
88
|
+
|
89
|
+
function! vader#window#result()
|
90
|
+
return getline(1, line('$'))
|
91
|
+
endfunction
|
92
|
+
|
93
|
+
function! vader#window#append(message, indent, ...)
|
94
|
+
let message = repeat(' ', a:indent) . a:message
|
95
|
+
if get(a:, 1, 1)
|
96
|
+
let message = substitute(message, '\s*$', '', '')
|
97
|
+
endif
|
98
|
+
if !exists('s:console_buffered')
|
99
|
+
echom 'Vader:' message
|
100
|
+
return 0
|
101
|
+
endif
|
102
|
+
call add(s:console_buffered, message)
|
103
|
+
return len(s:console_buffered)
|
104
|
+
endfunction
|
105
|
+
|
106
|
+
function! vader#window#prepare(lines, type)
|
107
|
+
call s:switch_to_workbench()
|
108
|
+
execute 'setlocal modifiable filetype='.a:type
|
109
|
+
|
110
|
+
silent %d _
|
111
|
+
for line in a:lines
|
112
|
+
call append(line('$') - 1, line)
|
113
|
+
endfor
|
114
|
+
silent d _
|
115
|
+
execute "normal! \<c-\>\<c-n>gg0"
|
116
|
+
|
117
|
+
let &undolevels = &undolevels " Break undo block
|
118
|
+
endfunction
|
119
|
+
|
120
|
+
function! vader#window#cleanup()
|
121
|
+
execute 'silent! bd' s:workbench_bfr
|
122
|
+
call s:switch_to_console()
|
123
|
+
setlocal nomodifiable
|
124
|
+
nnoremap <silent> <buffer> q :call <SID>quit()<CR><CR>
|
125
|
+
normal! Gzb
|
126
|
+
endfunction
|
127
|
+
|
128
|
+
function! vader#window#copen()
|
129
|
+
copen
|
130
|
+
let s:quickfix_bfr = bufnr('')
|
131
|
+
1wincmd w
|
132
|
+
normal! Gzb
|
133
|
+
2wincmd w
|
134
|
+
nnoremap <silent> <buffer> q :call <SID>quit()<CR><CR>
|
135
|
+
nnoremap <silent> <buffer> <CR> :call <SID>move()<CR><CR>
|
136
|
+
endfunction
|
137
|
+
|
138
|
+
function! vader#window#set_data(l1, l2, data)
|
139
|
+
try
|
140
|
+
let var = getbufvar(s:console_bfr, 'vader_data', {})
|
141
|
+
for l in range(a:l1, a:l2)
|
142
|
+
let var[l] = a:data
|
143
|
+
endfor
|
144
|
+
call setbufvar(s:console_bfr, 'vader_data', var)
|
145
|
+
catch
|
146
|
+
endtry
|
147
|
+
endfunction
|
148
|
+
|
149
|
+
function! s:scratch(type, data, title)
|
150
|
+
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap modifiable
|
151
|
+
silent! execute 'setf '.a:type
|
152
|
+
call append(0, a:data)
|
153
|
+
nnoremap <silent> <buffer> q :tabclose<cr>
|
154
|
+
autocmd TabLeave <buffer> tabclose
|
155
|
+
|
156
|
+
execute 'silent f '.escape(a:title, '[]')
|
157
|
+
normal! G"_ddgg
|
158
|
+
diffthis
|
159
|
+
setlocal nomodifiable
|
160
|
+
endfunction
|
161
|
+
|
162
|
+
function! s:action(line)
|
163
|
+
if has_key(b:vader_data, a:line)
|
164
|
+
let data = b:vader_data[a:line]
|
165
|
+
if has_key(data, 'expect')
|
166
|
+
tabnew
|
167
|
+
call s:scratch(data.type, data.expect, '[Vader-expected]')
|
168
|
+
|
169
|
+
vertical botright new
|
170
|
+
call s:scratch(data.type, data.got, '[Vader-got]')
|
171
|
+
|
172
|
+
redraw
|
173
|
+
echo "Press 'q' to close"
|
174
|
+
endif
|
175
|
+
else
|
176
|
+
execute "normal! \<CR>"
|
177
|
+
endif
|
178
|
+
endfunction
|
179
|
+
|
180
|
+
function! s:move()
|
181
|
+
let lno = matchstr(getline('.'), '(#[0-9]\+)')[2:-2]
|
182
|
+
let wq = winnr()
|
183
|
+
let wc = bufwinnr(s:console_bfr)
|
184
|
+
if wc >= 0
|
185
|
+
execute wc . 'wincmd w'
|
186
|
+
let scrolloff = &scrolloff
|
187
|
+
set scrolloff=0
|
188
|
+
execute lno
|
189
|
+
normal! zt
|
190
|
+
redraw
|
191
|
+
let &scrolloff = scrolloff
|
192
|
+
execute wq . 'wincmd w'
|
193
|
+
endif
|
194
|
+
endfunction
|
195
|
+
|
196
|
+
function! s:quit()
|
197
|
+
if s:prev_winid
|
198
|
+
let [s:t, s:w] = win_id2tabwin(s:prev_winid)
|
199
|
+
if s:t
|
200
|
+
execute printf('tabnext %d | %dwincmd w | %dtabclose', s:t, s:w, s:console_tab)
|
201
|
+
return
|
202
|
+
endif
|
203
|
+
endif
|
204
|
+
tabclose
|
205
|
+
endfunction
|
@@ -0,0 +1,37 @@
|
|
1
|
+
" Copyright (c) 2015 Junegunn Choi
|
2
|
+
"
|
3
|
+
" MIT License
|
4
|
+
"
|
5
|
+
" Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
" a copy of this software and associated documentation files (the
|
7
|
+
" "Software"), to deal in the Software without restriction, including
|
8
|
+
" without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
" distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
" permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
" the following conditions:
|
12
|
+
"
|
13
|
+
" The above copyright notice and this permission notice shall be
|
14
|
+
" included in all copies or substantial portions of the Software.
|
15
|
+
"
|
16
|
+
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
if exists('g:loaded_vader') || &compatible
|
25
|
+
finish
|
26
|
+
endif
|
27
|
+
let g:loaded_vader = 1
|
28
|
+
|
29
|
+
function! s:vader(...) range
|
30
|
+
if a:lastline - a:firstline > 0 && a:0 > 1
|
31
|
+
echoerr 'Range and file arguments are mutually exclusive'
|
32
|
+
return
|
33
|
+
endif
|
34
|
+
execute printf("%d,%dcall vader#run(%s)", a:firstline, a:lastline, string(a:000)[1:-2])
|
35
|
+
endfunction
|
36
|
+
|
37
|
+
command! -bang -nargs=* -range -complete=file Vader <line1>,<line2>call s:vader(<bang>0, <f-args>)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neovim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Genco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -154,6 +154,13 @@ files:
|
|
154
154
|
- spec/integration/runtime/rplugin/ruby/autocmds.rb
|
155
155
|
- spec/integration/runtime/rplugin/ruby/commands.rb
|
156
156
|
- spec/integration/runtime/rplugin/ruby/functions.rb
|
157
|
+
- spec/integration/runtime/vader.vim/autoload/vader.vim
|
158
|
+
- spec/integration/runtime/vader.vim/autoload/vader/assert.vim
|
159
|
+
- spec/integration/runtime/vader.vim/autoload/vader/helper.vim
|
160
|
+
- spec/integration/runtime/vader.vim/autoload/vader/parser.vim
|
161
|
+
- spec/integration/runtime/vader.vim/autoload/vader/syntax.vim
|
162
|
+
- spec/integration/runtime/vader.vim/autoload/vader/window.vim
|
163
|
+
- spec/integration/runtime/vader.vim/plugin/vader.vim
|
157
164
|
- spec/integration_spec.rb
|
158
165
|
- spec/neovim/buffer_spec.rb
|
159
166
|
- spec/neovim/client_spec.rb
|
@@ -225,6 +232,13 @@ test_files:
|
|
225
232
|
- spec/integration/runtime/rplugin/ruby/autocmds.rb
|
226
233
|
- spec/integration/runtime/rplugin/ruby/commands.rb
|
227
234
|
- spec/integration/runtime/rplugin/ruby/functions.rb
|
235
|
+
- spec/integration/runtime/vader.vim/autoload/vader.vim
|
236
|
+
- spec/integration/runtime/vader.vim/autoload/vader/assert.vim
|
237
|
+
- spec/integration/runtime/vader.vim/autoload/vader/helper.vim
|
238
|
+
- spec/integration/runtime/vader.vim/autoload/vader/parser.vim
|
239
|
+
- spec/integration/runtime/vader.vim/autoload/vader/syntax.vim
|
240
|
+
- spec/integration/runtime/vader.vim/autoload/vader/window.vim
|
241
|
+
- spec/integration/runtime/vader.vim/plugin/vader.vim
|
228
242
|
- spec/integration_spec.rb
|
229
243
|
- spec/neovim/buffer_spec.rb
|
230
244
|
- spec/neovim/client_spec.rb
|