Improve auto placeholder feature

This commit is contained in:
Shougo Matsushita 2015-12-19 12:27:49 +09:00
parent e3118e888f
commit fef60dbe6c
2 changed files with 11 additions and 0 deletions

View File

@ -86,6 +86,9 @@ endfunction"}}}
function! neosnippet#get_placeholder_marker_substitute_nonzero_pattern() "{{{ function! neosnippet#get_placeholder_marker_substitute_nonzero_pattern() "{{{
return '\${\([1-9]\d*\%(:.\{-}\)\?\\\@<!\)}' return '\${\([1-9]\d*\%(:.\{-}\)\?\\\@<!\)}'
endfunction"}}} endfunction"}}}
function! neosnippet#get_placeholder_marker_substitute_zero_pattern() "{{{
return '\${\(0\%(:.\{-}\)\?\\\@<!\)}'
endfunction"}}}
function! neosnippet#get_placeholder_marker_default_pattern() "{{{ function! neosnippet#get_placeholder_marker_default_pattern() "{{{
return '<`\d\+:\zs.\{-}\ze\\\@<!`>' return '<`\d\+:\zs.\{-}\ze\\\@<!`>'
endfunction"}}} endfunction"}}}

View File

@ -238,6 +238,14 @@ endfunction"}}}
function! neosnippet#parser#_initialize_snippet(dict, path, line, pattern, name) "{{{ function! neosnippet#parser#_initialize_snippet(dict, path, line, pattern, name) "{{{
let a:dict.word = substitute(a:dict.word, '\n\+$', '', '') let a:dict.word = substitute(a:dict.word, '\n\+$', '', '')
if a:dict.word !~ '\n'
\ && a:dict.word !~
\ neosnippet#get_placeholder_marker_substitute_pattern().'$'
\ && a:dict.word !~
\ neosnippet#get_placeholder_marker_substitute_zero_pattern()
" Add placeholder.
let a:dict.word .= '${0}'
endif
if !has_key(a:dict, 'abbr') || a:dict.abbr == '' if !has_key(a:dict, 'abbr') || a:dict.abbr == ''
" Set default abbr. " Set default abbr.