Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down Expand Up @@ -365,6 +369,9 @@ Subsequent calls to setup will replace the previous configuration.
ignore = {},
},
},
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...

log = {
enable = false,
truncate = false,
Expand All @@ -379,9 +386,6 @@ Subsequent calls to setup will replace the previous configuration.
watcher = false,
},
},
notify = {
threshold = vim.log.levels.INFO,
},
} -- END_DEFAULT_OPTS
<

Expand Down Expand Up @@ -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`
Expand All @@ -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*
Minimum severity.
Type: |vim.diagnostic.severity|, Default: `vim.diagnostic.severity.ERROR`

*nvim-tree.git*
Git integration with icons and colors.
Expand Down
4 changes: 4 additions & 0 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
3 changes: 2 additions & 1 deletion lua/nvim-tree/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
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!

local buf = diagnostic.bufnr
if vim.api.nvim_buf_is_valid(buf) then
local bufname = vim.api.nvim_buf_get_name(buf)
Expand Down Expand Up @@ -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")
Expand Down