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