feat(blame): show commit's hunk in the line popup
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user