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:
Amir
2024-10-06 10:25:50 +02:00
parent ee7e062909
commit 46294d589d
202 changed files with 306918 additions and 203617 deletions

View File

@ -78,11 +78,32 @@ function! s:parser_varend() dict abort
call extend(ret, self.placeholder())
elseif self.same('/')
call add(ret, self.subst())
elseif self.next == '|'
call add(ret, self.select())
endif
call self.same('}')
return ret
endfunction
function! s:parser_select() dict abort
let items = []
while self.same('|')
let str = self.text('|}')
call s:mark_vars_in_select(str)
call add(items, str)
endwhile
return ['select'] + items
endfunction
function! s:mark_vars_in_select(str)
for item in a:str
if type(item) == type([])
call add(item, { 'select' : 1 })
endif
unlet! item " avoid E706
endfor
endfunction
function! s:parser_placeholder() dict abort
let ret = self.text('}')
return empty(ret) ? [''] : ret
@ -171,6 +192,7 @@ endfunction
function! s:parser_text(till) dict abort
let ret = []
let till = '\V\[' . escape(a:till, '\') . ']'
let target = ret
while self.pos < self.len
@ -206,7 +228,7 @@ function! s:parser_text(till) dict abort
endif
" Empty lines are ignored if this is tested at the start of an iteration
if self.next ==# a:till
if self.next =~# till
break
endif
endwhile
@ -268,11 +290,26 @@ endfunction
function! s:parser_create_stubs() dict abort
for [id, dict] in items(self.vars)
" only instance is in a selection, so remove it
if len(dict.instances) == 1 && type(dict.instances[0][-1]) == type({})
\ && dict.instances[0][-1] == { 'select' : 1 }
call remove(self.vars, id)
continue
endif
for i in dict.instances
if len(i) > 1 && type(i[1]) != type({})
if !has_key(dict, 'placeholder')
let dict.placeholder = i[1:]
call add(i, dict)
if type(i[1]) == type([]) && i[1][0] == 'select'
let dict.placeholder = i[1][1]
let dict.items = i[1][1:]
let i[1] = dict.placeholder
call add(i, dict)
else
let dict.placeholder = i[1:]
call add(i, dict)
endif
else
unlet i[1:]
call s:create_mirror_stub(i, dict)
@ -281,6 +318,7 @@ function! s:parser_create_stubs() dict abort
call s:create_mirror_stub(i, dict)
endif
endfor
if !has_key(dict, 'placeholder')
let dict.placeholder = []
let j = 0
@ -292,6 +330,7 @@ function! s:parser_create_stubs() dict abort
call add(dict.instances[j], dict)
call filter(dict.mirrors, 'v:val isnot oldstub')
endif
unlet dict.instances
endfor
@ -301,9 +340,13 @@ function! s:create_mirror_stub(mirror, dict)
let mirror = a:mirror
let dict = a:dict
let stub = get(mirror, 1, {})
call add(mirror, stub)
let dict.mirrors = get(dict, 'mirrors', [])
call add(dict.mirrors, stub)
if stub == { 'select' : 1 }
unlet mirror[1:]
else
call add(mirror, stub)
let dict.mirrors = get(dict, 'mirrors', [])
call add(dict.mirrors, stub)
endif
endfunction
function! snipmate#parse#snippet(text, ...) abort
@ -318,6 +361,6 @@ endfunction
call extend(s:parser_proto, snipmate#util#add_methods(s:sfile(), 'parser',
\ [ 'advance', 'same', 'id', 'add_var', 'var', 'varend',
\ 'line', 'string', 'create_stubs', 'pat',
\ 'line', 'string', 'create_stubs', 'pat', 'select',
\ 'placeholder', 'subst', 'expr', 'text', 'parse',
\ ]), 'error')