Skip to content

Commit

Permalink
Fix for third party sources like coc.nvim
Browse files Browse the repository at this point in the history
Ref: dense-analysis/ale#4737

Note: this commit should be reverted when this issue has beed fixed.
  • Loading branch information
sainnhe committed Mar 8, 2024
1 parent 1e8de96 commit 29735b0
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions autoload/lightline/ale.vim
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ function! lightline#ale#infos() abort
if !lightline#ale#linted()
return ''
endif
let l:counts = ale#statusline#Count(bufnr(''))
let l:counts = lightline#ale#count(bufnr(''))
return l:counts.info == 0 ? '' : printf(s:indicator_infos . '%d', l:counts.info)
endfunction

function! lightline#ale#warnings() abort
if !lightline#ale#linted()
return ''
endif
let l:counts = ale#statusline#Count(bufnr(''))
let l:counts = lightline#ale#count(bufnr(''))
let l:all_warnings = l:counts.warning + l:counts.style_warning
return l:all_warnings == 0 ? '' : printf(s:indicator_warnings . '%d', all_warnings)
endfunction
Expand All @@ -30,7 +30,7 @@ function! lightline#ale#errors() abort
if !lightline#ale#linted()
return ''
endif
let l:counts = ale#statusline#Count(bufnr(''))
let l:counts = lightline#ale#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
Expand All @@ -39,7 +39,7 @@ function! lightline#ale#ok() abort
if !lightline#ale#linted()
return ''
endif
let l:counts = ale#statusline#Count(bufnr(''))
let l:counts = lightline#ale#count(bufnr(''))
return l:counts.total == 0 ? s:indicator_ok : ''
endfunction

Expand All @@ -64,3 +64,16 @@ function! lightline#ale#linted() abort
\ && getbufvar(bufnr(''), 'ale_linted', 0) > 0
\ && ale#engine#IsCheckingBuffer(bufnr('')) == 0
endfunction

function! lightline#ale#count(buffer) abort
" Force refresh the count info
" https://github.com/dense-analysis/ale/issues/4737
call ale#statusline#Update(
\ a:buffer,
\ g:ale_buffer_info[a:buffer].loclist
\ )
call ale#sign#SetSigns(
\ a:buffer,
\ g:ale_buffer_info[a:buffer].loclist)
return ale#statusline#Count(a:buffer)
endfunction

0 comments on commit 29735b0

Please sign in to comment.