refactor(conflict): keep default virtual text labels minimal

Problem: default labels included keymap hints ("current — doo") which
is an anti-pattern for a vim plugin — discoverability belongs in docs
and opt-in config, not baked into the default UI.

Solution: default labels return to plain "(current)" / "(incoming)".
Keymap hints are only shown when users provide a format_virtual_text
function or enable show_actions.
This commit is contained in:
Barrett Ruth 2026-02-09 13:27:09 -05:00
parent c9e2722d19
commit 861f83600a
3 changed files with 7 additions and 41 deletions

View file

@ -444,13 +444,10 @@ Configuration: ~
diagnostics alone.
{show_virtual_text} (boolean, default: true)
Show virtual text labels at the end of
`<<<<<<<` and `>>>>>>>` marker lines.
Default labels include keymap hints:
`(current — doo)` and `(incoming — dot)`.
If a keymap is `false`, the hint is omitted.
Also controls hunk hints in merge diff
views.
Show `(current)` and `(incoming)` labels at
the end of `<<<<<<<` and `>>>>>>>` marker
lines. Also controls hunk hints in merge
diff views.
{format_virtual_text} (function|nil, default: nil)
Custom formatter for virtual text labels.

View file

@ -96,15 +96,11 @@ end
---@param config diffs.ConflictConfig
---@return string?
local function get_virtual_text_label(side, config)
local keymap = side == 'ours' and config.keymaps.ours or config.keymaps.theirs
if config.format_virtual_text then
local keymap = side == 'ours' and config.keymaps.ours or config.keymaps.theirs
return config.format_virtual_text(side, keymap)
end
local label = side == 'ours' and 'current' or 'incoming'
if keymap then
return ('%s \226\128\148 %s'):format(label, keymap)
end
return label
return side == 'ours' and 'current' or 'incoming'
end
---@param bufnr integer

View file

@ -692,7 +692,7 @@ describe('conflict', function()
conflict.detach(vim.api.nvim_get_current_buf())
end)
it('includes keymap hints in default virtual text', function()
it('default labels show current and incoming without keymaps', function()
local bufnr = create_file_buffer({
'<<<<<<< HEAD',
'local x = 1',
@ -703,33 +703,6 @@ describe('conflict', function()
conflict.attach(bufnr, default_config())
local extmarks = get_extmarks(bufnr)
local labels = {}
for _, mark in ipairs(extmarks) do
if mark[4] and mark[4].virt_text then
table.insert(labels, mark[4].virt_text[1][1])
end
end
assert.are.equal(2, #labels)
assert.is_truthy(labels[1]:find('current'))
assert.is_truthy(labels[1]:find('doo'))
assert.is_truthy(labels[2]:find('incoming'))
assert.is_truthy(labels[2]:find('dot'))
helpers.delete_buffer(bufnr)
end)
it('omits keymap from label when keymap is false', function()
local bufnr = create_file_buffer({
'<<<<<<< HEAD',
'local x = 1',
'=======',
'local x = 2',
'>>>>>>> feature',
})
conflict.attach(bufnr, default_config({ keymaps = { ours = false, theirs = false } }))
local extmarks = get_extmarks(bufnr)
local labels = {}
for _, mark in ipairs(extmarks) do