GetlinterStatus gets status from ale or signs

This commit is contained in:
ManjaroOne666 2018-06-08 14:33:33 +01:00
parent ef052d91a5
commit fcd199af39
1 changed files with 43 additions and 2 deletions

View File

@ -165,9 +165,19 @@ endfunction
"}}}
function! GetLinterStatus(key) abort
let l:linter = ale#statusline#Count(bufnr(''))"{{{
"{{{
let l:statuscount = 0
return l:linter[a:key]
if exists('b:ale_linted')
let l:linter = ale#statusline#Count(bufnr(''))
else
let l:linter = GetDiagnosticCountsFromSigns(bufnr(''))
endif
if has_key(l:linter, a:key)
let l:statuscount = l:linter[a:key]
endif
return l:statuscount
endfunction
"}}}
@ -228,6 +238,37 @@ command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
let g:shell_scratch_buffer_nr = -1
"}}}
function! GetDiagnosticCountsFromSigns(buffer) abort
let l:error = 0
let l:warn = 0
let l:info = 0
let l:hint = 0
redir => l:result
silent exec 'sign place buffer=' . a:buffer
redir end
let l:lines = split(l:result, '\n')
for l:line in l:lines
if l:line =~? 'Error'
let l:error += 1
endif
if l:line =~? 'Warning'
let l:warn += 1
endif
if l:line =~? 'Info'
let l:info += 1
endif
if l:line =~? 'Hint'
let l:hint += 1
endif
endfor
return {'error': l:error, 'warning': l:warn, 'info': l:info, 'hint': l:hint}
endfunction
" https://stackoverflow.com/a/40195855
" ex_command: command to run to execute file