ale ext: simplify logic

This commit is contained in:
Christian Brabandt 2017-06-20 21:20:24 +02:00
parent 1891933e59
commit 7f3d6287b5
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
1 changed files with 10 additions and 10 deletions

View File

@ -20,17 +20,17 @@ function! s:count(index)
return l:count return l:count
endfunction endfunction
function! airline#extensions#ale#get_errors() function! airline#extensions#ale#get(type)
let l:count = s:count(0) let is_err = a:type is# 'error'
return l:count ? s:error_symbol . l:count : '' let cnt = s:count(is_err)
endfunction if cnt == 0
return ''
function! airline#extensions#ale#get_warnings() else
let l:count = s:count(1) return (is_err ? s:error_symbol : s:warning_symbol) . cnt
return l:count ? s:warning_symbol . l:count : '' endif
endfunction 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_errors') 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_warnings') call airline#parts#define_function('ale_warning_count', 'airline#extensions#ale#get("warning")')
endfunction endfunction