feat(explorer): added diagnostics file/directory status

This commit is contained in:
Folke Lemaitre 2025-02-07 08:45:38 +01:00
parent cc1b6c77aa
commit 7f1b60d557
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
7 changed files with 83 additions and 8 deletions

View file

@ -71,6 +71,15 @@ function State.new(picker)
end
end)
picker.list.win:on("DiagnosticChanged", function(_, ev)
local p = ref()
if p then
require("snacks.explorer.diagnostics").update(p:cwd())
p.list:set_target()
p:find()
end
end)
-- schedule initial follow
if opts.follow_file then
picker.list.win:on({ "WinEnter", "BufEnter" }, function(_, ev)
@ -212,6 +221,10 @@ function M.explorer(opts, ctx)
})
end
if opts.diagnostics then
require("snacks.explorer.diagnostics").update(ctx.filter.cwd)
end
return function(cb)
if state.on_find then
ctx.picker.matcher.task:on("done", vim.schedule_wrap(state.on_find))
@ -232,6 +245,7 @@ function M.explorer(opts, ctx)
status = (not node.dir or not node.open or opts.git_status_open) and node.status or nil,
last = true,
type = node.type,
severity = (not node.dir or not node.open or opts.diagnostics_open) and node.severity or nil,
}
if last[node.parent] then
last[node.parent].last = false