diff --git a/autoload/neosnippet.vim b/autoload/neosnippet.vim index 8ea779d..f51208e 100644 --- a/autoload/neosnippet.vim +++ b/autoload/neosnippet.vim @@ -42,6 +42,10 @@ endfunction function! neosnippet#expand(trigger) abort return neosnippet#mappings#_expand(a:trigger) endfunction +function! neosnippet#complete_done() abort + return neosnippet#mappings#_complete_done( + \ neosnippet#util#get_cur_text(), col('.')) +endfunction function! neosnippet#get_snippets_directory() abort return neosnippet#helpers#get_snippets_directory() diff --git a/autoload/neosnippet/mappings.vim b/autoload/neosnippet/mappings.vim index 75ae0b2..8e022ff 100644 --- a/autoload/neosnippet/mappings.vim +++ b/autoload/neosnippet/mappings.vim @@ -140,7 +140,7 @@ function! neosnippet#mappings#_expand(trigger) abort endfunction function! s:snippets_expand(cur_text, col) abort - if s:expand_completed_snippets(a:cur_text, a:col) + if neosnippet#mappings#_complete_done(a:cur_text, a:col) return 0 endif @@ -184,8 +184,13 @@ function! s:get_completed_snippets(cur_text, col) abort return [] endfunction -function! s:expand_completed_snippets(cur_text, col) abort - let [cur_text, snippet] = s:get_completed_snippets(a:cur_text, a:col) +function! neosnippet#mappings#_complete_done(cur_text, col) abort + let ret = s:get_completed_snippets(a:cur_text, a:col) + if empty(ret) + return 0 + endif + + let [cur_text, snippet] = ret call neosnippet#view#_insert(snippet, {}, cur_text, a:col) return 1 endfunction diff --git a/doc/neosnippet.txt b/doc/neosnippet.txt index 736ca88..ef711f3 100755 --- a/doc/neosnippet.txt +++ b/doc/neosnippet.txt @@ -373,6 +373,11 @@ neosnippet#get_snippets_directory() snippets directories and |g:neosnippet#snippets_directory| directories. + *neosnippet#complete_done()* +neosnippet#complete_done() + It expands the snippet for |CompleteDone| event. +> + autocmd CompleteDone * call neosnippet#complete_done() ============================================================================== EXAMPLES *neosnippet-examples*