feat(git): add in-house hunks module, replace gitsigns.nvim

This commit is contained in:
2026-05-20 06:10:17 +02:00
parent d979c961a2
commit f4181b89fc
13 changed files with 1055 additions and 75 deletions
+59
View File
@@ -194,6 +194,65 @@ function M.debounce(fn, delay)
}
end
---@class ow.Git.Util.KeyedDebounceHandle<K>
---@field cancel fun(key: K)
---@field flush fun(key: K)
---@field pending fun(key: K): boolean
---@field close fun()
---@generic K, F: fun(key: K, ...)
---@param fn F
---@param delay integer
---@return F, ow.Git.Util.KeyedDebounceHandle<K>
function M.keyed_debounce(fn, delay)
---@type table<any, { call: fun(...), handle: ow.Git.Util.DebounceHandle }>
local slots = {}
local function call(key, ...)
local t = type(key)
assert(
t == "string" or t == "number" or t == "boolean",
"key must be a primitive (string, number, boolean)"
)
local slot = slots[key]
if not slot then
local c, h = M.debounce(function(...)
fn(key, ...)
end, delay)
slot = { call = c, handle = h }
slots[key] = slot
end
slot.call(...)
end
return call,
{
cancel = function(key)
local slot = slots[key]
if slot then
slot.handle.close()
slots[key] = nil
end
end,
flush = function(key)
local slot = slots[key]
if slot then
slot.handle.flush()
end
end,
pending = function(key)
local slot = slots[key]
return slot ~= nil and slot.handle.pending()
end,
close = function()
for _, slot in pairs(slots) do
slot.handle.close()
end
slots = {}
end,
}
end
---@class ow.Git.Util.ExecOpts
---@field cwd string?
---@field stdin string?