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:registry = g:SyntasticRegistry.Instance()
|
||||||
let s:notifiers = g:SyntasticNotifiers.New()
|
let s:notifiers = g:SyntasticNotifiers.New()
|
||||||
let s:cursor_notifier = g:SyntasticNotifierCursor.New()
|
|
||||||
let s:modemap = g:SyntasticModeMap.Instance()
|
let s:modemap = g:SyntasticModeMap.Instance()
|
||||||
|
|
||||||
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos)
|
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos)
|
||||||
@ -68,10 +67,6 @@ highlight link SyntasticError SpellBad
|
|||||||
highlight link SyntasticWarning SpellCap
|
highlight link SyntasticWarning SpellCap
|
||||||
|
|
||||||
augroup syntastic
|
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 BufReadPost * if g:syntastic_check_on_open | call s:UpdateErrors(1) | endif
|
||||||
autocmd BufWritePost * call s:UpdateErrors(1)
|
autocmd BufWritePost * call s:UpdateErrors(1)
|
||||||
|
|
||||||
@ -117,8 +112,8 @@ endfunction
|
|||||||
|
|
||||||
"clear the loc list for the buffer
|
"clear the loc list for the buffer
|
||||||
function! s:ClearCache()
|
function! s:ClearCache()
|
||||||
|
call s:notifiers.reset(s:LocList())
|
||||||
unlet! b:syntastic_loclist
|
unlet! b:syntastic_loclist
|
||||||
call s:cursor_notifier.resetOldLine()
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CurrentFiletypes()
|
function! s:CurrentFiletypes()
|
||||||
|
@ -3,14 +3,6 @@ if exists("g:loaded_syntastic_notifier_autoloclist")
|
|||||||
endif
|
endif
|
||||||
let g:loaded_syntastic_notifier_autoloclist=1
|
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")
|
if !exists("g:syntastic_auto_loc_list")
|
||||||
let g:syntastic_auto_loc_list = 2
|
let g:syntastic_auto_loc_list = 2
|
||||||
endif
|
endif
|
||||||
@ -24,6 +16,10 @@ function! g:SyntasticNotifierAutoloclist.New()
|
|||||||
return newObj
|
return newObj
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! g:SyntasticNotifierAutoloclist.enabled()
|
||||||
|
return 1 " always enabled
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! g:SyntasticNotifierAutoloclist.refresh(loclist)
|
function! g:SyntasticNotifierAutoloclist.refresh(loclist)
|
||||||
call g:SyntasticNotifierAutoloclist.AutoToggle(a:loclist)
|
call g:SyntasticNotifierAutoloclist.AutoToggle(a:loclist)
|
||||||
endfunction
|
endfunction
|
||||||
@ -42,3 +38,5 @@ function! g:SyntasticNotifierAutoloclist.AutoToggle(loclist)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
@ -20,6 +20,10 @@ function! g:SyntasticNotifierBalloons.New()
|
|||||||
return newObj
|
return newObj
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! g:SyntasticNotifierBalloons.enabled()
|
||||||
|
return exists('b:syntastic_enable_balloons') ? b:syntastic_enable_balloons : g:syntastic_enable_balloons
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Update the error balloons
|
" Update the error balloons
|
||||||
function! g:SyntasticNotifierBalloons.refresh(loclist)
|
function! g:SyntasticNotifierBalloons.refresh(loclist)
|
||||||
let b:syntastic_balloons = {}
|
let b:syntastic_balloons = {}
|
||||||
|
@ -3,7 +3,7 @@ if exists("g:loaded_syntastic_notifier_cursor")
|
|||||||
endif
|
endif
|
||||||
let g:loaded_syntastic_notifier_cursor=1
|
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
|
let g:syntastic_echo_current_error = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -13,25 +13,50 @@ let g:SyntasticNotifierCursor = {}
|
|||||||
|
|
||||||
function! g:SyntasticNotifierCursor.New()
|
function! g:SyntasticNotifierCursor.New()
|
||||||
let newObj = copy(self)
|
let newObj = copy(self)
|
||||||
let newObj.oldLine = -1
|
let b:oldLine = -1
|
||||||
return newObj
|
return newObj
|
||||||
endfunction
|
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)
|
function! g:SyntasticNotifierCursor.refresh(loclist)
|
||||||
let l = line('.')
|
if g:syntastic_echo_current_error
|
||||||
if l == self.oldLine
|
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
|
return
|
||||||
endif
|
endif
|
||||||
let self.oldLine = l
|
|
||||||
|
|
||||||
let messages = a:loclist.messages()
|
if !exists('b:oldLine')
|
||||||
if has_key(messages, l)
|
let b:oldLine = -1
|
||||||
return syntastic#util#wideMsg(messages[l])
|
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
|
else
|
||||||
echo
|
echo
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! g:SyntasticNotifierCursor.resetOldLine()
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
let self.oldLine = -1
|
|
||||||
endfunction
|
|
||||||
|
@ -21,12 +21,14 @@ function! g:SyntasticNotifierHighlighting.New()
|
|||||||
return newObj
|
return newObj
|
||||||
endfunction
|
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
|
" The function `Syntastic_{filetype}_{checker}_GetHighlightRegex` is used
|
||||||
" to override default highlighting. This function must take one arg (an
|
" to override default highlighting. This function must take one arg (an
|
||||||
" error item) and return a regex to match that item in the buffer.
|
" error item) and return a regex to match that item in the buffer.
|
||||||
function! g:SyntasticNotifierHighlighting.refresh(loclist)
|
function! g:SyntasticNotifierHighlighting.refresh(loclist)
|
||||||
call self._reset()
|
|
||||||
|
|
||||||
let fts = substitute(&ft, '-', '_', 'g')
|
let fts = substitute(&ft, '-', '_', 'g')
|
||||||
for ft in split(fts, '\.')
|
for ft in split(fts, '\.')
|
||||||
|
|
||||||
@ -49,10 +51,8 @@ function! g:SyntasticNotifierHighlighting.refresh(loclist)
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Private functions {{{1
|
|
||||||
|
|
||||||
" Remove all error highlights from the window
|
" Remove all error highlights from the window
|
||||||
function! g:SyntasticNotifierHighlighting._reset()
|
function! g:SyntasticNotifierHighlighting.reset(loclist)
|
||||||
for match in getmatches()
|
for match in getmatches()
|
||||||
if stridx(match['group'], 'Syntastic') == 0
|
if stridx(match['group'], 'Syntastic') == 0
|
||||||
call matchdelete(match['id'])
|
call matchdelete(match['id'])
|
||||||
|
@ -5,7 +5,7 @@ let g:loaded_syntastic_notifiers=1
|
|||||||
|
|
||||||
let g:SyntasticNotifiers = {}
|
let g:SyntasticNotifiers = {}
|
||||||
|
|
||||||
let s:notifier_types = ['signs', 'balloons', 'highlighting', 'autoloclist']
|
let s:notifier_types = ['signs', 'balloons', 'highlighting', 'cursor', 'autoloclist']
|
||||||
|
|
||||||
" Public methods {{{1
|
" Public methods {{{1
|
||||||
|
|
||||||
@ -25,10 +25,19 @@ endfunction
|
|||||||
|
|
||||||
function! g:SyntasticNotifiers.refresh(loclist)
|
function! g:SyntasticNotifiers.refresh(loclist)
|
||||||
for type in self._enabled_types
|
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)
|
call self._notifier[type].refresh(a:loclist)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
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:
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
@ -51,6 +51,10 @@ function! g:SyntasticNotifierSigns.New()
|
|||||||
return newObj
|
return newObj
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! g:SyntasticNotifierSigns.enabled()
|
||||||
|
return exists('b:syntastic_enable_signs') ? b:syntastic_enable_signs : g:syntastic_enable_signs
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Update the error signs
|
" Update the error signs
|
||||||
function! g:SyntasticNotifierSigns.refresh(loclist)
|
function! g:SyntasticNotifierSigns.refresh(loclist)
|
||||||
let old_signs = copy(self._bufSignIds())
|
let old_signs = copy(self._bufSignIds())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user