Implement a more efficient statusbar

The statusbar now keeps its state in a separate variable, in order to
avoid excess iterations. The engine now updates said variable on run,
and a new function is made available for external statusbars to call (to
avoid dependencies on internal implementation details of ale).

To keep things light, the status bar code is not loaded unless invoked
by the user or an external plugin. On the first load it will update
itself from the global loclist, after that, the engine will handle all
updates.

The external integration function, `ale#statusline#Count()`, will return
a tuple in the format [E, W] (where E is errors, W is warnings), unless
no data exists (ie, the plugin doesn't have a linter for a file or has
not run yet), in which case it returns 0/false.
This commit is contained in:
Bjorn Neergaard
2016-10-11 16:51:01 -05:00
parent f4159ac7ee
commit dc58db7640
5 changed files with 76 additions and 40 deletions

View File

@@ -24,6 +24,7 @@ endif
" Globals
let g:ale_buffer_count_map = {}
let g:ale_buffer_loclist_map = {}
let g:ale_buffer_should_reset_map = {}
let g:ale_buffer_sign_dummy_map = {}
@@ -98,7 +99,8 @@ let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error')
let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning')
" This flag can be set to 0 to disable echoing when the cursor moves.
if get(g:, 'ale_echo_cursor', 1)
let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1)
if g:ale_echo_cursor
augroup ALECursorGroup
autocmd!
autocmd CursorMoved,CursorHold * call ale#cursor#EchoCursorWarningWithDelay()
@@ -120,10 +122,10 @@ let g:ale_warn_about_trailing_whitespace =
" Housekeeping
augroup ALECleanup
augroup ALECleanupGroup
autocmd!
" Clean up buffers automatically when they are unloaded.
autocmd BufUnload * call ale#cleanup#Buffer('<abuf>')
autocmd BufUnload * call ale#cleanup#Buffer(expand('<abuf>'))
augroup END
" Backwards Compatibility