Update the ALE extension so it loads better and uses the new count format
This commit is contained in:
parent
e7d18fe427
commit
c8a5efc11e
@ -240,7 +240,7 @@ function! airline#extensions#load()
|
|||||||
call add(loaded_ext, 'syntastic')
|
call add(loaded_ext, 'syntastic')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if (get(g:, 'airline#extensions#ale#enabled', 1) && exists('g:loaded_ale'))
|
if (get(g:, 'airline#extensions#ale#enabled', 1) && exists(':ALELint'))
|
||||||
call airline#extensions#ale#init(s:ext)
|
call airline#extensions#ale#init(s:ext)
|
||||||
call add(loaded_ext, 'ale')
|
call add(loaded_ext, 'ale')
|
||||||
endif
|
endif
|
||||||
|
@ -1,23 +1,32 @@
|
|||||||
" MIT License. Copyright (c) 2013-2016 Bjorn Neergaard.
|
" MIT License. Copyright (c) 2013-2017 Bjorn Neergaard, w0rp
|
||||||
" vim: et ts=2 sts=2 sw=2
|
" vim: et ts=2 sts=2 sw=2
|
||||||
|
|
||||||
if !exists('g:loaded_ale')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
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:count(index)
|
function! airline#extensions#ale#get(type)
|
||||||
let l:buf = bufnr('%')
|
if !exists(':ALELint')
|
||||||
let l:count = ale#statusline#Count(l:buf)
|
return ''
|
||||||
if type(l:count) ==# type(0)
|
|
||||||
let l:count = 0
|
|
||||||
else
|
|
||||||
let l:count = l:count[a:index]
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return l:count
|
let l:is_err = a:type ==# 'error'
|
||||||
|
let l:counts = ale#statusline#Count(bufnr(''))
|
||||||
|
let l:symbol = l:is_err ? s:error_symbol : s:warning_symbol
|
||||||
|
|
||||||
|
if type(l:counts) == type({}) && has_key(l:counts, 'error')
|
||||||
|
" Use the current Dictionary format.
|
||||||
|
let l:errors = l:counts.error + l:counts.style_error
|
||||||
|
let l:num = l:is_err ? l:errors : l:counts.total - l:errors
|
||||||
|
else
|
||||||
|
" Use the old List format.
|
||||||
|
let l:num = l:is_err ? l:counts[0] : l:counts[1]
|
||||||
|
endif
|
||||||
|
|
||||||
|
if l:num == 0
|
||||||
|
return ''
|
||||||
|
else
|
||||||
|
return l:symbol . l:num
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#ale#get_warning()
|
function! airline#extensions#ale#get_warning()
|
||||||
@ -28,16 +37,6 @@ function! airline#extensions#ale#get_error()
|
|||||||
return airline#extensions#ale#get('error')
|
return airline#extensions#ale#get('error')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#ale#get(type)
|
|
||||||
let is_err = a:type is# 'error'
|
|
||||||
let cnt = s:count(is_err)
|
|
||||||
if cnt == 0
|
|
||||||
return ''
|
|
||||||
else
|
|
||||||
return (is_err ? s:error_symbol : s:warning_symbol) . cnt
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! airline#extensions#ale#init(ext)
|
function! airline#extensions#ale#init(ext)
|
||||||
call airline#parts#define_function('ale_error_count', 'airline#extensions#ale#get_error')
|
call airline#parts#define_function('ale_error_count', 'airline#extensions#ale#get_error')
|
||||||
call airline#parts#define_function('ale_warning_count', 'airline#extensions#ale#get_warning')
|
call airline#parts#define_function('ale_warning_count', 'airline#extensions#ale#get_warning')
|
||||||
|
Loading…
Reference in New Issue
Block a user