2020-01-28 21:07:36 -05:00
|
|
|
let s:indicator_infos = get(g:, 'lightline#ale#indicator_infos', 'I: ')
|
2018-06-14 06:31:12 -04:00
|
|
|
let s:indicator_warnings = get(g:, 'lightline#ale#indicator_warnings', 'W: ')
|
|
|
|
let s:indicator_errors = get(g:, 'lightline#ale#indicator_errors', 'E: ')
|
|
|
|
let s:indicator_ok = get(g:, 'lightline#ale#indicator_ok', 'OK')
|
|
|
|
let s:indicator_checking = get(g:, 'lightline#ale#indicator_checking', 'Linting...')
|
|
|
|
|
|
|
|
|
|
|
|
""""""""""""""""""""""
|
|
|
|
" Lightline components
|
|
|
|
|
2020-01-28 21:07:36 -05:00
|
|
|
function! lightline#ale#infos() abort
|
|
|
|
if !lightline#ale#linted()
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
let l:counts = ale#statusline#Count(bufnr(''))
|
|
|
|
return l:counts.info == 0 ? '' : printf(s:indicator_infos . '%d', l:counts.info)
|
|
|
|
endfunction
|
|
|
|
|
2018-06-14 06:31:12 -04:00
|
|
|
function! lightline#ale#warnings() abort
|
|
|
|
if !lightline#ale#linted()
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
let l:counts = ale#statusline#Count(bufnr(''))
|
2020-01-28 21:07:36 -05:00
|
|
|
let l:all_warnings = l:counts.warning + l:counts.style_warning
|
|
|
|
return l:all_warnings == 0 ? '' : printf(s:indicator_warnings . '%d', all_warnings)
|
2018-06-14 06:31:12 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! lightline#ale#errors() abort
|
|
|
|
if !lightline#ale#linted()
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
let l:counts = ale#statusline#Count(bufnr(''))
|
|
|
|
let l:all_errors = l:counts.error + l:counts.style_error
|
|
|
|
return l:all_errors == 0 ? '' : printf(s:indicator_errors . '%d', all_errors)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! lightline#ale#ok() abort
|
|
|
|
if !lightline#ale#linted()
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
let l:counts = ale#statusline#Count(bufnr(''))
|
|
|
|
return l:counts.total == 0 ? s:indicator_ok : ''
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! lightline#ale#checking() abort
|
|
|
|
return ale#engine#IsCheckingBuffer(bufnr('')) ? s:indicator_checking : ''
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
""""""""""""""""""
|
|
|
|
" Helper functions
|
|
|
|
|
|
|
|
function! lightline#ale#linted() abort
|
|
|
|
return get(g:, 'ale_enabled', 0) == 1
|
|
|
|
\ && getbufvar(bufnr(''), 'ale_linted', 0) > 0
|
|
|
|
\ && ale#engine#IsCheckingBuffer(bufnr('')) == 0
|
|
|
|
endfunction
|