diff --git a/README.md b/README.md index 1d74045..a762471 100644 --- a/README.md +++ b/README.md @@ -512,7 +512,7 @@ sections = { 'diagnostics', -- Table of diagnostic sources, available sources are: - -- 'nvim_lsp', 'nvim_diagnostic', 'coc', 'ale', 'vim_lsp'. + -- 'nvim_lsp', 'nvim_diagnostic', 'nvim_workspace_diagnostic', 'coc', 'ale', 'vim_lsp'. -- or a function that returns a table as such: -- { error=error_cnt, warn=warn_cnt, info=info_cnt, hint=hint_cnt } sources = { 'nvim_diagnostic', 'coc' }, diff --git a/doc/lualine.txt b/doc/lualine.txt index 8107464..d4db421 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -530,7 +530,7 @@ Component specific options These are options that are available on 'diagnostics', -- Table of diagnostic sources, available sources are: - -- 'nvim_lsp', 'nvim_diagnostic', 'coc', 'ale', 'vim_lsp'. + -- 'nvim_lsp', 'nvim_diagnostic', 'nvim_workspace_diagnostic', 'coc', 'ale', 'vim_lsp'. -- or a function that returns a table as such: -- { error=error_cnt, warn=warn_cnt, info=info_cnt, hint=hint_cnt } sources = { 'nvim_diagnostic', 'coc' }, diff --git a/lua/lualine/components/diagnostics/sources.lua b/lua/lualine/components/diagnostics/sources.lua index f4ef71c..22c5587 100644 --- a/lua/lualine/components/diagnostics/sources.lua +++ b/lua/lualine/components/diagnostics/sources.lua @@ -30,6 +30,19 @@ M.sources = { end return error_count, warning_count, info_count, hint_count end, + nvim_workspace_diagnostic = function() + local diag_severity = vim.diagnostic.severity + + local function workspace_diag(severity) + local count = vim.diagnostic.get(nil, {severity = severity}) + return vim.tbl_count(count) + end + + return workspace_diag(diag_severity.ERROR), + workspace_diag(diag_severity.WARN), + workspace_diag(diag_severity.HINT), + workspace_diag(diag_severity.INFO) + end, nvim_diagnostic = function() local diagnostics = vim.diagnostic.get(0) local count = { 0, 0, 0, 0 }