You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

58 lines
1.5 KiB

  1. "=============================================================================
  2. " FILE: handlers.vim
  3. " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
  4. " License: MIT license
  5. "=============================================================================
  6. let s:save_cpo = &cpo
  7. set cpo&vim
  8. function! neosnippet#handlers#_cursor_moved() abort "{{{
  9. let expand_stack = neosnippet#variables#expand_stack()
  10. " Get patterns and count.
  11. if !&l:modifiable || !&l:modified
  12. \ || empty(expand_stack)
  13. return
  14. endif
  15. let expand_info = expand_stack[-1]
  16. if expand_info.begin_line == expand_info.end_line
  17. \ && line('.') != expand_info.begin_line
  18. call neosnippet#view#_clear_markers(expand_info)
  19. endif
  20. endfunction"}}}
  21. function! neosnippet#handlers#_all_clear_markers() abort "{{{
  22. if !&l:modifiable
  23. return
  24. endif
  25. let pos = getpos('.')
  26. try
  27. while !empty(neosnippet#variables#expand_stack())
  28. call neosnippet#view#_clear_markers(
  29. \ neosnippet#variables#expand_stack()[-1])
  30. stopinsert
  31. endwhile
  32. finally
  33. call setpos('.', pos)
  34. endtry
  35. endfunction"}}}
  36. function! neosnippet#handlers#_restore_unnamed_register() abort "{{{
  37. let neosnippet = neosnippet#variables#current_neosnippet()
  38. if neosnippet.unnamed_register != ''
  39. \ && @" !=# neosnippet.unnamed_register
  40. let @" = neosnippet.unnamed_register
  41. let neosnippet.unnamed_register = ''
  42. endif
  43. endfunction"}}}
  44. let &cpo = s:save_cpo
  45. unlet s:save_cpo
  46. " vim: foldmethod=marker