show diagnostics on parent dirs if nodes with diagnostics are not visible (#862)

This commit is contained in:
Reviakin Evgeny 2021-12-24 13:47:23 +02:00 committed by GitHub
parent bb12c70367
commit 239f2d6fea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -85,6 +85,7 @@ function.
update_cwd = false,
diagnostics = {
enable = false,
show_on_dirs = false,
icons = {
hint = "",
info = "",
@ -231,6 +232,11 @@ Here is a list of the options available in the setup call:
type: `boolean`
default: `false`
- diagnostics.show_on_dirs: if the node with diagnostic is not visible,
then show diagnostic in the parent directory
type: `boolean`
default: `false`
- |diagnostics.icons|: icons for diagnostic severity
type: `table`
default: `{ hint = "", info = "", warning = "", error = "" }`

View File

@ -431,6 +431,7 @@ local DEFAULT_OPTS = {
},
diagnostics = {
enable = false,
show_on_dirs = false,
icons = {
hint = "",
info = "",

View File

@ -125,7 +125,11 @@ function M.update()
for bufname, severity in pairs(buffer_severity) do
if 0 < severity and severity < 5 then
local node, line = utils.find_node(nodes, function(node)
return node.absolute_path == bufname
if M.show_on_dirs and not node.open then
return vim.startswith(bufname, node.absolute_path)
else
return node.absolute_path == bufname
end
end)
if node then add_sign(line, severity) end
end
@ -142,6 +146,7 @@ local links = {
function M.setup(opts)
M.enable = opts.diagnostics.enable
M.show_on_dirs = opts.diagnostics.show_on_dirs
vim.fn.sign_define(sign_names[1][1], { text = opts.diagnostics.icons.error, texthl = sign_names[1][2] })
vim.fn.sign_define(sign_names[2][1], { text = opts.diagnostics.icons.warning, texthl = sign_names[2][2] })
vim.fn.sign_define(sign_names[3][1], { text = opts.diagnostics.icons.info, texthl = sign_names[3][2] })