Skip to content

Commit 68a2a09

Browse files
feat(diagnostics): add diagnostics.severity (#1755)
* feat: Support diagnostics severity * fix: Revert Hunk * feat: Supports min/max severity * feat: Supports min/max severity: tidy doc * feat: Supports min/max severity: tidy doc * feat: Supports min/max severity: tidy doc Co-authored-by: Alexander Courtis <alex@courtis.org>
1 parent cc18122 commit 68a2a09

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

doc/nvim-tree-lua.txt

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ Subsequent calls to setup will replace the previous configuration.
291291
enable = false,
292292
show_on_dirs = false,
293293
debounce_delay = 50,
294+
severity = {
295+
min = vim.diagnostic.severity.HINT,
296+
max = vim.diagnostic.severity.ERROR
297+
},
294298
icons = {
295299
hint = "",
296300
info = "",
@@ -365,6 +369,9 @@ Subsequent calls to setup will replace the previous configuration.
365369
ignore = {},
366370
},
367371
},
372+
notify = {
373+
threshold = vim.log.levels.INFO,
374+
},
368375
log = {
369376
enable = false,
370377
truncate = false,
@@ -379,9 +386,6 @@ Subsequent calls to setup will replace the previous configuration.
379386
watcher = false,
380387
},
381388
},
382-
notify = {
383-
threshold = vim.log.levels.INFO,
384-
},
385389
} -- END_DEFAULT_OPTS
386390
<
387391

@@ -532,6 +536,13 @@ Configuration options for the system open command.
532536
*nvim-tree.diagnostics*
533537
Show LSP and COC diagnostics in the signcolumn
534538

539+
`NOTE`: it will use the default diagnostic color groups to highlight the signs.
540+
If you wish to customize, you can override these groups:
541+
- `NvimTreeLspDiagnosticsError`
542+
- `NvimTreeLspDiagnosticsWarning`
543+
- `NvimTreeLspDiagnosticsInformation`
544+
- `NvimTreeLspDiagnosticsHint`
545+
535546
*nvim-tree.diagnostics.enable*
536547
Enable/disable the feature.
537548
Type: `boolean`, Default: `false`
@@ -548,12 +559,16 @@ Show LSP and COC diagnostics in the signcolumn
548559
Icons for diagnostic severity.
549560
Type: `table`, Default: `{ hint = "", info = "", warning = "", error = "" }`
550561

551-
`NOTE`: it will use the default diagnostic color groups to highlight the signs.
552-
If you wish to customize, you can override these groups:
553-
- `NvimTreeLspDiagnosticsError`
554-
- `NvimTreeLspDiagnosticsWarning`
555-
- `NvimTreeLspDiagnosticsInformation`
556-
- `NvimTreeLspDiagnosticsHint`
562+
*nvim-tree.diagnostics.severity*
563+
Severity for which the diagnostics will be displayed. See |diagnostic-severity|
564+
565+
*nvim-tree.diagnostics.severity.min*
566+
Minimum severity.
567+
Type: |vim.diagnostic.severity|, Default: `vim.diagnostic.severity.HINT`
568+
569+
*nvim-tree.diagnostics.severity.max*
570+
Maximum severity.
571+
Type: |vim.diagnostic.severity|, Default: `vim.diagnostic.severity.ERROR`
557572

558573
*nvim-tree.git*
559574
Git integration with icons and colors.

lua/nvim-tree.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,10 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
569569
enable = false,
570570
show_on_dirs = false,
571571
debounce_delay = 50,
572+
severity = {
573+
min = vim.diagnostic.severity.HINT,
574+
max = vim.diagnostic.severity.ERROR,
575+
},
572576
icons = {
573577
hint = "",
574578
info = "",

lua/nvim-tree/diagnostics.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ end
2727
local function from_nvim_lsp()
2828
local buffer_severity = {}
2929

30-
for _, diagnostic in ipairs(vim.diagnostic.get()) do
30+
for _, diagnostic in ipairs(vim.diagnostic.get(nil, { severity = M.severity })) do
3131
local buf = diagnostic.bufnr
3232
if vim.api.nvim_buf_is_valid(buf) then
3333
local bufname = vim.api.nvim_buf_get_name(buf)
@@ -140,6 +140,7 @@ local links = {
140140
function M.setup(opts)
141141
M.enable = opts.diagnostics.enable
142142
M.debounce_delay = opts.diagnostics.debounce_delay
143+
M.severity = opts.diagnostics.severity
143144

144145
if M.enable then
145146
log.line("diagnostics", "setup")

0 commit comments

Comments
 (0)