Ale: Cache Warning and Errors
should provide some better performance
This commit is contained in:
parent
feee9bcf3c
commit
6ab0098ced
|
@ -4,29 +4,46 @@
|
||||||
let s:error_symbol = get(g:, 'airline#extensions#ale#error_symbol', 'E:')
|
let s:error_symbol = get(g:, 'airline#extensions#ale#error_symbol', 'E:')
|
||||||
let s:warning_symbol = get(g:, 'airline#extensions#ale#warning_symbol', 'W:')
|
let s:warning_symbol = get(g:, 'airline#extensions#ale#warning_symbol', 'W:')
|
||||||
|
|
||||||
|
function! s:airline_ale_count(cnt, symbol)
|
||||||
|
return a:cnt ? a:symbol. a:cnt : ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#ale#get(type)
|
function! airline#extensions#ale#get(type)
|
||||||
if !exists(':ALELint')
|
if !exists(':ALELint')
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:is_err = a:type ==# 'error'
|
let is_err = a:type ==# 'error'
|
||||||
let l:counts = ale#statusline#Count(bufnr(''))
|
let symbol = is_err ? s:error_symbol : s:warning_symbol
|
||||||
let l:symbol = l:is_err ? s:error_symbol : s:warning_symbol
|
|
||||||
|
|
||||||
if type(l:counts) == type({}) && has_key(l:counts, 'error')
|
if !exists('b:airline_extensions_ale_dict')
|
||||||
|
let b:airline_extensions_ale_dict = {}
|
||||||
|
let b:airline_extensions_ale_dict.error = 0
|
||||||
|
let b:airline_extensions_ale_dict.warning = 0
|
||||||
|
let b:airline_extensions_ale_dict.change = 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
if b:airline_extensions_ale_dict.change == b:changedtick
|
||||||
|
return s:airline_ale_count(b:airline_extensions_ale_dict[a:type], symbol)
|
||||||
|
endif
|
||||||
|
|
||||||
|
let is_err = a:type ==# 'error'
|
||||||
|
let counts = ale#statusline#Count(bufnr(''))
|
||||||
|
let symbol = is_err ? s:error_symbol : s:warning_symbol
|
||||||
|
|
||||||
|
if type(counts) == type({}) && has_key(counts, 'error')
|
||||||
" Use the current Dictionary format.
|
" Use the current Dictionary format.
|
||||||
let l:errors = l:counts.error + l:counts.style_error
|
let errors = counts.error + counts.style_error
|
||||||
let l:num = l:is_err ? l:errors : l:counts.total - l:errors
|
let num = is_err ? errors : counts.total - errors
|
||||||
else
|
else
|
||||||
" Use the old List format.
|
" Use the old List format.
|
||||||
let l:num = l:is_err ? l:counts[0] : l:counts[1]
|
let num = is_err ? counts[0] : counts[1]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if l:num == 0
|
let b:airline_extensions_ale_dict[a:type] = num
|
||||||
return ''
|
let b:airline_extensions_ale_dict['change'] = b:changedtick
|
||||||
else
|
|
||||||
return l:symbol . l:num
|
return s:airline_ale_count(num, symbol)
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#ale#get_warning()
|
function! airline#extensions#ale#get_warning()
|
||||||
|
|
Loading…
Reference in New Issue