-
-
Notifications
You must be signed in to change notification settings - Fork 628
feat: Support diagnostics severity #1755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support diagnostics severity #1755
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic idea, I think I will be using info.
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is showing only the diagnostics with that exact severity.
:help diagnostic-severity
indicates that you will need to set a min level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct I'll the default value to { min = vim.diagnostic.severity.HINT }
. But I think it's good to keep it like that here so it becomes compatible with other functions that uses severity as an options as per the docs. Example below. What do you think? ^^
1. A single [vim.diagnostic.severity](https://neovim.io/doc/user/diagnostic.html#vim.diagnostic.severity) value:
vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN })
2. A table with a "min" or "max" key (or both):
vim.diagnostic.get(0, { severity = { min = vim.diagnostic.severity.WARN } })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could simply make it explicit in the config and pass it directly to get()
diagnostics = {
severity = {
min = vim.diagnostic.severity.HINT,
max = vim.diagnostic.severity.ERROR,
},
}
This configuration will be validated at setup time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect ^^ I'll do it like that. Thanks!
doc/nvim-tree-lua.txt
Outdated
@@ -291,6 +291,7 @@ Subsequent calls to setup will replace the previous configuration. | |||
enable = false, | |||
show_on_dirs = false, | |||
debounce_delay = 50, | |||
severity = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run update-help.sh as per https://github.com/nvim-tree/nvim-tree.lua/blob/master/CONTRIBUTING.md
This will set the default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Thank you! Glad you liked the idea ^^ I updated the PR according to the comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested OK.
Tidied the doc a little.
@@ -365,6 +369,9 @@ Subsequent calls to setup will replace the previous configuration. | |||
ignore = {}, | |||
}, | |||
}, | |||
notify = { | |||
threshold = vim.log.levels.INFO, | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this was out of order...
Thanks—this is invaluable. |
Resolves #1756