feat: add workspace diagnostics source (#618)

* feat: add workspace diagnostics source

* doc: add nvim_workspace_diagnostics to list of sources

Co-authored-by: Shadman <13149513+shadmansaleh@users.noreply.github.com>
This commit is contained in:
Yohanes Bandung Bondowoso 2022-07-28 01:02:58 +07:00 committed by GitHub
parent 33f03620c3
commit 0521ada344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -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' },

View File

@ -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' },

View File

@ -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 }