Browse Source

Fix #379 snippet parse

PR/fix-warning
Shougo Matsushita 7 years ago
parent
commit
affc71bd9f
3 changed files with 10 additions and 14 deletions
  1. +4
    -4
      autoload/neosnippet.vim
  2. +5
    -9
      autoload/neosnippet/view.vim
  3. +1
    -1
      syntax/neosnippet.vim

+ 4
- 4
autoload/neosnippet.vim View File

@@ -81,19 +81,19 @@ endfunction"}}}

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


+ 5
- 9
autoload/neosnippet/view.vim View File

@@ -58,20 +58,16 @@ function! neosnippet#view#_insert(snippet, options, cur_text, col) abort "{{{
let snip_word = s:eval_snippet(snip_word)
endif

" Substitute escaped `.
let snip_word = substitute(snip_word, '\\`', '`', 'g')

" Substitute markers.
let snip_word = substitute(snip_word,
\ '\\\@<!'.neosnippet#get_placeholder_marker_substitute_pattern(),
\ neosnippet#get_placeholder_marker_substitute_pattern(),
\ '<`\1`>', 'g')
let snip_word = substitute(snip_word,
\ '\\\@<!'.neosnippet#get_mirror_placeholder_marker_substitute_pattern(),
\ neosnippet#get_mirror_placeholder_marker_substitute_pattern(),
\ '<|\1|>', 'g')
let snip_word = substitute(snip_word,
\ '\\'.neosnippet#get_mirror_placeholder_marker_substitute_pattern().'\|'.
\ '\\'.neosnippet#get_placeholder_marker_substitute_pattern(),
\ '\=submatch(0)[1:]', 'g')

" Substitute escaped characters.
let snip_word = substitute(snip_word, '\\\\', '\\', 'g')

" Insert snippets.
let next_line = getline('.')[a:col-1 :]


+ 1
- 1
syntax/neosnippet.vim View File

@@ -42,7 +42,7 @@ syntax match neosnippetWord
\ '^\s\+.*$' contains=
\neosnippetEval,neosnippetPlaceHolder,neosnippetEscape,neosnippetVariable
syntax match neosnippetPlaceHolder
\ '\\\@<!\${\d\+\%(:.\{-}\)\?\\\@<!}'
\ '\%(\\\@<!\|\\\\\zs\)\${\d\+\%(:.\{-}\)\?\\\@<!}'
\ contained contains=neosnippetPlaceHolderComment
syntax match neosnippetVariable
\ '\\\@<!\$\d\+' contained


Loading…
Cancel
Save