1
0
mirror of https://github.com/gryf/snipmate.vim.git synced 2025-12-19 20:38:05 +01:00

added support for escaping backticks (issue#74)

This commit is contained in:
msanders
2009-12-28 03:31:19 -05:00
parent 9fe9170564
commit 26e93e9195
2 changed files with 8 additions and 6 deletions

View File

@@ -75,15 +75,17 @@ endf
" Prepare snippet to be processed by s:BuildTabStops " Prepare snippet to be processed by s:BuildTabStops
fun s:ProcessSnippet(snip) fun s:ProcessSnippet(snip)
let snippet = a:snip let snippet = a:snip
" Evaluate eval (`...`) expressions. " Evaluate eval (`...`) expressions.
" Backquotes prefixed with a backslash are ignored.
" Using a loop here instead of a regex fixes a bug with nested "\=". " Using a loop here instead of a regex fixes a bug with nested "\=".
if stridx(snippet, '`') != -1 if stridx(snippet, '`') != -1
while match(snippet, '`.\{-}`') != -1 while match(snippet, '[^\\]`.\{-}[^\\]`') != -1
let snippet = substitute(snippet, '`.\{-}`', let snippet = substitute(snippet, '[^\\]\zs`.\{-}[^\\]`\ze',
\ substitute(eval(matchstr(snippet, '`\zs.\{-}\ze`')), \ substitute(eval(matchstr(snippet, '[^\\]`\zs.\{-}[^\\]\ze`')),
\ "\n\\%$", '', ''), '') \ "\n\\%$", '', ''), '')
endw endw
let snippet = substitute(snippet, "\r", "\n", 'g') let snippet = substitute(snippet, "\r", "\n", 'g')
let snippet = substitute(snippet, '\\`', '`', 'g')
endif endif
" Place all text after a colon in a tab stop after the tab stop " Place all text after a colon in a tab stop after the tab stop

View File

@@ -3,7 +3,7 @@
syn match snipComment '^#.*' syn match snipComment '^#.*'
syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand
syn match tabStop '\$\d\+' syn match tabStop '\$\d\+'
syn match snipCommand '`.\{-}`' syn match snipCommand '[^\\]`.\{-}`'
syn match snippet '^snippet.*' transparent contains=multiSnipText,snipKeyword syn match snippet '^snippet.*' transparent contains=multiSnipText,snipKeyword
syn match multiSnipText '\S\+ \zs.*' contained syn match multiSnipText '\S\+ \zs.*' contained
syn match snipKeyword '^snippet'me=s+8 contained syn match snipKeyword '^snippet'me=s+8 contained