Fix #291 expand completed_snippet when expand key mapping
This commit is contained in:
parent
a1508f8872
commit
9132237f3c
@ -26,23 +26,6 @@
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! neosnippet#handlers#_complete_done() abort "{{{
|
||||
if empty(v:completed_item)
|
||||
\ || !g:neosnippet#enable_completed_snippet
|
||||
\ || s:is_auto_pairs()
|
||||
return
|
||||
endif
|
||||
|
||||
let snippet = neosnippet#parser#_get_completed_snippet(
|
||||
\ v:completed_item, neosnippet#util#get_next_text())
|
||||
if snippet == ''
|
||||
return
|
||||
endif
|
||||
|
||||
let [cur_text, col, _] = neosnippet#mappings#_pre_trigger()
|
||||
call neosnippet#view#_insert(snippet, {}, cur_text, col)
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#handlers#_cursor_moved() abort "{{{
|
||||
let expand_stack = neosnippet#variables#expand_stack()
|
||||
|
||||
@ -87,10 +70,6 @@ function! neosnippet#handlers#_restore_unnamed_register() abort "{{{
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
function! s:is_auto_pairs() abort "{{{
|
||||
return get(g:, 'neopairs#enable', 0)
|
||||
endfunction"}}}
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
|
@ -66,11 +66,6 @@ function! s:initialize_others() abort "{{{
|
||||
\ call neosnippet#handlers#_all_clear_markers()
|
||||
endif
|
||||
|
||||
if exists('v:completed_item')
|
||||
autocmd neosnippet CompleteDone *
|
||||
\ call neosnippet#handlers#_complete_done()
|
||||
endif
|
||||
|
||||
if exists('##TextChanged') && exists('##TextChangedI')
|
||||
autocmd neosnippet TextChanged,TextChangedI *
|
||||
\ call neosnippet#handlers#_restore_unnamed_register()
|
||||
|
@ -31,7 +31,8 @@ function! neosnippet#mappings#expandable_or_jumpable() abort "{{{
|
||||
endfunction"}}}
|
||||
function! neosnippet#mappings#expandable() abort "{{{
|
||||
" Check snippet trigger.
|
||||
return neosnippet#helpers#get_cursor_snippet(
|
||||
return neosnippet#mappings#completed_expandable()
|
||||
\ || neosnippet#helpers#get_cursor_snippet(
|
||||
\ neosnippet#helpers#get_snippets('i'),
|
||||
\ neosnippet#util#get_cur_text()) != ''
|
||||
endfunction"}}}
|
||||
@ -40,6 +41,20 @@ function! neosnippet#mappings#jumpable() abort "{{{
|
||||
return search(neosnippet#get_placeholder_marker_pattern(). '\|'
|
||||
\ .neosnippet#get_sync_placeholder_marker_pattern(), 'nw') > 0
|
||||
endfunction"}}}
|
||||
function! neosnippet#mappings#completed_expandable() abort "{{{
|
||||
if !s:enabled_completed_snippet()
|
||||
return 0
|
||||
endif
|
||||
|
||||
let snippet = neosnippet#parser#_get_completed_snippet(
|
||||
\ v:completed_item, neosnippet#util#get_next_text())
|
||||
return snippet != ''
|
||||
endfunction"}}}
|
||||
function! s:enabled_completed_snippet() abort "{{{
|
||||
return exists('v:completed_item')
|
||||
\ && !empty(v:completed_item)
|
||||
\ && g:neosnippet#enable_completed_snippet
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#mappings#_clear_select_mode_mappings() abort "{{{
|
||||
if !g:neosnippet#disable_select_mode_mappings
|
||||
@ -153,37 +168,41 @@ function! neosnippet#mappings#_expand(trigger) abort "{{{
|
||||
endfunction"}}}
|
||||
|
||||
function! s:snippets_expand(cur_text, col) abort "{{{
|
||||
if s:enabled_completed_snippet()
|
||||
let snippet = neosnippet#parser#_get_completed_snippet(
|
||||
\ v:completed_item, neosnippet#util#get_next_text())
|
||||
if snippet != ''
|
||||
call neosnippet#view#_insert(snippet, {}, a:cur_text, a:col)
|
||||
return 0
|
||||
endif
|
||||
endif
|
||||
|
||||
let cur_word = neosnippet#helpers#get_cursor_snippet(
|
||||
\ neosnippet#helpers#get_snippets('i'),
|
||||
\ a:cur_text)
|
||||
|
||||
call neosnippet#view#_expand(
|
||||
\ neosnippet#util#get_cur_text(), a:col, cur_word)
|
||||
endfunction"}}}
|
||||
|
||||
function! s:snippets_expand_or_jump(cur_text, col) abort "{{{
|
||||
let cur_word = neosnippet#helpers#get_cursor_snippet(
|
||||
\ neosnippet#helpers#get_snippets('i'), a:cur_text)
|
||||
|
||||
if cur_word != ''
|
||||
" Found snippet trigger.
|
||||
call neosnippet#view#_expand(
|
||||
\ neosnippet#util#get_cur_text(), a:col, cur_word)
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
|
||||
return 1
|
||||
endfunction"}}}
|
||||
|
||||
function! s:snippets_expand_or_jump(cur_text, col) abort "{{{
|
||||
if s:snippets_expand(a:cur_text, a:col)
|
||||
call neosnippet#view#_jump('', a:col)
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
function! s:snippets_jump_or_expand(cur_text, col) abort "{{{
|
||||
let cur_word = neosnippet#helpers#get_cursor_snippet(
|
||||
\ neosnippet#helpers#get_snippets('i'), a:cur_text)
|
||||
if search(neosnippet#get_placeholder_marker_pattern(). '\|'
|
||||
\ .neosnippet#get_sync_placeholder_marker_pattern(), 'nw') > 0
|
||||
" Found snippet placeholder.
|
||||
call neosnippet#view#_jump('', a:col)
|
||||
else
|
||||
call neosnippet#view#_expand(
|
||||
\ neosnippet#util#get_cur_text(), a:col, cur_word)
|
||||
return s:snippets_expand(a:cur_text, a:col)
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
|
@ -230,10 +230,8 @@ g:neosnippet#enable_conceal_markers
|
||||
|
||||
*g:neosnippet#enable_completed_snippet*
|
||||
g:neosnippet#enable_completed_snippet
|
||||
If this variable is not 0, neosnippet will expand the function
|
||||
prototype when |CompleteDone| autocmd.
|
||||
Note: It is disabled if you have installed
|
||||
|neopairs.vim| plugin.
|
||||
If this variable is not 0, neosnippet can expand the function
|
||||
prototype.
|
||||
|
||||
The default value is 0.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user