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>
This commit is contained in:
Ibrahim Abdelkareem 2022-11-20 23:09:09 +01:00 committed by GitHub
parent cc18122be1
commit 68a2a0971e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 10 deletions

View File

@ -291,6 +291,10 @@ Subsequent calls to setup will replace the previous configuration.
enable = false,
show_on_dirs = false,
debounce_delay = 50,
severity = {
min = vim.diagnostic.severity.HINT,
max = vim.diagnostic.severity.ERROR
},
icons = {
hint = "",
info = "",
@ -365,6 +369,9 @@ Subsequent calls to setup will replace the previous configuration.
ignore = {},
},
},
notify = {
threshold = vim.log.levels.INFO,
},
log = {
enable = false,
truncate = false,
@ -379,9 +386,6 @@ Subsequent calls to setup will replace the previous configuration.
watcher = false,
},
},
notify = {
threshold = vim.log.levels.INFO,
},
} -- END_DEFAULT_OPTS
<
@ -532,6 +536,13 @@ Configuration options for the system open command.
*nvim-tree.diagnostics*
Show LSP and COC diagnostics in the signcolumn
`NOTE`: it will use the default diagnostic color groups to highlight the signs.
If you wish to customize, you can override these groups:
- `NvimTreeLspDiagnosticsError`
- `NvimTreeLspDiagnosticsWarning`
- `NvimTreeLspDiagnosticsInformation`
- `NvimTreeLspDiagnosticsHint`
*nvim-tree.diagnostics.enable*
Enable/disable the feature.
Type: `boolean`, Default: `false`
@ -548,12 +559,16 @@ Show LSP and COC diagnostics in the signcolumn
Icons for diagnostic severity.
Type: `table`, Default: `{ hint = "", info = "", warning = "", error = "" }`
`NOTE`: it will use the default diagnostic color groups to highlight the signs.
If you wish to customize, you can override these groups:
- `NvimTreeLspDiagnosticsError`
- `NvimTreeLspDiagnosticsWarning`
- `NvimTreeLspDiagnosticsInformation`
- `NvimTreeLspDiagnosticsHint`
*nvim-tree.diagnostics.severity*
Severity for which the diagnostics will be displayed. See |diagnostic-severity|
*nvim-tree.diagnostics.severity.min*
Minimum severity.
Type: |vim.diagnostic.severity|, Default: `vim.diagnostic.severity.HINT`
*nvim-tree.diagnostics.severity.max*
Maximum severity.
Type: |vim.diagnostic.severity|, Default: `vim.diagnostic.severity.ERROR`
*nvim-tree.git*
Git integration with icons and colors.

View File

@ -569,6 +569,10 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
enable = false,
show_on_dirs = false,
debounce_delay = 50,
severity = {
min = vim.diagnostic.severity.HINT,
max = vim.diagnostic.severity.ERROR,
},
icons = {
hint = "",
info = "",

View File

@ -27,7 +27,7 @@ end
local function from_nvim_lsp()
local buffer_severity = {}
for _, diagnostic in ipairs(vim.diagnostic.get()) do
for _, diagnostic in ipairs(vim.diagnostic.get(nil, { severity = M.severity })) do
local buf = diagnostic.bufnr
if vim.api.nvim_buf_is_valid(buf) then
local bufname = vim.api.nvim_buf_get_name(buf)
@ -140,6 +140,7 @@ local links = {
function M.setup(opts)
M.enable = opts.diagnostics.enable
M.debounce_delay = opts.diagnostics.debounce_delay
M.severity = opts.diagnostics.severity
if M.enable then
log.line("diagnostics", "setup")