Add angle support
This commit is contained in:
parent
0b3b441bef
commit
ae512e4818
@ -315,6 +315,26 @@ function! neosnippet#parser#_get_completed_snippet(completed_item) "{{{
|
||||
" Make snippet arguments
|
||||
let cnt = 1
|
||||
let snippet = ''
|
||||
|
||||
if abbr =~ '<.\+>'
|
||||
" Add angle analysis
|
||||
let snippet .= '<'
|
||||
|
||||
let args = ''
|
||||
for arg in split(substitute(
|
||||
\ neosnippet#parser#_get_in_paren('<', '>', abbr),
|
||||
\ '<\zs.\{-}\ze>', '', 'g'), '[^[]\zs\s*,\s*')
|
||||
if args != ''
|
||||
let args .= ', '
|
||||
endif
|
||||
let args .= printf('${%d:#:%s}', cnt, escape(arg, '{}'))
|
||||
let cnt += 1
|
||||
endfor
|
||||
let snippet .= args
|
||||
let snippet .= '>'
|
||||
endif
|
||||
|
||||
let args = ''
|
||||
for arg in split(substitute(
|
||||
\ neosnippet#parser#_get_in_paren(key, pair, abbr),
|
||||
\ key.'\zs.\{-}\ze'.pair, '', 'g'), '[^[]\zs\s*,\s*')
|
||||
@ -323,12 +343,13 @@ function! neosnippet#parser#_get_completed_snippet(completed_item) "{{{
|
||||
continue
|
||||
endif
|
||||
|
||||
if cnt != 1
|
||||
let snippet .= ', '
|
||||
if args != ''
|
||||
let args .= ', '
|
||||
endif
|
||||
let snippet .= printf('${%d:#:%s}', cnt, escape(arg, '{}'))
|
||||
let args .= printf('${%d:#:%s}', cnt, escape(arg, '{}'))
|
||||
let cnt += 1
|
||||
endfor
|
||||
let snippet .= args
|
||||
|
||||
let snippet .= pair
|
||||
|
||||
|
@ -67,5 +67,10 @@ function! s:suite.get_completed_snippet()
|
||||
\ 'word' : 'foo{', 'abbr' : 'foo{piyo}',
|
||||
\ 'menu' : '', 'info' : ''
|
||||
\ }), '${1:#:piyo}}${2}')
|
||||
|
||||
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
|
||||
\ 'word' : 'Dictionary(', 'abbr' : 'Dictionary<Key, Value>(foo)',
|
||||
\ 'menu' : '', 'info' : ''
|
||||
\ }), '<${1:#:Key}, ${2:#:Value}>${3:#:foo})${4}')
|
||||
endfunction
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user