Cleanup.
Makes cursor a standard notifier. Adds a method enabled() to the notifiers. Adds an optional method reset() to the notifiers.
This commit is contained in:
parent
9a7db4a50b
commit
90dce6d3e7
@ -47,7 +47,6 @@ endif
|
||||
|
||||
let s:registry = g:SyntasticRegistry.Instance()
|
||||
let s:notifiers = g:SyntasticNotifiers.New()
|
||||
let s:cursor_notifier = g:SyntasticNotifierCursor.New()
|
||||
let s:modemap = g:SyntasticModeMap.Instance()
|
||||
|
||||
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos)
|
||||
@ -68,10 +67,6 @@ highlight link SyntasticError SpellBad
|
||||
highlight link SyntasticWarning SpellCap
|
||||
|
||||
augroup syntastic
|
||||
if g:syntastic_echo_current_error
|
||||
autocmd CursorMoved * call s:cursor_notifier.refresh(s:LocList())
|
||||
endif
|
||||
|
||||
autocmd BufReadPost * if g:syntastic_check_on_open | call s:UpdateErrors(1) | endif
|
||||
autocmd BufWritePost * call s:UpdateErrors(1)
|
||||
|
||||
@ -117,8 +112,8 @@ endfunction
|
||||
|
||||
"clear the loc list for the buffer
|
||||
function! s:ClearCache()
|
||||
call s:notifiers.reset(s:LocList())
|
||||
unlet! b:syntastic_loclist
|
||||
call s:cursor_notifier.resetOldLine()
|
||||
endfunction
|
||||
|
||||
function! s:CurrentFiletypes()
|
||||
|
@ -3,14 +3,6 @@ if exists("g:loaded_syntastic_notifier_autoloclist")
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_autoloclist=1
|
||||
|
||||
"TODO: this var is a hack required for the Notifiers class. This is complicated
|
||||
"because this notification type doesnt use the same option naming convention
|
||||
"that Notifiers assumes
|
||||
"
|
||||
"i.e. it uses g:syntastic_auto_loc_list which has 3 possible values rather
|
||||
"than just on or off
|
||||
let g:syntastic_enable_autoloclist=1
|
||||
|
||||
if !exists("g:syntastic_auto_loc_list")
|
||||
let g:syntastic_auto_loc_list = 2
|
||||
endif
|
||||
@ -24,6 +16,10 @@ function! g:SyntasticNotifierAutoloclist.New()
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifierAutoloclist.enabled()
|
||||
return 1 " always enabled
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifierAutoloclist.refresh(loclist)
|
||||
call g:SyntasticNotifierAutoloclist.AutoToggle(a:loclist)
|
||||
endfunction
|
||||
@ -42,3 +38,5 @@ function! g:SyntasticNotifierAutoloclist.AutoToggle(loclist)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
@ -20,6 +20,10 @@ function! g:SyntasticNotifierBalloons.New()
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifierBalloons.enabled()
|
||||
return exists('b:syntastic_enable_balloons') ? b:syntastic_enable_balloons : g:syntastic_enable_balloons
|
||||
endfunction
|
||||
|
||||
" Update the error balloons
|
||||
function! g:SyntasticNotifierBalloons.refresh(loclist)
|
||||
let b:syntastic_balloons = {}
|
||||
|
@ -3,7 +3,7 @@ if exists("g:loaded_syntastic_notifier_cursor")
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_cursor=1
|
||||
|
||||
if !exists("g:syntastic_echo_current_error")
|
||||
if !exists('g:syntastic_echo_current_error')
|
||||
let g:syntastic_echo_current_error = 1
|
||||
endif
|
||||
|
||||
@ -13,25 +13,50 @@ let g:SyntasticNotifierCursor = {}
|
||||
|
||||
function! g:SyntasticNotifierCursor.New()
|
||||
let newObj = copy(self)
|
||||
let newObj.oldLine = -1
|
||||
let b:oldLine = -1
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifierCursor.enabled()
|
||||
return exists('b:syntastic_echo_current_error') ? b:syntastic_echo_current_error : g:syntastic_echo_current_error
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifierCursor.refresh(loclist)
|
||||
let l = line('.')
|
||||
if l == self.oldLine
|
||||
if g:syntastic_echo_current_error
|
||||
let b:syntastic_messages = copy(a:loclist.messages())
|
||||
autocmd syntastic CursorMoved * call g:SyntasticRefreshCursor()
|
||||
else
|
||||
autocmd! syntastic CursorMoved
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifierCursor.reset(loclist)
|
||||
let b:oldLine = -1
|
||||
endfunction
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
" The following defensive nonsense is needed because of the nature of autocmd
|
||||
function! g:SyntasticRefreshCursor()
|
||||
if exists('b:syntastic_messages')
|
||||
" file not checked
|
||||
return
|
||||
endif
|
||||
let self.oldLine = l
|
||||
|
||||
let messages = a:loclist.messages()
|
||||
if has_key(messages, l)
|
||||
return syntastic#util#wideMsg(messages[l])
|
||||
if !exists('b:oldLine')
|
||||
let b:oldLine = -1
|
||||
endif
|
||||
let l = line('.')
|
||||
if l == b:oldLine
|
||||
return
|
||||
endif
|
||||
let b:oldLine = l
|
||||
|
||||
if has_key(b:syntastic_messages, l)
|
||||
return syntastic#util#wideMsg(b:syntastic_messages[l])
|
||||
else
|
||||
echo
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifierCursor.resetOldLine()
|
||||
let self.oldLine = -1
|
||||
endfunction
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
@ -1,7 +1,7 @@
|
||||
if exists("g:loaded_syntastic_notifier_highlighting")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_highlighting=1
|
||||
let g:loaded_syntastic_notifier_highlighting = 1
|
||||
|
||||
if !exists("g:syntastic_enable_highlighting")
|
||||
let g:syntastic_enable_highlighting = 1
|
||||
@ -21,12 +21,14 @@ function! g:SyntasticNotifierHighlighting.New()
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifierHighlighting.enabled()
|
||||
return exists('b:syntastic_enable_highlighting') ? b:syntastic_enable_highlighting : g:syntastic_enable_highlighting
|
||||
endfunction
|
||||
|
||||
" The function `Syntastic_{filetype}_{checker}_GetHighlightRegex` is used
|
||||
" to override default highlighting. This function must take one arg (an
|
||||
" error item) and return a regex to match that item in the buffer.
|
||||
function! g:SyntasticNotifierHighlighting.refresh(loclist)
|
||||
call self._reset()
|
||||
|
||||
let fts = substitute(&ft, '-', '_', 'g')
|
||||
for ft in split(fts, '\.')
|
||||
|
||||
@ -49,10 +51,8 @@ function! g:SyntasticNotifierHighlighting.refresh(loclist)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" Private functions {{{1
|
||||
|
||||
" Remove all error highlights from the window
|
||||
function! g:SyntasticNotifierHighlighting._reset()
|
||||
function! g:SyntasticNotifierHighlighting.reset(loclist)
|
||||
for match in getmatches()
|
||||
if stridx(match['group'], 'Syntastic') == 0
|
||||
call matchdelete(match['id'])
|
||||
|
@ -5,7 +5,7 @@ let g:loaded_syntastic_notifiers=1
|
||||
|
||||
let g:SyntasticNotifiers = {}
|
||||
|
||||
let s:notifier_types = ['signs', 'balloons', 'highlighting', 'autoloclist']
|
||||
let s:notifier_types = ['signs', 'balloons', 'highlighting', 'cursor', 'autoloclist']
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
@ -25,10 +25,19 @@ endfunction
|
||||
|
||||
function! g:SyntasticNotifiers.refresh(loclist)
|
||||
for type in self._enabled_types
|
||||
if ( exists('b:syntastic_enable_'.type) ? b:syntastic_enable_{type} : g:syntastic_enable_{type} )
|
||||
if self._notifier[type].enabled()
|
||||
call self._notifier[type].refresh(a:loclist)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifiers.reset(loclist)
|
||||
for type in self._enabled_types
|
||||
let class = substitute(type, '.*', 'SyntasticNotifier\u&', '')
|
||||
if has_key(g:{class}, 'reset')
|
||||
call self._notifier[type].reset(a:loclist)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
@ -51,6 +51,10 @@ function! g:SyntasticNotifierSigns.New()
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifierSigns.enabled()
|
||||
return exists('b:syntastic_enable_signs') ? b:syntastic_enable_signs : g:syntastic_enable_signs
|
||||
endfunction
|
||||
|
||||
" Update the error signs
|
||||
function! g:SyntasticNotifierSigns.refresh(loclist)
|
||||
let old_signs = copy(self._bufSignIds())
|
||||
|
Loading…
x
Reference in New Issue
Block a user