Support ${VISUAL} keyword

This commit is contained in:
sasdf 2018-06-03 18:53:52 +08:00
parent fa7cc15aee
commit 9265c5483a
2 changed files with 5 additions and 4 deletions

View File

@ -59,19 +59,19 @@ endfunction
" Get marker patterns.
function! neosnippet#get_placeholder_target_marker_pattern() abort
return '\%(\\\@<!\|\\\\\zs\)\${\d\+:\(#:\)\?TARGET\%(:.\{-}\)\?\\\@<!}'
return '\%(\\\@<!\|\\\\\zs\)\${\d\+:\(#:\)\?\%(TARGET\|\${VISUAL\%(:.\{-}\)\?}\)\%(:.\{-}\)\?\\\@<!}'
endfunction
function! neosnippet#get_placeholder_marker_pattern() abort
return '<`\d\+\%(:.\{-}\)\?\\\@<!`>'
endfunction
function! neosnippet#get_placeholder_marker_substitute_pattern() abort
return '\%(\\\@<!\|\\\\\zs\)\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}'
return '\%(\\\@<!\|\\\\\zs\)\${\(\d\+\%(:\%(\${VISUAL\%(:.\{-}\)\?}\)\?.\{-}\)\?\\\@<!\)}'
endfunction
function! neosnippet#get_placeholder_marker_substitute_nonzero_pattern() abort
return '\%(\\\@<!\|\\\\\zs\)\${\([1-9]\d*\%(:.\{-}\)\?\\\@<!\)}'
return '\%(\\\@<!\|\\\\\zs\)\${\([1-9]\d*\%(:\%(\${VISUAL\%(:.\{-}\)\?}\)\?.\{-}\)\?\\\@<!\)}'
endfunction
function! neosnippet#get_placeholder_marker_substitute_zero_pattern() abort
return '\%(\\\@<!\|\\\\\zs\)\${\(0\%(:.\{-}\)\?\\\@<!\)}'
return '\%(\\\@<!\|\\\\\zs\)\${\(0\%(:\%(\${VISUAL\%(:.\{-}\)\?}\)\?.\{-}\)\?\\\@<!\)}'
endfunction
function! neosnippet#get_placeholder_marker_default_pattern() abort
return '<`\d\+:\zs.\{-}\ze\\\@<!`>'

View File

@ -336,6 +336,7 @@ function! s:expand_placeholder(start, end, holder_cnt, line, ...) abort
" Remove optional marker
let default = substitute(default, '^#:', '', '')
let default = substitute(default, '\${VISUAL\(:.\{-}\)\?}', 'TARGET\1', '')
let is_target = (default =~ '^TARGET\>' && neosnippet.target != '')
let default = substitute(default, '^TARGET:\?', neosnippet.target, '')