1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 09:35:01 +08:00

Updated plugins

This commit is contained in:
amix
2017-03-14 16:16:07 +01:00
parent 7b7a056680
commit 395c077dcb
15 changed files with 170 additions and 67 deletions

View File

@ -6,7 +6,7 @@ endif
try
call tlib#input#List('mi', '', [])
catch /.*/
echoe "you're missing tlib. See install instructions at ".expand('<sfile>:h:h').'/README.md'
echoe "tlib is missing. See install instructions at ".expand('<sfile>:h:h').'/README.md'
endtry
fun! Filename(...) abort
@ -117,7 +117,14 @@ function! snipMate#sniplist_str(snippet, stops) abort
if type(item) == type('')
let str .= item
elseif type(item) == type([])
let str .= snipMate#placeholder_str(item[0], a:stops)
let placeholder = snipMate#placeholder_str(item[0], a:stops)
if len(item) > 1 && type(item[1]) == type({})
let placeholder = substitute(placeholder,
\ get(item[1], 'pat', ''),
\ get(item[1], 'sub', ''),
\ get(item[1], 'flags', ''))
endif
let str .= placeholder
endif
let pos += 1

View File

@ -171,6 +171,7 @@ endfunction
function! s:parser_text(till) dict abort
let ret = []
let target = ret
while self.pos < self.len
let lines = []
@ -180,8 +181,12 @@ function! s:parser_text(till) dict abort
if !empty(var)
if var[0] is# 'VISUAL'
let lines = s:visual_placeholder(var, self.indent)
" Remove trailing newline. See #245
if lines[-1] == '' && self.next == "\n"
call remove(lines, -1)
endif
elseif var[0] >= 0
call add(ret, var)
call add(target, var)
call self.add_var(var)
endif
endif
@ -192,8 +197,12 @@ function! s:parser_text(till) dict abort
endif
if !empty(lines)
call add(ret, lines[0])
call extend(self.stored_lines, lines[1:])
call add(target, lines[0])
call extend(self.stored_lines, lines[1:-2])
" Don't change targets if there's only one line
if exists("lines[1]")
let target = [lines[-1]]
endif
endif
" Empty lines are ignored if this is tested at the start of an iteration
@ -203,6 +212,11 @@ function! s:parser_text(till) dict abort
endwhile
call s:join_consecutive_strings(ret)
if target isnot ret
call s:join_consecutive_strings(target)
call extend(self.stored_lines, target)
endif
return ret
endfunction

View File

@ -118,6 +118,16 @@ describe 'snippet parser'
\ ["\t baz"], ["x"]]
end
it 'removes newlines from the end of VISUALs if before an end of line'
let b:snipmate_visual = "1\n2\n"
Expect Parse("x\n$VISUAL\nx") == [['x'], ['1'], ['2'], ['x']]
end
it 'splits the before and after a $VISUAL if it is multiline'
let b:snipmate_visual = "1\n2\n3"
Expect Parse("foo $VISUAL bar") == [['foo 1'], ['2'], ['3 bar']]
end
it 'determines which var with an id is the stop'
let [snip, stops] = Parse("$1$1$1", 0, 1)
Expect snip == [[[1, "", stops[1]], [1, {}], [1, {}]]]