Improve complete done behavior

This commit is contained in:
Shougo Matsushita 2015-12-12 16:37:15 +09:00
parent 5246b1f924
commit 12ad06d37d

View File

@ -31,13 +31,6 @@ function! neosnippet#handlers#_complete_done() "{{{
return
endif
let snippets = neosnippet#helpers#get_snippets()
if has_key(snippets, v:completed_item.word)
\ && !get(snippets[v:completed_item.word], 'oneshot', 0)
" Don't overwrite exists snippets
return
endif
let item = v:completed_item
let abbr = (item.abbr != '') ? item.abbr : item.word
@ -56,8 +49,8 @@ function! neosnippet#handlers#_complete_done() "{{{
" Make snippet arguments
let cnt = 1
let snippet = item.word
if snippet !~ '()\?$'
let snippet = ''
if item.word !~ '()\?$'
let snippet .= '('
endif
@ -83,19 +76,8 @@ function! neosnippet#handlers#_complete_done() "{{{
let snippet .= '${0}'
endif
let options = neosnippet#parser#_initialize_snippet_options()
let options.word = 1
let options.oneshot = 1
let neosnippet = neosnippet#variables#current_neosnippet()
let trigger = item.word
let neosnippet.snippets[trigger] =
\ 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)
call neosnippet#view#_insert(snippet, {}, cur_text, col)
endfunction"}}}
function! neosnippet#handlers#_cursor_moved() "{{{