Merge pull request #430 from sasdf/master

Support ${VISUAL} keyword
This commit is contained in:
Shougo 2018-06-04 08:47:04 +09:00 committed by GitHub
commit aac0d6553e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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, '')