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.
 
 

50 lines
1.3 KiB

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