Fix for ${0} problems

This commit is contained in:
Shougo Matsushita 2015-12-19 11:44:33 +09:00
parent 248ee0651f
commit 1d5b8589b6
3 changed files with 6 additions and 8 deletions

View File

@ -74,11 +74,12 @@ function! neosnippet#handlers#_complete_done() "{{{
if !s:is_auto_pairs() if !s:is_auto_pairs()
if key != '(' && snippet =~ key.'$' if key != '(' && snippet =~ key.'$'
let snippet .= '${'. cnt .'}'.pair let snippet .= '${'. cnt .'}'.pair
let cnt += 1
elseif snippet !~ pair.'$' elseif snippet !~ pair.'$'
let snippet .= pair let snippet .= pair
endif endif
let snippet .= '${0}' let snippet .= '${' . cnt . '}'
endif endif
let [cur_text, col, _] = neosnippet#mappings#_pre_trigger() let [cur_text, col, _] = neosnippet#mappings#_pre_trigger()

View File

@ -238,11 +238,6 @@ endfunction"}}}
function! neosnippet#parser#_initialize_snippet(dict, path, line, pattern, name) "{{{ function! neosnippet#parser#_initialize_snippet(dict, path, line, pattern, name) "{{{
let a:dict.word = substitute(a:dict.word, '\n\+$', '', '') let a:dict.word = substitute(a:dict.word, '\n\+$', '', '')
if a:dict.word !~
\ neosnippet#get_placeholder_marker_substitute_pattern()
" Add placeholder.
let a:dict.word .= '${0}'
endif
if !has_key(a:dict, 'abbr') || a:dict.abbr == '' if !has_key(a:dict, 'abbr') || a:dict.abbr == ''
" Set default abbr. " Set default abbr.

View File

@ -347,10 +347,10 @@ neosnippet#anonymous({snippet})
Note: You can use this function with |map-<expr>|. Note: You can use this function with |map-<expr>|.
> >
inoremap <silent> (( inoremap <silent> ((
\ <C-r>=neosnippet#anonymous('\left(${1}\right)${0}')<CR> \ <C-r>=neosnippet#anonymous('\left(${1}\right)${2}')<CR>
" OR " OR
inoremap <expr><silent> (( inoremap <expr><silent> ((
\ neosnippet#anonymous('\left(${1}\right)${0}') \ neosnippet#anonymous('\left(${1}\right)${2}')
< <
*neosnippet#expand()* *neosnippet#expand()*
neosnippet#expand({trigger}) neosnippet#expand({trigger})
@ -580,6 +580,8 @@ The structure of a placeholder can be:
placeholders in the snippet, it will repeat its content. $1 is placeholders in the snippet, it will repeat its content. $1 is
synchronized to ${1} and so on. ${0} will be the final jump synchronized to ${1} and so on. ${0} will be the final jump
placeholder. placeholder.
Note: You should not use ${0} for one line snippet.
It conflicts with nested snippet feature.
Example Example