From 9a3568b815b57b8552a2a552b4f616603cb20667 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Fri, 10 Dec 2021 14:02:34 -0500 Subject: [PATCH] nvimlsp: use vim.diagnostic.get() if available --- autoload/airline/extensions/nvimlsp.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions/nvimlsp.vim b/autoload/airline/extensions/nvimlsp.vim index c4aa328a..4ccb1e12 100644 --- a/autoload/airline/extensions/nvimlsp.vim +++ b/autoload/airline/extensions/nvimlsp.vim @@ -26,7 +26,10 @@ function! airline#extensions#nvimlsp#get(type) abort let symbol = is_err ? error_symbol : warning_symbol - if luaeval("pcall(require, 'vim.lsp.diagnostic')") + if luaeval("pcall(require, 'vim.diagnostic')") + let severity = a:type == 'Warning' ? 'Warn' : a:type + let num = len(v:lua.vim.diagnostic.get(0, { 'severity': severity })) + elseif luaeval("pcall(require, 'vim.lsp.diagnostic')") let num = v:lua.vim.lsp.diagnostic.get_count(0, a:type) else let num = v:lua.vim.lsp.util.buf_diagnostics_count(a:type)