feat: basic all-line blaming done

This commit is contained in:
2025-09-11 00:05:39 +02:00
parent 89f0df3d60
commit 7925cdd229
2 changed files with 22 additions and 6 deletions

View File

@@ -1,5 +1,9 @@
local ns = vim.api.nvim_create_namespace('line-blame');
local lineBlame = function(input_file_path)
local ns = vim.api.nvim_create_namespace('line_blame');
-- lineBlame
-- - does everything the plugin needs xd
-- @param blame_highlight: 'Normal'
-- @param blame_position: 'eol' | 'overlay' | 'right_align'
local lineBlame = function(input_file_path, input_comma_separated_mail_list, blame_text, blame_highlight, blame_position)
local handler = io.popen("git blame -e " .. input_file_path .. " | awk '{ print $2$6}'")
if handler == nil then
@@ -8,9 +12,20 @@ local lineBlame = function(input_file_path)
local result = handler:read("L")
while result do
for k, v in string.gmatch(result, "%(<(.+)>(%d+)%)") do
-- print(input_file_path, k, v)
local extid = vim.api.nvim_buf_set_extmark(0, ns, tonumber(v), 0, { end_row = tonumber(v), end_col = 30 ,virt_text = {[ "test", "WildMenu"]}})
for current_line_mail, line_number in string.gmatch(result, "%(<(.+)>(%d+)%)") do
for target_mail in string.gmatch(input_comma_separated_mail_list, "[^,]+") do
if target_mail == current_line_mail then
local extid = vim.api.nvim_buf_set_extmark(0, ns, tonumber(line_number), 0, {
id = tonumber(line_number),
virt_text = { { blame_text, blame_highlight } },
virt_text_pos = blame_position,
priority = 700,
hl_mode = 'combine',
})
end
end
-- ,virt_text = {[ "test", "WildMenu"]}
end
result = handler:read("L")
end

View File

@@ -10,7 +10,8 @@ local function setup(opts)
end
local function blameCurrentFile()
blame.lineBlame(vim.api.nvim_buf_get_name(0))
blame.lineBlame(vim.api.nvim_buf_get_name(0), "test,another,dani.heras@hotmail.com,final", "| Found a fkin monkey 🐒",
"Normal", "eol")
end
return {