From 2fde49493be871e7c5eb84877f320a214f33aec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ho=CC=88ltje?= Date: Sun, 28 Oct 2012 00:43:55 -0400 Subject: [PATCH] Add compatability for SnipMate-style `abbr` SnipMate-style snippets set the `abbr` (they call it `name`) via the snippet line. Note: If both styles are used, then neosnippet style wins. Example of SnipMate-style: snippet if if ... end if ${1:condition} ${2} end Example of neosnippet-style: snippet if abbr if ... end if ${1:condition} ${2} end --- autoload/neosnippet.vim | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/autoload/neosnippet.vim b/autoload/neosnippet.vim index fcbf9bd..0c4834e 100644 --- a/autoload/neosnippet.vim +++ b/autoload/neosnippet.vim @@ -344,9 +344,11 @@ function! s:load_snippets(snippet, snippets_file)"{{{ \ 'options' : { 'head' : 0, 'word' : 0 } } endif - let snippet_pattern.name = - \ substitute(matchstr(line, '^snippet\s\+\zs.*$'), - \ '\s', '_', 'g') + let snippet_pattern.name = matchstr(line, '^snippet\s\+\zs\S\+') + + " Collect the description (abbr) of the snippet, if set on snippet line. + " This is for compatibility with SnipMate-style snippets. + let snippet_pattern.abbr = matchstr(line, '^snippet\s\+\S\+\s\+\zs.*$') " Check for duplicated names. if has_key(dup_check, snippet_pattern.name) @@ -358,7 +360,8 @@ function! s:load_snippets(snippet, snippets_file)"{{{ \ 'Please delete this snippet name before.') endif elseif has_key(snippet_pattern, 'name') - " Only in snippets. + " Allow overriding/setting of the description (abbr) of the snippet. + " This will override what was set via the snippet line. if line =~ '^abbr\s' let snippet_pattern.abbr = matchstr(line, '^abbr\s\+\zs.*$') elseif line =~ '^alias\s'