refactor(git): rework module around clearer Status and Repo split

This commit is contained in:
2026-05-06 00:45:56 +02:00
parent 1b43fa6a1c
commit 80d6d465cf
17 changed files with 821 additions and 775 deletions
+31
View File
@@ -0,0 +1,31 @@
local repo = require("git.repo")
local M = {}
---@return string
function M.render()
local r = repo.find()
if not r then
return ""
end
local name = vim.api.nvim_buf_get_name(0)
if name == "" then
return ""
end
local rel = vim.fs.relpath(r.worktree, vim.fn.resolve(name))
local list = rel and r.status.entries[rel]
if not list then
return ""
end
local parts = {}
for _, e in ipairs(list) do
table.insert(parts, string.format("%%#%s#%s%%*", e.hl, e.char))
end
return table.concat(parts, " ")
end
repo.on("refresh", function()
vim.cmd.redrawstatus({ bang = true })
end)
return M