1
0

balloons.vim 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. if exists('g:loaded_syntastic_notifier_balloons') || !exists('g:loaded_syntastic_plugin')
  2. finish
  3. endif
  4. let g:loaded_syntastic_notifier_balloons = 1
  5. if !has('balloon_eval')
  6. let g:syntastic_enable_balloons = 0
  7. endif
  8. let g:SyntasticBalloonsNotifier = {}
  9. " Public methods {{{1
  10. function! g:SyntasticBalloonsNotifier.New() abort " {{{2
  11. let newObj = copy(self)
  12. return newObj
  13. endfunction " }}}2
  14. function! g:SyntasticBalloonsNotifier.enabled() abort " {{{2
  15. return has('balloon_eval') && syntastic#util#var('enable_balloons')
  16. endfunction " }}}2
  17. " Update the error balloons
  18. function! g:SyntasticBalloonsNotifier.refresh(loclist) abort " {{{2
  19. unlet! b:syntastic_private_balloons
  20. if self.enabled() && !a:loclist.isEmpty()
  21. let b:syntastic_private_balloons = a:loclist.balloons()
  22. if !empty(b:syntastic_private_balloons)
  23. set ballooneval balloonexpr=SyntasticBalloonsExprNotifier()
  24. endif
  25. endif
  26. endfunction " }}}2
  27. " Reset the error balloons
  28. " @vimlint(EVL103, 1, a:loclist)
  29. function! g:SyntasticBalloonsNotifier.reset(loclist) abort " {{{2
  30. let b:syntastic_private_balloons = {}
  31. if has('balloon_eval')
  32. call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'balloons: reset')
  33. unlet! b:syntastic_private_balloons
  34. set noballooneval
  35. endif
  36. endfunction " }}}2
  37. " @vimlint(EVL103, 0, a:loclist)
  38. " }}}1
  39. " Private functions {{{1
  40. function! SyntasticBalloonsExprNotifier() abort " {{{2
  41. if !exists('b:syntastic_private_balloons')
  42. return ''
  43. endif
  44. return get(b:syntastic_private_balloons, v:beval_lnum, '')
  45. endfunction " }}}2
  46. " }}}1
  47. " vim: set sw=4 sts=4 et fdm=marker: