neosnippet.vim/autoload/neosnippet/handlers.vim

58 lines
1.5 KiB
VimL
Raw Normal View History

2015-08-21 21:36:11 +00:00
"=============================================================================
" FILE: handlers.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
2017-06-15 00:04:27 +00:00
" License: MIT license
2015-08-21 21:36:11 +00:00
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
2016-02-08 12:48:14 +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
endfunction"}}}
2016-02-08 12:48:14 +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
endfunction"}}}
2016-02-08 12:48:14 +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
endfunction"}}}
2015-08-21 21:36:11 +00:00
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker