Add g:neosnippet#enable_complete_done

This commit is contained in:
Shougo Matsushita 2015-12-12 03:07:13 +09:00
parent 7dc7ce803e
commit 5246b1f924
6 changed files with 23 additions and 10 deletions

View File

@ -41,6 +41,8 @@ call neosnippet#util#set_default(
\ 'g:neosnippet#expand_word_boundary', 0)
call neosnippet#util#set_default(
\ 'g:neosnippet#enable_conceal_markers', 1)
call neosnippet#util#set_default(
\ 'g:neosnippet#enable_complete_done', 0)
"}}}
function! neosnippet#expandable_or_jumpable() "{{{

View File

@ -27,7 +27,7 @@ let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#handlers#_complete_done() "{{{
if empty(v:completed_item)
if empty(v:completed_item) || !g:neosnippet#enable_complete_done
return
endif
@ -74,9 +74,12 @@ function! neosnippet#handlers#_complete_done() "{{{
" Remove auto pair from the snippet
let snippet = substitute(snippet, ')$', '', '')
else
if snippet !~ ')$'
if snippet =~ '($'
let snippet .= '${'. cnt .'})'
elseif snippet !~ ')$'
let snippet .= ')'
endif
let snippet .= '${0}'
endif
@ -90,6 +93,9 @@ function! neosnippet#handlers#_complete_done() "{{{
\ neosnippet#parser#_initialize_snippet(
\ { 'name' : trigger, 'word' : snippet, 'options' : options },
\ '', 0, '', trigger)
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
call neosnippet#view#_expand(cur_text, col, trigger)
endfunction"}}}
function! neosnippet#handlers#_cursor_moved() "{{{

View File

@ -137,14 +137,14 @@ function! neosnippet#mappings#_expand_target_trigger(trigger) "{{{
endfunction"}}}
function! neosnippet#mappings#_anonymous(snippet) "{{{
let [cur_text, col, expr] = s:pre_trigger()
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
let expr .= printf("\<ESC>:call neosnippet#view#_insert(%s, {}, %s, %d)\<CR>",
\ string(a:snippet), string(cur_text), col)
return expr
endfunction"}}}
function! neosnippet#mappings#_expand(trigger) "{{{
let [cur_text, col, expr] = s:pre_trigger()
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
let expr .= printf("\<ESC>:call neosnippet#view#_expand(%s, %d, %s)\<CR>",
\ string(cur_text), col, string(a:trigger))
@ -191,7 +191,7 @@ function! s:SID_PREFIX() "{{{
endfunction"}}}
function! neosnippet#mappings#_trigger(function) "{{{
let [cur_text, col, expr] = s:pre_trigger()
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
let expr .= printf("\<ESC>:call %s(%s,%d)\<CR>",
\ a:function, string(cur_text), col)
@ -199,7 +199,7 @@ function! neosnippet#mappings#_trigger(function) "{{{
return expr
endfunction"}}}
function! s:pre_trigger() "{{{
function! neosnippet#mappings#_pre_trigger() "{{{
call neosnippet#init#check()
let cur_text = neosnippet#util#get_cur_text()

View File

@ -368,7 +368,8 @@ function! s:expand_placeholder(start, end, holder_cnt, line, ...) "{{{
endif
stopinsert
execute 'normal! v'. repeat('l', len) . "\<C-g>"
execute 'normal! v'.
\ repeat('l', (mode() == 'i' ? len+1 : len)) . "\<C-g>"
elseif pos[2] < col('$')
startinsert
else

View File

@ -225,6 +225,13 @@ g:neosnippet#enable_conceal_markers
The default value is 1.
*g:neosnippet#enable_complete_done*
g:neosnippet#enable_complete_done
If this variable is not 0, neosnippet will expand the function
prototype when |CompleteDone| autocmd.
The default value is 0.
*g:neosnippet#scope_aliases*
g:neosnippet#scope_aliases
It is a dictionary that associating certain filetypes with

View File

@ -33,9 +33,6 @@ endif
let s:save_cpo = &cpo
set cpo&vim
" Obsolute options check. "{{{
"}}}
" Plugin key-mappings. "{{{
inoremap <silent><expr> <Plug>(neosnippet_expand_or_jump)
\ neosnippet#mappings#expand_or_jump_impl()