2015-07-13 06:22:46 -04:00
|
|
|
if exists('g:loaded_syntastic_notifiers') || !exists('g:loaded_syntastic_plugin')
|
2014-02-08 05:05:16 -05:00
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let g:loaded_syntastic_notifiers = 1
|
|
|
|
|
|
|
|
let g:SyntasticNotifiers = {}
|
|
|
|
|
2014-10-31 17:30:24 -04:00
|
|
|
let s:_NOTIFIER_TYPES = ['signs', 'balloons', 'highlighting', 'cursor', 'autoloclist']
|
|
|
|
lockvar! s:_NOTIFIER_TYPES
|
2014-02-08 05:05:16 -05:00
|
|
|
|
2014-10-31 17:30:24 -04:00
|
|
|
let s:_PERSISTENT_NOTIFIERS = ['signs', 'balloons']
|
|
|
|
lockvar! s:_PERSISTENT_NOTIFIERS
|
2014-08-03 18:02:51 -04:00
|
|
|
|
2014-02-08 05:05:16 -05:00
|
|
|
" Public methods {{{1
|
|
|
|
|
2015-02-24 05:45:22 -05:00
|
|
|
function! g:SyntasticNotifiers.Instance() abort " {{{2
|
2014-02-08 05:05:16 -05:00
|
|
|
if !exists('s:SyntasticNotifiersInstance')
|
|
|
|
let s:SyntasticNotifiersInstance = copy(self)
|
|
|
|
call s:SyntasticNotifiersInstance._initNotifiers()
|
|
|
|
endif
|
|
|
|
|
|
|
|
return s:SyntasticNotifiersInstance
|
2014-03-02 09:35:00 -05:00
|
|
|
endfunction " }}}2
|
2014-02-08 05:05:16 -05:00
|
|
|
|
2015-02-24 05:45:22 -05:00
|
|
|
function! g:SyntasticNotifiers.refresh(loclist) abort " {{{2
|
2014-08-03 18:02:51 -04:00
|
|
|
if !a:loclist.isEmpty() && !a:loclist.isNewerThan([])
|
|
|
|
" loclist not fully constructed yet
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
2014-10-31 17:30:24 -04:00
|
|
|
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'notifiers: refresh')
|
2014-02-08 05:05:16 -05:00
|
|
|
for type in self._enabled_types
|
|
|
|
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')
|
|
|
|
if !has_key(g:{class}, 'enabled') || self._notifier[type].enabled()
|
2014-10-31 17:30:24 -04:00
|
|
|
if index(s:_PERSISTENT_NOTIFIERS, type) > -1
|
2014-08-03 18:02:51 -04:00
|
|
|
" refresh only if loclist has changed since last call
|
2015-01-18 07:58:28 -05:00
|
|
|
if !exists('b:syntastic_private_' . type . '_stamp')
|
|
|
|
let b:syntastic_private_{type}_stamp = []
|
2014-08-03 18:02:51 -04:00
|
|
|
endif
|
2015-01-18 07:58:28 -05:00
|
|
|
if a:loclist.isNewerThan(b:syntastic_private_{type}_stamp) || a:loclist.isEmpty()
|
2014-08-03 18:02:51 -04:00
|
|
|
call self._notifier[type].refresh(a:loclist)
|
2015-01-18 07:58:28 -05:00
|
|
|
let b:syntastic_private_{type}_stamp = syntastic#util#stamp()
|
2014-08-03 18:02:51 -04:00
|
|
|
endif
|
|
|
|
else
|
|
|
|
call self._notifier[type].refresh(a:loclist)
|
|
|
|
endif
|
2014-02-08 05:05:16 -05:00
|
|
|
endif
|
|
|
|
endfor
|
2014-03-02 09:35:00 -05:00
|
|
|
endfunction " }}}2
|
2014-02-08 05:05:16 -05:00
|
|
|
|
2015-02-24 05:45:22 -05:00
|
|
|
function! g:SyntasticNotifiers.reset(loclist) abort " {{{2
|
2014-10-31 17:30:24 -04:00
|
|
|
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'notifiers: reset')
|
2014-02-08 05:05:16 -05:00
|
|
|
for type in self._enabled_types
|
|
|
|
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')
|
|
|
|
|
|
|
|
" reset notifiers regardless if they are enabled or not, since
|
|
|
|
" the user might have disabled them since the last refresh();
|
|
|
|
" notifiers MUST be prepared to deal with reset() when disabled
|
|
|
|
if has_key(g:{class}, 'reset')
|
|
|
|
call self._notifier[type].reset(a:loclist)
|
|
|
|
endif
|
2014-08-03 18:02:51 -04:00
|
|
|
|
|
|
|
" also reset stamps
|
2014-10-31 17:30:24 -04:00
|
|
|
if index(s:_PERSISTENT_NOTIFIERS, type) > -1
|
2015-01-18 07:58:28 -05:00
|
|
|
let b:syntastic_private_{type}_stamp = []
|
2014-08-03 18:02:51 -04:00
|
|
|
endif
|
2014-02-08 05:05:16 -05:00
|
|
|
endfor
|
2014-03-02 09:35:00 -05:00
|
|
|
endfunction " }}}2
|
|
|
|
|
|
|
|
" }}}1
|
2014-02-08 05:05:16 -05:00
|
|
|
|
|
|
|
" Private methods {{{1
|
|
|
|
|
2015-02-24 05:45:22 -05:00
|
|
|
function! g:SyntasticNotifiers._initNotifiers() abort " {{{2
|
2014-02-08 05:05:16 -05:00
|
|
|
let self._notifier = {}
|
2014-10-31 17:30:24 -04:00
|
|
|
for type in s:_NOTIFIER_TYPES
|
2014-02-08 05:05:16 -05:00
|
|
|
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')
|
|
|
|
let self._notifier[type] = g:{class}.New()
|
|
|
|
endfor
|
|
|
|
|
2014-10-31 17:30:24 -04:00
|
|
|
let self._enabled_types = copy(s:_NOTIFIER_TYPES)
|
2014-03-02 09:35:00 -05:00
|
|
|
endfunction " }}}2
|
|
|
|
|
|
|
|
" }}}1
|
2014-02-08 05:05:16 -05:00
|
|
|
|
|
|
|
" vim: set sw=4 sts=4 et fdm=marker:
|