feat(nvim-tree): aggregate child git status onto directory nodes

This commit is contained in:
2026-05-07 00:10:01 +02:00
parent 7083584628
commit 66ceb352aa
3 changed files with 37 additions and 3 deletions
+23
View File
@@ -45,6 +45,29 @@ function Status:by_kind(kind)
return out
end
---@param prefix string
---@return ow.Git.Status.Entry[]
function Status:aggregate_at(prefix)
local match = (prefix == "" or prefix == ".") and "" or prefix .. "/"
local seen = {}
local out = {}
for path, list in pairs(self.entries) do
if path == prefix or vim.startswith(path, match) then
for _, e in ipairs(list) do
local key = e.char .. "\0" .. e.hl
if not seen[key] then
seen[key] = true
table.insert(out, e)
end
end
end
end
table.sort(out, function(a, b)
return a.char < b.char
end)
return out
end
---@param x string
---@return string char, string hl
local function staged_attrs(x)