2017-06-25 18:49:18 +00:00
|
|
|
" MIT License. Copyright (c) 2013-2017 Bjorn Neergaard, w0rp
|
2016-10-10 01:27:51 +00:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
|
|
|
let s:error_symbol = get(g:, 'airline#extensions#ale#error_symbol', 'E:')
|
|
|
|
let s:warning_symbol = get(g:, 'airline#extensions#ale#warning_symbol', 'W:')
|
|
|
|
|
2017-06-25 18:49:18 +00:00
|
|
|
function! airline#extensions#ale#get(type)
|
|
|
|
if !exists(':ALELint')
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
|
|
|
|
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
|
2016-10-10 01:27:51 +00:00
|
|
|
else
|
2017-06-25 18:49:18 +00:00
|
|
|
" Use the old List format.
|
|
|
|
let l:num = l:is_err ? l:counts[0] : l:counts[1]
|
2016-10-10 01:27:51 +00:00
|
|
|
endif
|
|
|
|
|
2017-06-25 18:49:18 +00:00
|
|
|
if l:num == 0
|
|
|
|
return ''
|
|
|
|
else
|
|
|
|
return l:symbol . l:num
|
|
|
|
endif
|
2016-10-10 01:27:51 +00:00
|
|
|
endfunction
|
|
|
|
|
2017-06-20 20:23:46 +00:00
|
|
|
function! airline#extensions#ale#get_warning()
|
|
|
|
return airline#extensions#ale#get('warning')
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#extensions#ale#get_error()
|
|
|
|
return airline#extensions#ale#get('error')
|
|
|
|
endfunction
|
|
|
|
|
2016-10-10 01:27:51 +00:00
|
|
|
function! airline#extensions#ale#init(ext)
|
2017-06-20 20:23:46 +00:00
|
|
|
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')
|
2016-10-10 01:27:51 +00:00
|
|
|
endfunction
|