Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
238df23ee0 feat(conflict): show branch names in virtual text labels
Problem: virtual text showed generic "current"/"incoming" labels with
no indication of which branch each side came from.

Solution: extract the branch name from the marker line itself
(e.g. <<<<<<< HEAD, >>>>>>> feature) and display as
"HEAD (current)" / "feature (incoming)".
2026-02-07 17:57:53 -05:00

View file

@ -107,8 +107,15 @@ local function apply_highlights(bufnr, regions, config)
})
if config.show_virtual_text then
local ours_line = vim.api.nvim_buf_get_lines(
bufnr,
region.marker_ours,
region.marker_ours + 1,
false
)[1] or ''
local ours_name = ours_line:match('^<<<<<<<%s+(.+)$') or ''
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, region.marker_ours, 0, {
virt_text = { { ' current', 'DiffsConflictMarker' } },
virt_text = { { ' ' .. ours_name .. ' (current)', 'DiffsConflictMarker' } },
virt_text_pos = 'eol',
})
end
@ -176,8 +183,15 @@ local function apply_highlights(bufnr, regions, config)
})
if config.show_virtual_text then
local theirs_line = vim.api.nvim_buf_get_lines(
bufnr,
region.marker_theirs,
region.marker_theirs + 1,
false
)[1] or ''
local theirs_name = theirs_line:match('^>>>>>>>%s+(.+)$') or ''
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, region.marker_theirs, 0, {
virt_text = { { ' incoming', 'DiffsConflictMarker' } },
virt_text = { { ' ' .. theirs_name .. ' (incoming)', 'DiffsConflictMarker' } },
virt_text_pos = 'eol',
})
end