From 9bd6508e8cadf664fef36913318ba63898623ebc Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 25 May 2024 20:39:18 +0800 Subject: [PATCH] fix(statusline): check vim.diagnostic.count --- autoload/SpaceVim/layers/core/statusline.vim | 2 +- lua/spacevim/lsp.lua | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/core/statusline.vim b/autoload/SpaceVim/layers/core/statusline.vim index 0c32b68d0..1f6d08292 100644 --- a/autoload/SpaceVim/layers/core/statusline.vim +++ b/autoload/SpaceVim/layers/core/statusline.vim @@ -257,7 +257,7 @@ endfunction function! s:syntax_checking() abort if SpaceVim#lsp#buf_server_ready() - let counts = v:lua.vim.diagnostic.count(0) + let counts = v:lua.require('spacevim.lsp').lsp_diagnostic_count() let warnings = get(counts, 1, 0) let errors = get(counts, 0, 0) let l = warnings ? '%#SpaceVim_statusline_warn# ● ' . warnings . ' ' : '' diff --git a/lua/spacevim/lsp.lua b/lua/spacevim/lsp.lua index b390c809c..f60d52f1b 100644 --- a/lua/spacevim/lsp.lua +++ b/lua/spacevim/lsp.lua @@ -4,6 +4,13 @@ function M.server_ready() return vim.b.lsp_server_ready end +function M.lsp_diagnostic_count() + if vim.diagnostic.count then + return vim.diagnostic.count(0) + end + return {} +end + M.clients = {} -- store the clients for different filetype -- which can be called via vim.lsp.start_client()