From 861f83600abbdcf671e2b7eec976bc6dffba7277 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 9 Feb 2026 13:27:09 -0500 Subject: [PATCH] refactor(conflict): keep default virtual text labels minimal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- doc/diffs.nvim.txt | 11 ++++------- lua/diffs/conflict.lua | 8 ++------ spec/conflict_spec.lua | 29 +---------------------------- 3 files changed, 7 insertions(+), 41 deletions(-) diff --git a/doc/diffs.nvim.txt b/doc/diffs.nvim.txt index 4d96f33..f199d31 100644 --- a/doc/diffs.nvim.txt +++ b/doc/diffs.nvim.txt @@ -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. diff --git a/lua/diffs/conflict.lua b/lua/diffs/conflict.lua index e2a5298..ce3618d 100644 --- a/lua/diffs/conflict.lua +++ b/lua/diffs/conflict.lua @@ -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 diff --git a/spec/conflict_spec.lua b/spec/conflict_spec.lua index a64911a..b163960 100644 --- a/spec/conflict_spec.lua +++ b/spec/conflict_spec.lua @@ -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