feat(git): per-key cache invalidation and optional submodule tracking

This commit is contained in:
2026-05-19 09:50:31 +02:00
parent c66b2f04d2
commit 5f956401c1
7 changed files with 611 additions and 69 deletions
+22 -6
View File
@@ -34,6 +34,15 @@ local function clear(buf)
vim.b[buf].git_status_string = nil
end
---@param buf integer
---@param r ow.Git.Repo
---@param rel string
local function set_status(buf, r, rel)
local entry = r.status.entries[rel]
vim.b[buf].git_status = { head = r:head(), entry = entry }
vim.b[buf].git_status_string = render(entry)
end
---@param buf integer
---@param r ow.Git.Repo?
local function update_buf(buf, r)
@@ -52,18 +61,25 @@ local function update_buf(buf, r)
if not rel then
return clear(buf)
end
local entry = r.status.entries[rel]
vim.b[buf].git_status = { head = r:head(), entry = entry }
vim.b[buf].git_status_string = render(entry)
set_status(buf, r, rel)
end
repo.on("refresh", function(r)
local any_visible = false
for buf in pairs(r.buffers) do
if vim.api.nvim_buf_is_loaded(buf) then
update_buf(buf, r)
if not any_visible and #vim.fn.win_findbuf(buf) > 0 then
any_visible = true
local name = vim.api.nvim_buf_get_name(buf)
if name ~= "" and not util.is_uri(name) then
local rel = vim.fs.relpath(r.worktree, vim.fn.resolve(name))
if rel then
set_status(buf, r, rel)
if
not any_visible
and #vim.fn.win_findbuf(buf) > 0
then
any_visible = true
end
end
end
end
end