neosnippet.vim/autoload/neosnippet/handlers.vim

50 lines
1.3 KiB
VimL
Raw Normal View History

2015-08-21 21:36:11 +00:00
"=============================================================================
" FILE: handlers.vim
2017-06-15 00:11:15 +00:00
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
2017-06-15 00:04:27 +00:00
" License: MIT license
2015-08-21 21:36:11 +00:00
"=============================================================================
2017-10-01 13:40:17 +00:00
function! neosnippet#handlers#_cursor_moved() abort
2015-08-29 00:33:43 +00:00
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#view#_clear_markers(expand_info)
2015-08-29 00:33:43 +00:00
endif
2017-10-01 13:40:17 +00:00
endfunction
2015-08-29 00:33:43 +00:00
2017-10-01 13:40:17 +00:00
function! neosnippet#handlers#_all_clear_markers() abort
2016-05-17 11:50:40 +00:00
if !&l:modifiable
return
endif
let pos = getpos('.')
try
while !empty(neosnippet#variables#expand_stack())
call neosnippet#view#_clear_markers(
\ neosnippet#variables#expand_stack()[-1])
2016-06-30 23:15:01 +00:00
stopinsert
endwhile
finally
call setpos('.', pos)
endtry
2017-10-01 13:40:17 +00:00
endfunction
2017-10-01 13:40:17 +00:00
function! neosnippet#handlers#_restore_unnamed_register() abort
let neosnippet = neosnippet#variables#current_neosnippet()
if neosnippet.unnamed_register != ''
\ && @" !=# neosnippet.unnamed_register
let @" = neosnippet.unnamed_register
let neosnippet.unnamed_register = ''
endif
2017-10-01 13:40:17 +00:00
endfunction