diff --git a/autoload/neosnippet.vim b/autoload/neosnippet.vim index 0c4834e..e968c16 100644 --- a/autoload/neosnippet.vim +++ b/autoload/neosnippet.vim @@ -344,8 +344,18 @@ function! s:load_snippets(snippet, snippets_file)"{{{ \ 'options' : { 'head' : 0, 'word' : 0 } } endif + " Try using the name without the description (abbr). let snippet_pattern.name = matchstr(line, '^snippet\s\+\zs\S\+') + " Fall back to using the name and description (abbr) combined. + " SnipMate snippets may have duplicate names, but different + " descriptions (abbrs). + if has_key(dup_check, snippet_pattern.name) + let snippet_pattern.name = + \ substitute(matchstr(line, '^snippet\s\+\zs.*$'), + \ '\s\+', '_', 'g') + endif + " 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.*$') diff --git a/autoload/neosnippet/snippets/ruby.snip b/autoload/neosnippet/snippets/ruby.snip index b4fac89..6fca0f9 100644 --- a/autoload/neosnippet/snippets/ruby.snip +++ b/autoload/neosnippet/snippets/ruby.snip @@ -10,8 +10,17 @@ abbr def end ${2} end +snippet defrescue +alias defr +abbr def ... rescue ... end + def ${1:method_name} + ${2} + rescue ${3:StandardError} => ${4:error} + ${5} + end + snippet do -abbr do end +abbr do ... end do ${1} end