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
This commit is contained in:
parent
0a3edfa3a0
commit
2fde49493b
@ -344,9 +344,11 @@ function! s:load_snippets(snippet, snippets_file)"{{{
|
|||||||
\ 'options' : { 'head' : 0, 'word' : 0 } }
|
\ 'options' : { 'head' : 0, 'word' : 0 } }
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let snippet_pattern.name =
|
let snippet_pattern.name = matchstr(line, '^snippet\s\+\zs\S\+')
|
||||||
\ substitute(matchstr(line, '^snippet\s\+\zs.*$'),
|
|
||||||
\ '\s', '_', 'g')
|
" 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.
|
" Check for duplicated names.
|
||||||
if has_key(dup_check, snippet_pattern.name)
|
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.')
|
\ 'Please delete this snippet name before.')
|
||||||
endif
|
endif
|
||||||
elseif has_key(snippet_pattern, 'name')
|
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'
|
if line =~ '^abbr\s'
|
||||||
let snippet_pattern.abbr = matchstr(line, '^abbr\s\+\zs.*$')
|
let snippet_pattern.abbr = matchstr(line, '^abbr\s\+\zs.*$')
|
||||||
elseif line =~ '^alias\s'
|
elseif line =~ '^alias\s'
|
||||||
|
Loading…
Reference in New Issue
Block a user