- Added regexp syntax.
This commit is contained in:
parent
ff8b6f19c3
commit
45c3baaf23
@ -222,8 +222,8 @@ function! s:initialize_snippet(dict, path, line, pattern, name)"{{{
|
|||||||
\ 'action__pattern' : a:pattern, 'real_name' : a:name,
|
\ 'action__pattern' : a:pattern, 'real_name' : a:name,
|
||||||
\}
|
\}
|
||||||
|
|
||||||
if has_key(a:dict, 'regex')
|
if has_key(a:dict, 'regexp')
|
||||||
let snippet.regex = a:dict.regex
|
let snippet.regexp = a:dict.regexp
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return snippet
|
return snippet
|
||||||
@ -453,9 +453,9 @@ function! s:add_snippet_attribute(line, linenr, snippet_dict)"{{{
|
|||||||
call neosnippet#util#print_error(
|
call neosnippet#util#print_error(
|
||||||
\ 'prev_word must be "^" character.')
|
\ 'prev_word must be "^" character.')
|
||||||
endif
|
endif
|
||||||
elseif a:line =~ '^regex\s'
|
elseif a:line =~ '^regexp\s'
|
||||||
let a:snippet_dict.regex = matchstr(a:line,
|
let a:snippet_dict.regexp = matchstr(a:line,
|
||||||
\ '^regex\s\+[''"]\zs.*\ze[''"]$')
|
\ '^regexp\s\+[''"]\zs.*\ze[''"]$')
|
||||||
elseif a:line =~ '^options\s\+'
|
elseif a:line =~ '^options\s\+'
|
||||||
for option in split(matchstr(a:line,
|
for option in split(matchstr(a:line,
|
||||||
\ '^options\s\+\zs.*$'), '[,[:space:]]\+')
|
\ '^options\s\+\zs.*$'), '[,[:space:]]\+')
|
||||||
@ -1043,11 +1043,16 @@ function! neosnippet#get_snippets()"{{{
|
|||||||
call extend(snippets, s:snippets[filetype], 'keep')
|
call extend(snippets, s:snippets[filetype], 'keep')
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
if mode() ==# 'i' &&
|
if mode() ==# 'i'
|
||||||
\ !s:is_beginning_of_line(neosnippet#util#get_cur_text())
|
" Special filters.
|
||||||
|
let cur_text = neosnippet#util#get_cur_text()
|
||||||
|
if !s:is_beginning_of_line(cur_text)
|
||||||
call filter(snippets, '!v:val.options.head')
|
call filter(snippets, '!v:val.options.head')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
call filter(snippets, "cur_text =~ get(v:val, 'regexp', '')")
|
||||||
|
endif
|
||||||
|
|
||||||
return snippets
|
return snippets
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_snippets_directory()"{{{
|
function! neosnippet#get_snippets_directory()"{{{
|
||||||
|
@ -395,6 +395,16 @@ Snippet Keywords:
|
|||||||
alias hoge hogera hogehoge
|
alias hoge hogera hogehoge
|
||||||
<
|
<
|
||||||
|
|
||||||
|
- regexp [pattern] (optional)
|
||||||
|
|
||||||
|
This snippet expands when it matched by the regexp pattern only.
|
||||||
|
|
||||||
|
Example
|
||||||
|
|
||||||
|
>
|
||||||
|
regexp '^% '
|
||||||
|
<
|
||||||
|
|
||||||
- options [options] (optional)
|
- options [options] (optional)
|
||||||
|
|
||||||
Options influece the snippet behavior. The possible options are:
|
Options influece the snippet behavior. The possible options are:
|
||||||
@ -677,6 +687,7 @@ CHANGELOG *neosnippet-changelog*
|
|||||||
- Refactored documentation.
|
- Refactored documentation.
|
||||||
- Added :NeoSnippetSource.
|
- Added :NeoSnippetSource.
|
||||||
- Refactored parse routine.
|
- Refactored parse routine.
|
||||||
|
- Added regexp syntax.
|
||||||
|
|
||||||
2012-11-02
|
2012-11-02
|
||||||
- Added g:neosnippet#enable_snipmate_compatibility option.
|
- Added g:neosnippet#enable_snipmate_compatibility option.
|
||||||
|
Loading…
Reference in New Issue
Block a user