Skip to content

How to reliably get number of errors from after diagnositcs? #374

@fedeDev

Description

@fedeDev

I want to display the number of errors reported by LanguageClient-neovim using vim-arline. What I have right now is:

function! AirlineInit()
  let g:airline_section_x = airline#section#create(['LC_status'])
  let g:airline_section_error = airline#section#create(['LC_error_count'])
endfunction

call airline#parts#define_function('LC_error_count', 'LC_error_count')
call airline#parts#define_function('LC_status', 'LC_status')

function! LC_error_count()
  let count = len(getqflist())
  return count > 0 && g:LanguageClient_loaded ? 'E: ' . count : ''
endfunction

function! LC_status()
  return g:LanguageClient_loaded ? LanguageClient#statusLine() : ''
endfunction

autocmd User AirlineAfterInit call AirlineInit()

This is great for the LanguageClient#statusLine(), however I am currently relying on len(getqflist()) to get the number of errors from LS.

Is there a better way to get this number of diagnostic errors in order to use them in the status line?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions