From 238df23ee06f41c12cf68348c5f3a3d01c379572 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sat, 7 Feb 2026 17:57:53 -0500 Subject: [PATCH] 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)". --- lua/diffs/conflict.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lua/diffs/conflict.lua b/lua/diffs/conflict.lua index 52397fe..84cc2fa 100644 --- a/lua/diffs/conflict.lua +++ b/lua/diffs/conflict.lua @@ -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