Implement auto clear markers feature

This commit is contained in:
Shougo Matsushita 2015-08-29 09:33:43 +09:00
parent 58ed397963
commit 32e2cf9f70
3 changed files with 19 additions and 2 deletions

View File

@ -137,8 +137,7 @@ function! neosnippet#commands#_clear_markers() "{{{
let expand_stack = neosnippet#variables#expand_stack()
" Get patterns and count.
if !&l:modifiable
\ || !&l:modified
if !&l:modifiable || !&l:modified
\ || empty(expand_stack)
\ || neosnippet#variables#current_neosnippet().trigger
return

View File

@ -84,6 +84,22 @@ function! neosnippet#handlers#_complete_done() "{{{
\ '', 0, '', trigger)
endfunction"}}}
function! neosnippet#handlers#_cursor_moved() "{{{
let expand_stack = neosnippet#variables#expand_stack()
" Get patterns and count.
if !&l:modifiable || !&l:modified
\ || empty(expand_stack)
return
endif
let expand_info = expand_stack[-1]
if expand_info.begin_line == expand_info.end_line
\ && line('.') != expand_info.begin_line
call neosnippet#commands#_clear_markers()
endif
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -88,6 +88,8 @@ function! s:initialize_others() "{{{
\ call neosnippet#variables#set_snippets({})
autocmd BufEnter *
\ call neosnippet#mappings#_clear_select_mode_mappings()
autocmd CursorMoved,CursorMovedI *
\ call neosnippet#handlers#_cursor_moved()
autocmd BufWritePre * NeoSnippetClearMarkers
augroup END"}}}