Skip to content

Conversation

@iabdelkareem
Copy link
Contributor

@iabdelkareem iabdelkareem commented Nov 19, 2022

Resolves #1756

Copy link
Member

@alex-courtis alex-courtis left a 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.

local buffer_severity = {}

for _, diagnostic in ipairs(vim.diagnostic.get()) do
for _, diagnostic in ipairs(vim.diagnostic.get(nil, { severity = M.severity })) do
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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!

enable = false,
show_on_dirs = false,
debounce_delay = 50,
severity = null,
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@iabdelkareem iabdelkareem requested review from alex-courtis and gegoune and removed request for alex-courtis November 20, 2022 00:49
@iabdelkareem
Copy link
Contributor Author

Thank you! Glad you liked the idea ^^ I updated the PR according to the comments.

Copy link
Member

@alex-courtis alex-courtis left a 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.

},
notify = {
threshold = vim.log.levels.INFO,
},
Copy link
Member

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...

@alex-courtis alex-courtis merged commit 68a2a09 into nvim-tree:master Nov 20, 2022
@textzenith
Copy link

Thanks—this is invaluable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support diagnostics severity

4 participants