feat(blame): show commit's hunk in the line popup

This commit is contained in:
2026-05-26 23:25:08 +02:00
parent 428ded2c4c
commit ff7b20ec46
7 changed files with 589 additions and 65 deletions
+28
View File
@@ -120,6 +120,34 @@ function M.split_lines(content)
return lines
end
---@param buf integer
---@param ns integer
---@param lines string[]
---@param start_row integer 0-indexed row of the first line in `lines`
function M.paint_diff_lines(buf, ns, lines, start_row)
for i, line in ipairs(lines) do
local hl ---@type string?
local prefix = line:sub(1, 1)
if prefix == "+" then
hl = "GitHunkAdded"
elseif prefix == "-" then
hl = "GitHunkRemoved"
elseif vim.startswith(line, "@@") then
hl = "GitHunkHeader"
end
if hl then
pcall(
vim.api.nvim_buf_set_extmark,
buf,
ns,
start_row + i - 1,
0,
{ line_hl_group = hl }
)
end
end
end
---@class ow.Git.Util.DebounceHandle
---@field cancel fun()
---@field flush fun()