diff --git a/README.md b/README.md index c9c04f93..3a7b7aec 100644 --- a/README.md +++ b/README.md @@ -111,9 +111,6 @@ own command, e.g. `:command! Review Diff review ++nountracked`. # Acknowledgements - [`vim-fugitive`](https://github.com/tpope/vim-fugitive) -- [@esmuellert](https://github.com/esmuellert) / - [`codediff.nvim`](https://github.com/esmuellert/codediff.nvim) - vscode-diff - algorithm FFI backend for word-level intra-line accuracy - [`diffview.nvim`](https://github.com/sindrets/diffview.nvim) - [`difftastic`](https://github.com/Wilfred/difftastic) - [`mini.diff`](https://github.com/echasnovski/mini.diff) diff --git a/doc/diffs.nvim.txt b/doc/diffs.nvim.txt index a005b8b2..afe86470 100644 --- a/doc/diffs.nvim.txt +++ b/doc/diffs.nvim.txt @@ -154,28 +154,25 @@ Configuration is done via `vim.g.diffs`. Set options before the plugin loads: Use `{ args = {...} }` to forward flags. See |diffs.nvim-difftastic|. - {extra_filetypes} (table, default: {}) - Deprecated. See |diffs.nvim-extra-filetypes|. - {highlights} (table, default: see below) - Controls which highlight features are enabled. + Syntax and diff highlighting. See |diffs.nvim.Highlights| for fields. - {conflict} (boolean|table, default: true) + {conflict} (boolean, default: true) Highlight and resolve inline merge conflicts. + Set to false to disable. + See |diffs.nvim-conflict|. *diffs.nvim.Highlights* Highlights table fields: ~ {background} (boolean, default: true) - Apply background highlighting to `+`/`-` lines - using `DiffsAdd`/`DiffsDelete` groups (derived - from `DiffAdd`/`DiffDelete` backgrounds). + Highlight added and deleted lines with + `DiffsAdd` and `DiffsDelete` backgrounds. {blend_alpha} (number, default: 0.6) - Alpha value for diff line background intensity. - Controls how strongly diff lines (adds/deletes) - stand out from the editor background. Must be - between 0 and 1 (inclusive). + Blend diff backgrounds with the editor background. + Use 0 for the editor background or 1 for the + full `DiffAdd` and `DiffDelete` colors. {warn_max_lines} (boolean, default: true) Show a `vim.notify()` warning when syntax @@ -183,60 +180,47 @@ Configuration is done via `vim.g.diffs`. Set options before the plugin loads: {max_lines}. See |diffs.nvim-max-lines|. {treesitter} (table, default: see below) - Treesitter highlighting limits. + Highlight code with Treesitter when a parser + is available. See |diffs.nvim.TreesitterConfig| for fields. {vim} (boolean|table, default: true) - Vim syntax fallback highlighting options. + Use Vim syntax when no Treesitter parser is + available. Set to false to disable. See |diffs.nvim.VimConfig| for fields. - {intra} (boolean|table, default: true) - Boolean values are deprecated. - See |diffs.nvim-diffopt|. + {intra} (table, default: see below) + Intra-line diff highlighting options. See |diffs.nvim.IntraConfig| for fields. - {overrides} (table, default: {}) - Deprecated. See |diffs.nvim-highlights|. - *diffs.nvim.TreesitterConfig* Treesitter config fields: ~ {max_lines} (integer, default: 500) - Skip treesitter highlighting for hunks with more - highlighted lines (`+`/`-`) than this threshold. - Context lines are not counted. Prevents lag on - massive diffs. + Skip Treesitter highlighting for hunks with more + than this many added and deleted lines. + Context lines do not count toward the limit. *diffs.nvim.VimConfig* Vim config fields: ~ {max_lines} (integer, default: 200) - Skip vim syntax highlighting for hunks with more - highlighted lines (`+`/`-`) than this threshold. - Context lines are not counted. + Skip Vim syntax highlighting for hunks with more + than this many added and deleted lines. + Context lines do not count toward the limit. *diffs.nvim.IntraConfig* Intra config fields: ~ - {algorithm} (string, default: 'default') - Diff algorithm for character-level analysis. - `'default'`: use `vim.diff()` with settings - inherited from `'diffopt'` (`algorithm` and - `linematch`). `'vscode'`: use libvscodediff FFI - (falls back to default if not available). - libvscodediff support will be removed on - 30 November 2026. Remove `highlights.intra.algorithm` - to use Neovim's diff. - {max_lines} (integer, default: 500) - Skip character-level highlighting for hunks with - more highlighted lines (`+`/`-`) than this - threshold. Context lines are not counted. + Skip intra-line highlighting for hunks with more + than this many added and deleted lines. + Context lines do not count toward the limit. - Note: Header context (e.g., `@@ -10,3 +10,4 @@ func()`) is always - highlighted with treesitter when a parser is available. + Treesitter also highlights code in hunk headers, such as `func()` in + `@@ -10,3 +10,4 @@ func()`. - Language detection uses Neovim's built-in `vim.filetype.match()` and - `vim.treesitter.language.get_lang()`. To customize filetype detection - or register treesitter parsers for custom filetypes, use - `vim.filetype.add()` and `vim.treesitter.language.register()`. + diffs.nvim detects the filetype with |vim.filetype.match()| and selects + the parser with |vim.treesitter.language.get_lang()|. Use + |vim.filetype.add()| for custom filetypes and + |vim.treesitter.language.register()| to associate them with a parser. ============================================================================== MAX LINES *diffs.nvim-max-lines* @@ -456,7 +440,7 @@ Paired-window behavior: ~ *diffs.nvim-paired-windows* target language. Each changed line is painted with the same palette as generated buffers, so its background is continuous across the gutter and the text, and changed regions within a line carry the same intra-line word-diff - highlighting, honoring `highlights.intra` (including the `vscode` algorithm). + highlighting, honoring `highlights.intra`. Each pane renders its own side's real line numbers in a `statuscolumn` rail (blank on filler rows), so the rail does not depend on or conflict with a @@ -680,10 +664,6 @@ Whitespace handling: ~ *diffs.nvim-whitespace* - Native |:diffsplit| windows: whitespace is handled by Neovim itself. Limitations: ~ - - With `highlights.intra.algorithm = 'vscode'` the intra-line highlighter - ignores only leading and trailing whitespace; internal whitespace inside - a changed line is still highlighted. A warning is issued once. Use the - `default` algorithm for full whitespace handling. - 'diffopt' `algorithm` and `linematch` are honored by the generated diffs too. `linematch` has no git equivalent, so it shapes the file diffs computed with |vim.diff()| but not the git-backed surfaces (|:Diff-review| @@ -1046,18 +1026,19 @@ unchanged. ============================================================================== CONFLICT RESOLUTION *diffs.nvim-conflict* -diffs.nvim detects inline merge conflict markers (`<<<<<<<`/`=======`/ -`>>>>>>>`) in working files and provides highlighting and resolution actions. -Both standard and diff3 (`|||||||`) formats are supported. +diffs.nvim highlights merge conflicts in working files. It recognizes standard +markers (`<<<<<<<`, `=======`, `>>>>>>>`) and diff3 base sections (`|||||||`). -Conflict regions are detected automatically on `BufReadPost` and re-scanned on -`TextChanged`. When all conflicts in a buffer are resolved, highlighting is -removed. +diffs.nvim detects conflicts when you open a file and updates their highlights +as you edit. Resolve conflicts with the mappings below or edit the text directly. + +To disable conflict handling: >lua + vim.g.diffs = { conflict = false } +< Buffer-local mappings: ~ *diffs.nvim-conflict-keymaps* -`conflict.keymaps` is deprecated and will be removed on 30 November 2026. -Replace it with buffer-local mappings: >lua +Set buffer-local mappings when conflicts are detected: >lua vim.api.nvim_create_autocmd('User', { pattern = 'DiffsConflictDetected', callback = function(event) @@ -1176,8 +1157,7 @@ API *diffs.nvim-api* attach({bufnr}, {options}) *diffs.nvim.attach()* Attach highlighting to a buffer. Called automatically when the buffer's - filetype matches `git`, `gitcommit`, an enabled integration filetype, - or any entry in the deprecated `extra_filetypes` option. + filetype matches `git`, `gitcommit`, or an enabled integration filetype. Direct calls work with any filetype. For automatic attachment to other filetypes, see |diffs.nvim-extra-filetypes|. @@ -1482,20 +1462,18 @@ Diff mode window highlights: ~ These are used for 'winhighlight' remapping in *DiffsDiffText* DiffsDiffText Background-only replacement for `DiffText`. -After diffs.nvim initializes, customize with |nvim_set_hl()| and -|ColorScheme|: >lua - local function set_highlights() - vim.api.nvim_set_hl(0, 'DiffsAdd', { bg = '#2e4a3a' }) - vim.api.nvim_set_hl(0, 'DiffsDiffDelete', { link = 'DiffDelete' }) - end - - vim.api.nvim_create_autocmd('ColorScheme', { - group = vim.api.nvim_create_augroup('MyDiffsHighlights', { clear = true }), + *DiffsHighlights* +diffs.nvim triggers `User DiffsHighlights` after each highlight update, including +initialization and |ColorScheme| changes. Register this autocmd before loading +diffs.nvim to apply your colors after each update: >lua + vim.api.nvim_create_autocmd('User', { + pattern = 'DiffsHighlights', + group = vim.api.nvim_create_augroup('my_diffs_highlights', { clear = true }), callback = function() - vim.schedule(set_highlights) + vim.api.nvim_set_hl(0, 'DiffsAdd', { bg = '#2e4a3a' }) + vim.api.nvim_set_hl(0, 'DiffsDiffDelete', { link = 'DiffDelete' }) end, }) - vim.schedule(set_highlights) < ============================================================================== @@ -1507,7 +1485,6 @@ Run `:checkhealth diffs` to check the required Neovim version (0.12.0+). ACKNOWLEDGEMENTS *diffs.nvim-acknowledgements* - vim-fugitive (https://github.com/tpope/vim-fugitive) -- codediff.nvim (https://github.com/esmuellert/codediff.nvim) - diffview.nvim (https://github.com/sindrets/diffview.nvim) - @phanen (https://github.com/phanen) - diff header highlighting, treesitter injection support, blame_hl.nvim (gitsigns blame popup diff --git a/lua/diffs/commands.lua b/lua/diffs/commands.lua index 66671be9..d114c974 100644 --- a/lua/diffs/commands.lua +++ b/lua/diffs/commands.lua @@ -2245,7 +2245,7 @@ function M.diff_file(filepath, opts) if diff_label == 'unmerged' then local conflict_config = runtime.get_conflict_config() if conflict_config then - require('diffs.merge').attach(diff_buf, conflict_config) + require('diffs.merge').attach(diff_buf) end end diff --git a/lua/diffs/config.lua b/lua/diffs/config.lua index 0ea8e5c5..a54f5ff7 100644 --- a/lua/diffs/config.lua +++ b/lua/diffs/config.lua @@ -9,7 +9,6 @@ local integration_metadata = require('diffs.integrations') ---@field max_lines integer ---@class diffs.IntraConfig ----@field algorithm string ---@field max_lines integer ---@class diffs.ViewConfig @@ -19,23 +18,10 @@ local integration_metadata = require('diffs.integrations') ---@class diffs.Highlights ---@field background boolean ---@field blend_alpha? number ----@field overrides? table ---@field warn_max_lines boolean ---@field treesitter diffs.TreesitterConfig ---@field vim diffs.VimConfig|false ----@field intra diffs.IntraConfig|false - ----@class diffs.ConflictKeymaps ----@field ours string|false ----@field theirs string|false ----@field both string|false ----@field none string|false ----@field next string|false ----@field prev string|false - ----@class diffs.ConflictConfig ----@field enabled? boolean Deprecated. ----@field keymaps diffs.ConflictKeymaps|false +---@field intra diffs.IntraConfig ---@class diffs.DifftasticConfig ---@field args? string[] @@ -45,17 +31,15 @@ local integration_metadata = require('diffs.integrations') ---@field neogit? boolean ---@field neojj? boolean ---@field gitsigns? boolean ----@field committia? boolean ---@field telescope? boolean ---@field difftastic? boolean|diffs.DifftasticConfig ---@class diffs.Config ---@field debug boolean|string ---@field view diffs.ViewConfig ----@field extra_filetypes string[] ---@field highlights diffs.Highlights ---@field integrations diffs.IntegrationsConfig ----@field conflict diffs.ConflictConfig|false +---@field conflict boolean ---@type diffs.Config local DEFAULTS = { @@ -64,7 +48,6 @@ local DEFAULTS = { default_layout = 'unified', prefix = true, }, - extra_filetypes = {}, highlights = { background = true, warn_max_lines = true, @@ -75,14 +58,11 @@ local DEFAULTS = { max_lines = 200, }, intra = { - algorithm = 'default', max_lines = 500, }, }, integrations = {}, - conflict = { - keymaps = false, - }, + conflict = true, } ---@param opts? table @@ -97,86 +77,9 @@ function M.new(opts) opts = vim.tbl_extend('force', opts or {}, { integrations = integration_metadata.normalize(opts and opts.integrations), }) - if opts.integrations.committia ~= nil then - vim.notify_once( - '[diffs]: integrations.committia is deprecated and ignored. Support ends on November 30, 2026. ' - .. 'Committia highlighting is automatic. See :help diffs.nvim-committia.', - vim.log.levels.WARN - ) - end - for group, keys in pairs({ - conflict = { 'disable_diagnostics', 'show_virtual_text', 'format_virtual_text', 'show_actions' }, - view = { 'change_bar', 'rail_separator' }, - }) do - if type(opts[group]) == 'table' then - for _, key in ipairs(keys) do - if opts[group][key] ~= nil then - vim.notify_once( - '[diffs]: ' - .. group - .. '.' - .. key - .. ' was removed and is ignored. Remove it from the configuration.', - vim.log.levels.WARN - ) - end - end - end - end - if opts.highlights and type(opts.highlights.intra) == 'boolean' then - vim.notify_once( - '[diffs]: Boolean highlights.intra is deprecated. Support ends on November 30, 2026. ' - .. 'See :help diffs.nvim-diffopt.', - vim.log.levels.WARN - ) - end - if opts.highlights and opts.highlights.context ~= nil then - vim.notify_once( - '[diffs]: highlights.context was removed and is ignored. Remove it from the configuration.', - vim.log.levels.WARN - ) - end local result = vim.tbl_deep_extend('force', DEFAULTS, opts) - for _, key in ipairs({ 'treesitter', 'vim', 'intra' }) do - local value = result.highlights[key] - if type(value) == 'table' and value.enabled ~= nil then - local migration = key == 'treesitter' - and 'The enabled field is ignored. Tree-sitter highlighting is always enabled. Remove enabled.' - or key == 'intra' and 'Remove enabled and use diffopt. See :help diffs.nvim-diffopt.' - or 'Use highlights.vim = false to disable Vim syntax. Otherwise remove enabled.' - vim.notify_once( - '[diffs]: highlights.' - .. key - .. '.enabled is deprecated. Support ends on November 30, 2026. ' - .. migration, - vim.log.levels.WARN - ) - if key ~= 'treesitter' and value.enabled == false then - result.highlights[key] = false - else - value.enabled = nil - end - end - end - if type(result.conflict) == 'table' and result.conflict.enabled ~= nil then - vim.notify_once( - '[diffs]: conflict.enabled is deprecated. Support ends on November 30, 2026. ' - .. 'Use conflict = false to disable conflict handling. Otherwise remove enabled.', - vim.log.levels.WARN - ) - if result.conflict.enabled == false then - result.conflict = false - else - result.conflict.enabled = nil - end - end - if result.conflict == true then - result.conflict = vim.deepcopy(DEFAULTS.conflict) - end - for _, key in ipairs({ 'vim', 'intra' }) do - if result.highlights[key] == true then - result.highlights[key] = vim.deepcopy(DEFAULTS.highlights[key]) - end + if result.highlights.vim == true then + result.highlights.vim = vim.deepcopy(DEFAULTS.highlights.vim) end return result end diff --git a/lua/diffs/conflict.lua b/lua/diffs/conflict.lua index 82961638..c93f54e8 100644 --- a/lua/diffs/conflict.lua +++ b/lua/diffs/conflict.lua @@ -13,7 +13,6 @@ local M = {} -local keymaps = require('diffs.keymaps') local notify = require('diffs.log').notify local ns = vim.api.nvim_create_namespace('diffs-conflict') @@ -22,9 +21,6 @@ local CONFLICT_PRIORITY = 200 ---@type table local attached_buffers = {} ----@type table> -local buffer_keymaps = {} - ---@param event string ---@param bufnr integer local function emit(event, bufnr) @@ -155,8 +151,6 @@ local function parse_buffer(bufnr) return M.parse(lines) end -local setup_keymaps - ---@param bufnr integer ---@param row integer ---@param hl_group string @@ -251,22 +245,17 @@ function M.replace_region(bufnr, region, replacement) end ---@param bufnr integer ----@param config diffs.ConflictConfig -function M.refresh(bufnr, config) +function M.refresh(bufnr) local had_conflicts = #vim.api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, { limit = 1 }) > 0 local regions = parse_buffer(bufnr) if #regions == 0 then vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1) - keymaps.clear_buffer_keymaps(buffer_keymaps, bufnr) if had_conflicts then emit('DiffsConflictResolved', bufnr) end return end apply_highlights(bufnr, regions) - if not buffer_keymaps[bufnr] then - setup_keymaps(bufnr, config) - end if not had_conflicts then emit('DiffsConflictDetected', bufnr) end @@ -294,9 +283,8 @@ function M.replacement_lines(bufnr, region, side) end ---@param bufnr integer ----@param config diffs.ConflictConfig ---@param side 'ours'|'theirs'|'both'|'none' -local function resolve(bufnr, config, side) +local function resolve(bufnr, side) if not vim.api.nvim_get_option_value('modifiable', { buf = bufnr }) then notify('buffer is not modifiable', vim.log.levels.WARN) return @@ -307,31 +295,27 @@ local function resolve(bufnr, config, side) return end M.replace_region(bufnr, region, M.replacement_lines(bufnr, region, side)) - M.refresh(bufnr, config) + M.refresh(bufnr) end ---@param bufnr integer ----@param config diffs.ConflictConfig -function M.resolve_ours(bufnr, config) - resolve(bufnr, config, 'ours') +function M.resolve_ours(bufnr) + resolve(bufnr, 'ours') end ---@param bufnr integer ----@param config diffs.ConflictConfig -function M.resolve_theirs(bufnr, config) - resolve(bufnr, config, 'theirs') +function M.resolve_theirs(bufnr) + resolve(bufnr, 'theirs') end ---@param bufnr integer ----@param config diffs.ConflictConfig -function M.resolve_both(bufnr, config) - resolve(bufnr, config, 'both') +function M.resolve_both(bufnr) + resolve(bufnr, 'both') end ---@param bufnr integer ----@param config diffs.ConflictConfig -function M.resolve_none(bufnr, config) - resolve(bufnr, config, 'none') +function M.resolve_none(bufnr) + resolve(bufnr, 'none') end ---@param bufnr integer @@ -373,30 +357,10 @@ function M.goto_prev(bufnr) goto_conflict(bufnr, false) end ----@param bufnr integer ----@param config diffs.ConflictConfig -setup_keymaps = function(bufnr, config) - local km = config.keymaps - if km == false then - keymaps.clear_buffer_keymaps(buffer_keymaps, bufnr) - return - end - - keymaps.set_buffer_keymaps(buffer_keymaps, bufnr, { - { km.ours, '(diffs-conflict-ours)' }, - { km.theirs, '(diffs-conflict-theirs)' }, - { km.both, '(diffs-conflict-both)' }, - { km.none, '(diffs-conflict-none)' }, - { km.next, '(diffs-conflict-next)' }, - { km.prev, '(diffs-conflict-prev)' }, - }) -end - ---@param bufnr integer function M.detach(bufnr) local attached = attached_buffers[bufnr] vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1) - keymaps.clear_buffer_keymaps(buffer_keymaps, bufnr) attached_buffers[bufnr] = nil if attached then @@ -405,8 +369,7 @@ function M.detach(bufnr) end ---@param bufnr integer ----@param config diffs.ConflictConfig -function M.attach(bufnr, config) +function M.attach(bufnr) if attached_buffers[bufnr] then return end @@ -425,7 +388,6 @@ function M.attach(bufnr, config) attached_buffers[bufnr] = true apply_highlights(bufnr, regions) - setup_keymaps(bufnr, config) vim.api.nvim_create_autocmd({ 'TextChanged', 'TextChangedI' }, { buffer = bufnr, @@ -433,14 +395,13 @@ function M.attach(bufnr, config) if not attached_buffers[bufnr] then return true end - M.refresh(bufnr, config) + M.refresh(bufnr) end, }) vim.api.nvim_create_autocmd('BufWipeout', { buffer = bufnr, callback = function() - keymaps.clear_buffer_keymaps(buffer_keymaps, bufnr) attached_buffers[bufnr] = nil end, }) diff --git a/lua/diffs/diff.lua b/lua/diffs/diff.lua index b985597d..5c7ff644 100644 --- a/lua/diffs/diff.lua +++ b/lua/diffs/diff.lua @@ -14,11 +14,8 @@ local M = {} local dbg = require('diffs.log').dbg -local notify = require('diffs.log').notify local diffopt = require('diffs.diffopt') -local warned_vscode_whitespace = false - ---@param hunk_lines string[] ---@return diffs.ChangeGroup[] function M.extract_change_groups(hunk_lines) @@ -380,90 +377,9 @@ local function diff_group_native(group, diff_opts) return all_del, all_add end ----@param group diffs.ChangeGroup ----@param handle table ----@param diff_opts? diffs.DiffOpts ----@return diffs.CharSpan[], diffs.CharSpan[] -local function diff_group_vscode(group, handle, diff_opts) - ---@type diffs.CharSpan[] - local all_del = {} - ---@type diffs.CharSpan[] - local all_add = {} - - local ffi = require('ffi') - - local old_texts = {} - for _, l in ipairs(group.del_lines) do - table.insert(old_texts, l.text) - end - local new_texts = {} - for _, l in ipairs(group.add_lines) do - table.insert(new_texts, l.text) - end - - local orig_arr = ffi.new('const char*[?]', #old_texts) - for i, t in ipairs(old_texts) do - orig_arr[i - 1] = t - end - - local mod_arr = ffi.new('const char*[?]', #new_texts) - for i, t in ipairs(new_texts) do - mod_arr[i - 1] = t - end - - local ignore_trim = false - if diff_opts then - ignore_trim = diff_opts.ignore_whitespace == true - or diff_opts.ignore_whitespace_change == true - or diff_opts.ignore_whitespace_change_at_eol == true - end - - local opts = ffi.new('DiffsDiffOptions', { - ignore_trim_whitespace = ignore_trim, - max_computation_time_ms = 1000, - compute_moves = false, - extend_to_subwords = false, - }) - - local result = handle.compute_diff(orig_arr, #old_texts, mod_arr, #new_texts, opts) - if result == nil then - return all_del, all_add - end - - for ci = 0, result.changes.count - 1 do - local mapping = result.changes.mappings[ci] - for ii = 0, mapping.inner_change_count - 1 do - local inner = mapping.inner_changes[ii] - - local orig_line = inner.original.start_line - if group.del_lines[orig_line] then - table.insert(all_del, { - line = group.del_lines[orig_line].idx, - col_start = inner.original.start_col, - col_end = inner.original.end_col, - }) - end - - local mod_line = inner.modified.start_line - if group.add_lines[mod_line] then - table.insert(all_add, { - line = group.add_lines[mod_line].idx, - col_start = inner.modified.start_col, - col_end = inner.modified.end_col, - }) - end - end - end - - handle.free_lines_diff(result) - - return all_del, all_add -end - ---@param hunk_lines string[] ----@param algorithm? string ---@return diffs.IntraChanges? -function M.compute_intra_hunks(hunk_lines, algorithm) +function M.compute_intra_hunks(hunk_lines) local inline = diffopt.inline() if inline == 'none' then dbg('intra skipped: diffopt inline:none') @@ -475,16 +391,6 @@ function M.compute_intra_hunks(hunk_lines, algorithm) return nil end - algorithm = algorithm or 'default' - - local vscode_handle = nil - if algorithm == 'vscode' then - vscode_handle = require('diffs.lib').load() - if not vscode_handle then - dbg('vscode algorithm requested but library not available, falling back to default') - end - end - local diff_opts = diffopt.resolve() if diff_opts.algorithm then dbg('diffopt algorithm: %s', diff_opts.algorithm) @@ -493,36 +399,16 @@ function M.compute_intra_hunks(hunk_lines, algorithm) dbg('diffopt linematch: %d', diff_opts.linematch) end - if vscode_handle and diff_opts.ignore_whitespace and not warned_vscode_whitespace then - warned_vscode_whitespace = true - notify( - 'the vscode intra-line algorithm ignores only leading/trailing whitespace; ' - .. 'internal whitespace differences are still highlighted. Set ' - .. 'highlights.intra.algorithm = "default" for full whitespace handling.', - vim.log.levels.WARN - ) - end - ---@type diffs.CharSpan[] local all_add = {} ---@type diffs.CharSpan[] local all_del = {} - dbg( - 'intra: %d change groups, algorithm=%s, vscode=%s', - #groups, - algorithm, - vscode_handle and 'yes' or 'no' - ) + dbg('intra: %d change groups', #groups) for gi, group in ipairs(groups) do dbg('group %d: %d del lines, %d add lines', gi, #group.del_lines, #group.add_lines) - local ds, as - if vscode_handle then - ds, as = diff_group_vscode(group, vscode_handle, diff_opts) - else - ds, as = diff_group_native(group, diff_opts) - end + local ds, as = diff_group_native(group, diff_opts) dbg('group %d result: %d del spans, %d add spans', gi, #ds, #as) for _, s in ipairs(ds) do dbg(' del span: line=%d col=%d..%d', s.line, s.col_start, s.col_end) diff --git a/lua/diffs/difftastic.lua b/lua/diffs/difftastic.lua index fb238ace..0b912a2a 100644 --- a/lua/diffs/difftastic.lua +++ b/lua/diffs/difftastic.lua @@ -341,14 +341,13 @@ end ---@return integer applied span count function M.apply_unified(bufnr, lhs, rhs, diff_lines, spec, rail_width) local opts = runtime.get_highlight_opts() - local intra_cfg = opts.highlights.intra local priority = opts.highlights.priorities.char_bg local base = rail_width + 1 vim.api.nvim_buf_clear_namespace(bufnr, unified_ns, 0, -1) M.mark_active(bufnr) - if not intra_cfg or diffopt.inline() == 'none' then + if diffopt.inline() == 'none' then return 0 end diff --git a/lua/diffs/highlight.lua b/lua/diffs/highlight.lua index cc9d9df3..9723c2d7 100644 --- a/lua/diffs/highlight.lua +++ b/lua/diffs/highlight.lua @@ -37,6 +37,7 @@ local vim_syntax_cache_limit = 128 ---@class diffs.HunkHighlights: diffs.Highlights ---@field treesitter diffs.TreesitterConfig|false +---@field intra diffs.IntraConfig|false ---@field priorities diffs.HighlightPriorities ---@type diffs.HighlightPriorities @@ -631,7 +632,7 @@ function M.highlight_hunk(bufnr, ns, hunk, opts) and (hunk._hl_line_count or #hunk.lines) <= intra_cfg.max_lines then dbg('computing intra for hunk %s:%d (%d lines)', hunk.filename, hunk.start_line, #hunk.lines) - intra = diff.compute_intra_hunks(hunk.lines, intra_cfg.algorithm) + intra = diff.compute_intra_hunks(hunk.lines) if intra then dbg('intra result: %d add spans, %d del spans', #intra.add_spans, #intra.del_spans) else diff --git a/lua/diffs/integrations.lua b/lua/diffs/integrations.lua index 421a25b7..7aab049d 100644 --- a/lua/diffs/integrations.lua +++ b/lua/diffs/integrations.lua @@ -48,11 +48,6 @@ function M.filetypes(opts) end end end - if type(opts.extra_filetypes) == 'table' then - for _, ft in ipairs(opts.extra_filetypes) do - table.insert(fts, ft) - end - end return fts end diff --git a/lua/diffs/lib.lua b/lua/diffs/lib.lua deleted file mode 100644 index ce207dd1..00000000 --- a/lua/diffs/lib.lua +++ /dev/null @@ -1,135 +0,0 @@ -local M = {} - -local log = require('diffs.log') - -local dbg = log.dbg - ----@type table? -local cached_handle = nil - ----@return string -local function get_ext() - local os_name = jit.os:lower() - if os_name == 'windows' then - return 'dll' - elseif os_name == 'osx' then - return 'dylib' - end - return 'so' -end - ----@return string -local function lib_dir() - return vim.fn.stdpath('data') .. '/diffs/lib' -end - ----@return string -local function lib_path() - return lib_dir() .. '/libvscode_diff.' .. get_ext() -end - ----@return boolean -function M.has_lib() - if cached_handle then - return true - end - return vim.fn.filereadable(lib_path()) == 1 -end - ----@return string -function M.lib_path() - return lib_path() -end - ----@return table? -function M.load() - if cached_handle then - return cached_handle - end - - local path = lib_path() - if vim.fn.filereadable(path) ~= 1 then - return nil - end - - local ffi = require('ffi') - - ffi.cdef([[ - typedef struct { - int start_line; - int end_line; - } DiffsLineRange; - - typedef struct { - int start_line; - int start_col; - int end_line; - int end_col; - } DiffsCharRange; - - typedef struct { - DiffsCharRange original; - DiffsCharRange modified; - } DiffsRangeMapping; - - typedef struct { - DiffsLineRange original; - DiffsLineRange modified; - DiffsRangeMapping* inner_changes; - int inner_change_count; - } DiffsDetailedMapping; - - typedef struct { - DiffsDetailedMapping* mappings; - int count; - int capacity; - } DiffsDetailedMappingArray; - - typedef struct { - DiffsLineRange original; - DiffsLineRange modified; - } DiffsMovedText; - - typedef struct { - DiffsMovedText* moves; - int count; - int capacity; - } DiffsMovedTextArray; - - typedef struct { - DiffsDetailedMappingArray changes; - DiffsMovedTextArray moves; - bool hit_timeout; - } DiffsLinesDiff; - - typedef struct { - bool ignore_trim_whitespace; - int max_computation_time_ms; - bool compute_moves; - bool extend_to_subwords; - } DiffsDiffOptions; - - DiffsLinesDiff* compute_diff( - const char** original_lines, - int original_count, - const char** modified_lines, - int modified_count, - const DiffsDiffOptions* options - ); - - void free_lines_diff(DiffsLinesDiff* diff); - - const char* get_version(void); - ]]) - - local ok, handle = pcall(ffi.load, path) - if not ok then - dbg('failed to load libvscode_diff: %s', handle) - return nil - end - - cached_handle = handle - return handle -end - -return M diff --git a/lua/diffs/merge.lua b/lua/diffs/merge.lua index 18fe712d..d61f1c4e 100644 --- a/lua/diffs/merge.lua +++ b/lua/diffs/merge.lua @@ -1,16 +1,12 @@ local M = {} local conflict = require('diffs.conflict') -local keymaps = require('diffs.keymaps') local notify = require('diffs.log').notify local rails = require('diffs.rails') ---@type table> local resolved_hunks = {} ----@type table> -local buffer_keymaps = {} - ---@class diffs.MergeHunkInfo ---@field index integer ---@field start_line integer @@ -146,9 +142,8 @@ function M.is_resolved(diff_bufnr, hunk_index) end ---@param diff_bufnr integer ----@param config diffs.ConflictConfig ---@param side 'ours'|'theirs'|'both'|'none' -local function resolve(diff_bufnr, config, side) +local function resolve(diff_bufnr, side) local hunk = M.find_hunk_at_cursor(diff_bufnr) if not hunk then return @@ -171,32 +166,28 @@ local function resolve(diff_bufnr, config, side) region, conflict.replacement_lines(working_bufnr, region, side) ) - conflict.refresh(working_bufnr, config) + conflict.refresh(working_bufnr) mark_resolved(diff_bufnr, hunk.index) end ---@param bufnr integer ----@param config diffs.ConflictConfig -function M.resolve_ours(bufnr, config) - resolve(bufnr, config, 'ours') +function M.resolve_ours(bufnr) + resolve(bufnr, 'ours') end ---@param bufnr integer ----@param config diffs.ConflictConfig -function M.resolve_theirs(bufnr, config) - resolve(bufnr, config, 'theirs') +function M.resolve_theirs(bufnr) + resolve(bufnr, 'theirs') end ---@param bufnr integer ----@param config diffs.ConflictConfig -function M.resolve_both(bufnr, config) - resolve(bufnr, config, 'both') +function M.resolve_both(bufnr) + resolve(bufnr, 'both') end ---@param bufnr integer ----@param config diffs.ConflictConfig -function M.resolve_none(bufnr, config) - resolve(bufnr, config, 'none') +function M.resolve_none(bufnr) + resolve(bufnr, 'none') end ---@param bufnr integer @@ -257,28 +248,12 @@ function M.goto_prev(bufnr) end ---@param bufnr integer ----@param config diffs.ConflictConfig -function M.attach(bufnr, config) +function M.attach(bufnr) resolved_hunks[bufnr] = nil - local km = config.keymaps - if km ~= false then - keymaps.set_buffer_keymaps(buffer_keymaps, bufnr, { - { km.ours, '(diffs-merge-ours)' }, - { km.theirs, '(diffs-merge-theirs)' }, - { km.both, '(diffs-merge-both)' }, - { km.none, '(diffs-merge-none)' }, - { km.next, '(diffs-merge-next)' }, - { km.prev, '(diffs-merge-prev)' }, - }) - else - keymaps.clear_buffer_keymaps(buffer_keymaps, bufnr) - end - vim.api.nvim_create_autocmd('BufWipeout', { buffer = bufnr, callback = function() - keymaps.clear_buffer_keymaps(buffer_keymaps, bufnr) resolved_hunks[bufnr] = nil end, }) diff --git a/lua/diffs/runtime/highlight_groups.lua b/lua/diffs/runtime/highlight_groups.lua index 77d6e935..eb9f66c2 100644 --- a/lua/diffs/runtime/highlight_groups.lua +++ b/lua/diffs/runtime/highlight_groups.lua @@ -152,11 +152,7 @@ function M.apply(config, is_default) vim.api.nvim_set_hl(0, 'NeogitDiffDeleteInline', {}) end - if config.highlights.overrides then - for group, hl in pairs(config.highlights.overrides) do - vim.api.nvim_set_hl(0, group, hl) - end - end + vim.api.nvim_exec_autocmds('User', { pattern = 'DiffsHighlights', modeline = false }) return { transparent = transparent } end diff --git a/lua/diffs/runtime/init.lua b/lua/diffs/runtime/init.lua index 878684a8..f3f51b52 100644 --- a/lua/diffs/runtime/init.lua +++ b/lua/diffs/runtime/init.lua @@ -64,30 +64,6 @@ local function init() end log.set_enabled(config.debug) - if config.highlights.overrides and next(config.highlights.overrides) then - log.notify( - 'highlights.overrides is deprecated. Support ends on November 30, 2026. ' - .. 'Use vim.api.nvim_set_hl(). See :help diffs.nvim-highlights.', - vim.log.levels.WARN - ) - end - - if config.highlights.intra and config.highlights.intra.algorithm == 'vscode' then - log.notify( - 'libvscodediff support will be removed on 30 November 2026. ' - .. "Remove highlights.intra.algorithm to use Neovim's diff.", - vim.log.levels.WARN - ) - end - - if config.conflict and config.conflict.keymaps then - log.notify( - 'conflict.keymaps will be removed on 30 November 2026. ' - .. 'Use vim.keymap.set(). See :help diffs.nvim-conflict-keymaps.', - vim.log.levels.WARN - ) - end - fast_hl_opts = highlight.hunk_opts(config, { highlights = { treesitter = false, @@ -189,7 +165,7 @@ function M.get_fugitive_config() return config.integrations.fugitive == true end ----@return diffs.ConflictConfig|false +---@return boolean function M.get_conflict_config() init() return config.conflict diff --git a/lua/diffs/split.lua b/lua/diffs/split.lua index ea0dd924..e90de1a5 100644 --- a/lua/diffs/split.lua +++ b/lua/diffs/split.lua @@ -245,8 +245,7 @@ end ---@param info diffs.SplitPaneInfo local function set_split_intra_difft(bufnr, info) local opts = require('diffs.runtime').get_highlight_opts() - local intra_cfg = opts.highlights.intra - if not intra_cfg or diffopt.inline() == 'none' then + if diffopt.inline() == 'none' then return end local cfg = side_config[info.side] @@ -279,7 +278,7 @@ local function set_split_intra(bufnr, info, hunks) local opts = require('diffs.runtime').get_highlight_opts() local intra_cfg = opts.highlights.intra - if not intra_cfg or diffopt.inline() == 'none' then + if diffopt.inline() == 'none' then return end @@ -309,7 +308,7 @@ local function set_split_intra(bufnr, info, hunks) end if #texts > 0 and #texts <= intra_cfg.max_lines then - local intra = diff.compute_intra_hunks(texts, intra_cfg.algorithm) + local intra = diff.compute_intra_hunks(texts) local spans = intra and intra[cfg.spans] or {} for _, span in ipairs(spans) do local ref = refs[span.line] diff --git a/plugin/diffs.lua b/plugin/diffs.lua index a8e4395c..e9d907e5 100644 --- a/plugin/diffs.lua +++ b/plugin/diffs.lua @@ -8,16 +8,6 @@ local user_config = config.new(vim.deepcopy(vim.g.diffs or {})) vim.g.loaded_diffs = 1 -if #user_config.extra_filetypes > 0 then - vim.schedule(function() - require('diffs.log').notify( - 'extra_filetypes is deprecated. Support ends on November 30, 2026. ' - .. 'Use the FileType autocmd recipe: :help diffs.nvim-extra-filetypes', - vim.log.levels.WARN - ) - end) -end - local function get_runtime() local runtime = require('diffs.runtime') runtime.configure(user_config) @@ -105,7 +95,7 @@ vim.api.nvim_create_autocmd('BufReadPost', { local runtime = get_runtime() local conflict_config = runtime.get_conflict_config() if conflict_config then - require('diffs.conflict').attach(args.buf, conflict_config) + require('diffs.conflict').attach(args.buf) end end, }) @@ -174,7 +164,7 @@ local function conflict_action(fn) local runtime = get_runtime() local conflict_config = runtime.get_conflict_config() if conflict_config then - fn(bufnr, conflict_config) + fn(bufnr) end end diff --git a/spec/commands_spec.lua b/spec/commands_spec.lua index 409a7b6d..d86890ea 100644 --- a/spec/commands_spec.lua +++ b/spec/commands_spec.lua @@ -12,7 +12,6 @@ local saved_git = {} local saved_runtime_attach local saved_runtime_get_conflict_config local saved_runtime_get_view_config -local saved_runtime_get_highlight_opts local saved_schedule local saved_systemlist local saved_jobstart @@ -84,16 +83,6 @@ local function mock_view_config(config) end end -local function mock_highlight_opts(mutate) - saved_runtime_get_highlight_opts = runtime.get_highlight_opts - local base = saved_runtime_get_highlight_opts() - runtime.get_highlight_opts = function() - local opts = vim.deepcopy(base) - mutate(opts) - return opts - end -end - local function capture_notifications() local notifications = {} saved_notify = vim.notify @@ -405,10 +394,6 @@ local function restore_mocks() runtime.get_view_config = saved_runtime_get_view_config saved_runtime_get_view_config = nil end - if saved_runtime_get_highlight_opts then - runtime.get_highlight_opts = saved_runtime_get_highlight_opts - saved_runtime_get_highlight_opts = nil - end if saved_schedule then vim.schedule = saved_schedule saved_schedule = nil @@ -1197,28 +1182,6 @@ describe('commands', function() ) end) - it('skips the intra overlay when highlights.intra is disabled', function() - mock_view_config({ prefix = true }) - mock_highlight_opts(function(opts) - opts.highlights.intra = false - end) - create_split_source({ - index_lines = { 'function f()', ' return 111', ' log()', 'end' }, - worktree_lines = { 'function f()', ' return 222', ' log()', 'end' }, - }) - commands.diff('++layout=split', false) - - local right_buf = vim.api.nvim_get_current_buf() - local left_buf = vim.api.nvim_buf_get_var(right_buf, 'diffs_split_peer') - table.insert(test_buffers, left_buf) - table.insert(test_buffers, right_buf) - - local intra_ns = vim.api.nvim_get_namespaces().diffs_split_intra - assert.is_not_nil(intra_ns) - assert.are.equal(0, #vim.api.nvim_buf_get_extmarks(left_buf, intra_ns, 0, -1, {})) - assert.are.equal(0, #vim.api.nvim_buf_get_extmarks(right_buf, intra_ns, 0, -1, {})) - end) - it('leaves split panes untouched when attach_diff re-runs', function() mock_view_config({ prefix = true }) create_split_source() @@ -2177,9 +2140,7 @@ describe('commands', function() local source_buf = edit_file(filepath) local source_win = vim.api.nvim_get_current_win() mock_runtime_attach(function() end) - mock_conflict_config({ - keymaps = helpers.default_conflict_keymaps(), - }) + mock_conflict_config(true) assert.is_true(git.is_unmerged(filepath)) @@ -2210,8 +2171,8 @@ describe('commands', function() assert.is_true(text:find('--- /dev/null', 1, true) == nil) assert.is_true(text:find('new file mode', 1, true) == nil) assert.is_true(text:find('<<<<<<<', 1, true) == nil) - assert.is_true(helpers.has_keymap(bufnr, 'go')) - assert.is_true(helpers.has_keymap(bufnr, 'gt')) + assert.is_false(helpers.has_keymap(bufnr, 'go')) + assert.is_false(helpers.has_keymap(bufnr, 'gt')) if expected_rail_style then assert.are.equal(expected_rail_style, vim.api.nvim_buf_get_var(bufnr, 'diffs_rail_style')) end diff --git a/spec/config_spec.lua b/spec/config_spec.lua index 32601093..9512118d 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua @@ -2,7 +2,7 @@ require('spec.helpers') local config = require('diffs.config') describe('diffs.config', function() - local integration_keys = { 'fugitive', 'neogit', 'neojj', 'gitsigns', 'committia', 'telescope' } + local integration_keys = { 'fugitive', 'neogit', 'neojj', 'gitsigns', 'telescope' } describe('new', function() it('accepts nil config', function() @@ -22,7 +22,6 @@ describe('diffs.config', function() view = { prefix = true, }, - extra_filetypes = { 'diff' }, highlights = { background = true, blend_alpha = 0.4, @@ -30,7 +29,6 @@ describe('diffs.config', function() treesitter = { max_lines = 1000 }, vim = false, intra = { - algorithm = 'vscode', max_lines = 250, }, }, @@ -39,19 +37,9 @@ describe('diffs.config', function() neogit = true, neojj = true, gitsigns = true, - committia = true, telescope = true, }, - conflict = { - keymaps = { - ours = 'co', - theirs = 'ct', - both = 'cb', - none = 'c0', - next = ']x', - prev = '[x', - }, - }, + conflict = false, }) end) end) @@ -72,7 +60,7 @@ describe('diffs.config', function() end) it('accepts boolean and table highlight settings', function() - for _, key in ipairs({ 'vim', 'intra' }) do + for _, key in ipairs({ 'vim' }) do local defaults = config.new().highlights[key] for _, value in ipairs({ true, {} }) do assert.are.same(defaults, config.new({ highlights = { [key] = value } }).highlights[key]) @@ -91,16 +79,10 @@ describe('diffs.config', function() assert.is_nil(opts.hide_prefix) end) - it('accepts boolean and table conflict settings', function() - local defaults = config.new().conflict - for _, value in ipairs({ true, {} }) do - assert.are.same(defaults, config.new({ conflict = value }).conflict) - end + it('accepts boolean conflict settings', function() + assert.is_true(config.new().conflict) + assert.is_true(config.new({ conflict = true }).conflict) assert.is_false(config.new({ conflict = false }).conflict) - assert.are.same( - vim.tbl_extend('force', defaults, { keymaps = { ours = 'co' } }), - config.new({ conflict = { keymaps = { ours = 'co' } } }).conflict - ) end) it('accepts integration lists and boolean maps', function() @@ -147,21 +129,5 @@ describe('diffs.config', function() local fts = compute({ integrations = { neogit = false } }) assert.is_false(vim.tbl_contains(fts, 'NeogitStatus')) end) - - it('includes extra_filetypes', function() - local fts = compute({ extra_filetypes = { 'diff' } }) - assert.is_true(vim.tbl_contains(fts, 'diff')) - end) - - it('combines integrations and extra_filetypes', function() - local fts = compute({ - integrations = { fugitive = true, neogit = true }, - extra_filetypes = { 'diff' }, - }) - assert.is_true(vim.tbl_contains(fts, 'git')) - assert.is_true(vim.tbl_contains(fts, 'fugitive')) - assert.is_true(vim.tbl_contains(fts, 'NeogitStatus')) - assert.is_true(vim.tbl_contains(fts, 'diff')) - end) end) end) diff --git a/spec/conflict_spec.lua b/spec/conflict_spec.lua index 7f0a5c30..2a2733d2 100644 --- a/spec/conflict_spec.lua +++ b/spec/conflict_spec.lua @@ -1,16 +1,6 @@ local conflict = require('diffs.conflict') local helpers = require('spec.helpers') -local function default_config(overrides) - local cfg = { - keymaps = false, - } - if overrides then - cfg = vim.tbl_deep_extend('force', cfg, overrides) - end - return cfg -end - local function create_file_buffer(lines) local bufnr = vim.api.nvim_create_buf(false, false) vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines or {}) @@ -180,7 +170,7 @@ describe('conflict', function() '>>>>>>> feature', }) - conflict.attach(bufnr, default_config()) + conflict.attach(bufnr) local extmarks = get_extmarks(bufnr) assert.is_true(#extmarks > 0) @@ -216,7 +206,7 @@ describe('conflict', function() '>>>>>>> feature', }) - conflict.attach(bufnr, default_config()) + conflict.attach(bufnr) local checked = 0 for _, mark in ipairs(get_extmarks(bufnr)) do @@ -240,7 +230,7 @@ describe('conflict', function() '>>>>>>> feature', }) - conflict.attach(bufnr, default_config()) + conflict.attach(bufnr) local extmarks = get_extmarks(bufnr) local has_ours_nr = false @@ -271,7 +261,7 @@ describe('conflict', function() '>>>>>>> feature', }) - conflict.attach(bufnr, default_config()) + conflict.attach(bufnr) local extmarks = get_extmarks(bufnr) local has_base = false @@ -295,7 +285,7 @@ describe('conflict', function() '>>>>>>> feature', }) - conflict.attach(bufnr, default_config()) + conflict.attach(bufnr) assert.is_true(#get_extmarks(bufnr) > 0) conflict.detach(bufnr) @@ -305,147 +295,6 @@ describe('conflict', function() end) end) - describe('keymaps', function() - it('does not set buffer-local keymaps when disabled', function() - local bufnr = create_file_buffer({ - '<<<<<<< HEAD', - 'local x = 1', - '=======', - 'local x = 2', - '>>>>>>> feature', - }) - - conflict.attach(bufnr, default_config()) - - assert.is_false(helpers.has_keymap(bufnr, 'gt')) - - helpers.delete_buffer(bufnr) - end) - - it('removes buffer-local keymaps on detach', function() - local bufnr = create_file_buffer({ - '<<<<<<< HEAD', - 'local x = 1', - '=======', - 'local x = 2', - '>>>>>>> feature', - }) - local cfg = default_config({ keymaps = helpers.default_conflict_keymaps() }) - - conflict.attach(bufnr, cfg) - - assert.is_true(helpers.has_keymap(bufnr, 'gt')) - - conflict.detach(bufnr) - - assert.is_false(helpers.has_keymap(bufnr, 'gt')) - - helpers.delete_buffer(bufnr) - end) - - it('removes buffer-local keymaps when all conflicts are resolved', function() - local bufnr = create_file_buffer({ - '<<<<<<< HEAD', - 'local x = 1', - '=======', - 'local x = 2', - '>>>>>>> feature', - }) - local cfg = default_config({ keymaps = helpers.default_conflict_keymaps() }) - - conflict.attach(bufnr, cfg) - - assert.is_true(helpers.has_keymap(bufnr, 'gt')) - - vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { 'local x = 2' }) - conflict.refresh(bufnr, cfg) - - assert.is_false(helpers.has_keymap(bufnr, 'gt')) - - helpers.delete_buffer(bufnr) - end) - - it('reinstalls buffer-local keymaps when conflicts return', function() - local bufnr = create_file_buffer({ - '<<<<<<< HEAD', - 'local x = 1', - '=======', - 'local x = 2', - '>>>>>>> feature', - }) - local cfg = default_config({ keymaps = helpers.default_conflict_keymaps() }) - - conflict.attach(bufnr, cfg) - - vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { 'local x = 2' }) - conflict.refresh(bufnr, cfg) - assert.is_false(helpers.has_keymap(bufnr, 'gt')) - - vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { - '<<<<<<< HEAD', - 'local x = 1', - '=======', - 'local x = 2', - '>>>>>>> feature', - }) - conflict.refresh(bufnr, cfg) - - assert.is_true(helpers.has_keymap(bufnr, 'gt')) - - helpers.delete_buffer(bufnr) - end) - - it('does not replace pre-existing buffer-local keymaps', function() - local bufnr = create_file_buffer({ - '<<<<<<< HEAD', - 'local x = 1', - '=======', - 'local x = 2', - '>>>>>>> feature', - }) - vim.keymap.set('n', 'gt', '', { buffer = bufnr, desc = 'user theirs' }) - local cfg = default_config({ keymaps = helpers.default_conflict_keymaps() }) - - conflict.attach(bufnr, cfg) - - local theirs = helpers.get_keymap(bufnr, 'gt') - local ours = helpers.get_keymap(bufnr, 'go') - assert.are.equal('user theirs', theirs.desc) - assert.are.equal('(diffs-conflict-ours)', ours.rhs) - - conflict.detach(bufnr) - - theirs = helpers.get_keymap(bufnr, 'gt') - assert.are.equal('user theirs', theirs.desc) - assert.is_false(helpers.has_keymap(bufnr, 'go')) - - helpers.delete_buffer(bufnr) - end) - - it('does not remove a user replacement during cleanup', function() - local bufnr = create_file_buffer({ - '<<<<<<< HEAD', - 'local x = 1', - '=======', - 'local x = 2', - '>>>>>>> feature', - }) - local cfg = default_config({ keymaps = helpers.default_conflict_keymaps() }) - - conflict.attach(bufnr, cfg) - assert.are.equal('(diffs-conflict-ours)', helpers.get_keymap(bufnr, 'go').rhs) - - vim.keymap.set('n', 'go', '', { buffer = bufnr, desc = 'user ours' }) - conflict.detach(bufnr) - - local ours = helpers.get_keymap(bufnr, 'go') - assert.are.equal('user ours', ours.desc) - assert.is_false(helpers.has_keymap(bufnr, 'gt')) - - helpers.delete_buffer(bufnr) - end) - end) - describe('resolution', function() local function make_conflict_buffer() local bufnr = create_file_buffer({ @@ -463,7 +312,7 @@ describe('conflict', function() local bufnr = make_conflict_buffer() vim.api.nvim_win_set_cursor(0, { 2, 0 }) - conflict.resolve_ours(bufnr, default_config()) + conflict.resolve_ours(bufnr) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) assert.are.equal(1, #lines) @@ -476,7 +325,7 @@ describe('conflict', function() local bufnr = make_conflict_buffer() vim.api.nvim_win_set_cursor(0, { 2, 0 }) - conflict.resolve_theirs(bufnr, default_config()) + conflict.resolve_theirs(bufnr) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) assert.are.equal(1, #lines) @@ -489,7 +338,7 @@ describe('conflict', function() local bufnr = make_conflict_buffer() vim.api.nvim_win_set_cursor(0, { 2, 0 }) - conflict.resolve_both(bufnr, default_config()) + conflict.resolve_both(bufnr) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) assert.are.equal(2, #lines) @@ -503,7 +352,7 @@ describe('conflict', function() local bufnr = make_conflict_buffer() vim.api.nvim_win_set_cursor(0, { 2, 0 }) - conflict.resolve_none(bufnr, default_config()) + conflict.resolve_none(bufnr) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) assert.are.equal(1, #lines) @@ -524,7 +373,7 @@ describe('conflict', function() vim.api.nvim_set_current_buf(bufnr) vim.api.nvim_win_set_cursor(0, { 1, 0 }) - conflict.resolve_ours(bufnr, default_config()) + conflict.resolve_ours(bufnr) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) assert.are.equal(6, #lines) @@ -549,7 +398,7 @@ describe('conflict', function() vim.api.nvim_set_current_buf(bufnr) vim.api.nvim_win_set_cursor(0, { 2, 0 }) - conflict.resolve_ours(bufnr, default_config()) + conflict.resolve_ours(bufnr) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) assert.are.equal('a', lines[1]) @@ -569,7 +418,7 @@ describe('conflict', function() vim.api.nvim_set_current_buf(bufnr) vim.api.nvim_win_set_cursor(0, { 1, 0 }) - conflict.resolve_ours(bufnr, default_config()) + conflict.resolve_ours(bufnr) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) assert.are.equal(1, #lines) @@ -591,7 +440,7 @@ describe('conflict', function() vim.api.nvim_set_current_buf(bufnr) vim.api.nvim_win_set_cursor(0, { 2, 0 }) - conflict.resolve_theirs(bufnr, default_config()) + conflict.resolve_theirs(bufnr) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) assert.are.equal(1, #lines) @@ -765,10 +614,9 @@ describe('conflict', function() 'b', '>>>>>>> feat', }) - local cfg = default_config() - conflict.attach(bufnr, cfg) + conflict.attach(bufnr) local count1 = #get_extmarks(bufnr) - conflict.attach(bufnr, cfg) + conflict.attach(bufnr) local count2 = #get_extmarks(bufnr) assert.are.equal(count1, count2) conflict.detach(bufnr) @@ -785,7 +633,7 @@ describe('conflict', function() }) vim.api.nvim_set_option_value('buftype', 'nofile', { buf = bufnr }) - conflict.attach(bufnr, default_config()) + conflict.attach(bufnr) assert.are.equal(0, #get_extmarks(bufnr)) helpers.delete_buffer(bufnr) @@ -794,7 +642,7 @@ describe('conflict', function() it('skips buffers without conflict markers', function() local bufnr = create_file_buffer({ 'local x = 1', 'local y = 2' }) - conflict.attach(bufnr, default_config()) + conflict.attach(bufnr) assert.are.equal(0, #get_extmarks(bufnr)) helpers.delete_buffer(bufnr) @@ -808,7 +656,6 @@ describe('conflict', function() 'local x = 2', '>>>>>>> feature', }) - local cfg = default_config() local events = {} local autocmd = vim.api.nvim_create_autocmd('User', { pattern = { 'DiffsConflictDetected', 'DiffsConflictResolved', 'DiffsConflictDetached' }, @@ -818,14 +665,14 @@ describe('conflict', function() end, }) vim.api.nvim_set_current_buf(bufnr) - conflict.attach(bufnr, cfg) + conflict.attach(bufnr) assert.is_true(#get_extmarks(bufnr) > 0) vim.api.nvim_win_set_cursor(0, { 2, 0 }) - conflict.resolve_ours(bufnr, cfg) + conflict.resolve_ours(bufnr) assert.are.equal(0, #get_extmarks(bufnr)) - conflict.refresh(bufnr, cfg) + conflict.refresh(bufnr) vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { '<<<<<<< HEAD', @@ -838,7 +685,7 @@ describe('conflict', function() assert.is_true(#get_extmarks(bufnr) > 0) - conflict.refresh(bufnr, cfg) + conflict.refresh(bufnr) conflict.detach(bufnr) assert.are.same({ 'DiffsConflictDetected', @@ -859,12 +706,12 @@ describe('conflict', function() '>>>>>>> feature', }) vim.api.nvim_set_current_buf(bufnr) - conflict.attach(bufnr, default_config()) + conflict.attach(bufnr) assert.is_true(#get_extmarks(bufnr) > 0) vim.api.nvim_win_set_cursor(0, { 2, 0 }) - conflict.resolve_ours(bufnr, default_config()) + conflict.resolve_ours(bufnr) assert.are.equal(0, #get_extmarks(bufnr)) diff --git a/spec/diff_spec.lua b/spec/diff_spec.lua index 44dbc7df..733bc395 100644 --- a/spec/diff_spec.lua +++ b/spec/diff_spec.lua @@ -73,17 +73,17 @@ describe('diff', function() describe('compute_intra_hunks', function() it('returns nil for all-addition hunks', function() - local result = diff.compute_intra_hunks({ '+line1', '+line2' }, 'default') + local result = diff.compute_intra_hunks({ '+line1', '+line2' }) assert.is_nil(result) end) it('returns nil for all-deletion hunks', function() - local result = diff.compute_intra_hunks({ '-line1', '-line2' }, 'default') + local result = diff.compute_intra_hunks({ '-line1', '-line2' }) assert.is_nil(result) end) it('returns nil for context-only hunks', function() - local result = diff.compute_intra_hunks({ ' line1', ' line2' }, 'default') + local result = diff.compute_intra_hunks({ ' line1', ' line2' }) assert.is_nil(result) end) @@ -91,7 +91,7 @@ describe('diff', function() local result = diff.compute_intra_hunks({ '-local x = 1', '+local x = 2', - }, 'default') + }) assert.is_not_nil(result) assert.are.equal(1, #result.del_spans) @@ -111,7 +111,7 @@ describe('diff', function() ' local b = 3', '-local c = 4', '+local c = 5', - }, 'default') + }) assert.is_not_nil(result) assert.is_true(#result.del_spans >= 2) assert.is_true(#result.add_spans >= 2) @@ -122,7 +122,7 @@ describe('diff', function() '-line one', '-line two', '+line combined', - }, 'default') + }) assert.is_not_nil(result) end) @@ -130,7 +130,7 @@ describe('diff', function() local result = diff.compute_intra_hunks({ '-local x = "héllo"', '+local x = "wörld"', - }, 'default') + }) assert.is_not_nil(result) assert.is_true(#result.del_spans > 0) assert.is_true(#result.add_spans > 0) @@ -140,7 +140,7 @@ describe('diff', function() local result = diff.compute_intra_hunks({ '-local x = 1', '+local x = 1', - }, 'default') + }) assert.is_nil(result) end) end) @@ -179,7 +179,7 @@ describe('diff', function() ---@param lines string[] ---@return string[] local function add_texts(lines) - local result = diff.compute_intra_hunks(lines, 'default') + local result = diff.compute_intra_hunks(lines) if not result then return {} end @@ -195,7 +195,7 @@ describe('diff', function() it('skips intra-line work entirely on inline:none', function() vim.o.diffopt = 'internal,filler,inline:none' - assert.is_nil(diff.compute_intra_hunks(changed, 'default')) + assert.is_nil(diff.compute_intra_hunks(changed)) end) it('spans first to last difference on inline:simple', function() diff --git a/spec/diffopt_spec.lua b/spec/diffopt_spec.lua index 2cefee52..3df49963 100644 --- a/spec/diffopt_spec.lua +++ b/spec/diffopt_spec.lua @@ -233,7 +233,7 @@ describe('line-level whitespace handling', function() end) end) -describe('intra-line whitespace handling (default algorithm)', function() +describe('intra-line whitespace handling', function() local saved before_each(function() @@ -246,39 +246,39 @@ describe('intra-line whitespace handling (default algorithm)', function() it('highlights a whitespace-only intra change by default', function() vim.o.diffopt = 'internal' - local result = diff.compute_intra_hunks({ '-foo bar', '+foo bar' }, 'default') + local result = diff.compute_intra_hunks({ '-foo bar', '+foo bar' }) assert.is_not_nil(result) assert.is_true(#result.add_spans > 0 or #result.del_spans > 0) end) it('drops whitespace-only intra spans when iwhiteall is set', function() vim.o.diffopt = 'internal,iwhiteall' - local result = diff.compute_intra_hunks({ '-foo bar', '+foo bar' }, 'default') + local result = diff.compute_intra_hunks({ '-foo bar', '+foo bar' }) assert.is_nil(result) end) it('keeps content spans while dropping whitespace spans under iwhiteall', function() vim.o.diffopt = 'internal,iwhiteall' - local result = diff.compute_intra_hunks({ '-foo', '+bar ' }, 'default') + local result = diff.compute_intra_hunks({ '-foo', '+bar ' }) assert.is_not_nil(result) assert.is_true(#result.add_spans > 0) end) it('keeps whitespace intra spans under iwhite (only iwhiteall drops them)', function() vim.o.diffopt = 'internal,iwhite' - local result = diff.compute_intra_hunks({ '-ab', '+a b' }, 'default') + local result = diff.compute_intra_hunks({ '-ab', '+a b' }) assert.is_not_nil(result) end) it('drops only end-of-line whitespace spans under iwhiteeol', function() vim.o.diffopt = 'internal,iwhiteeol' - assert.is_nil(diff.compute_intra_hunks({ '-foo', '+foo ' }, 'default')) - assert.is_not_nil(diff.compute_intra_hunks({ '-foo bar', '+foo bar' }, 'default')) + assert.is_nil(diff.compute_intra_hunks({ '-foo', '+foo ' })) + assert.is_not_nil(diff.compute_intra_hunks({ '-foo bar', '+foo bar' })) end) it('does not drop a multibyte content change under iwhiteall', function() vim.o.diffopt = 'internal,iwhiteall' - local result = diff.compute_intra_hunks({ '-café', '+cafe' }, 'default') + local result = diff.compute_intra_hunks({ '-café', '+cafe' }) assert.is_not_nil(result) end) end) diff --git a/spec/email_quote_spec.lua b/spec/email_quote_spec.lua index b767b8e4..3db3a8cf 100644 --- a/spec/email_quote_spec.lua +++ b/spec/email_quote_spec.lua @@ -408,7 +408,7 @@ describe('email-quoted diffs', function() ns, hunk, default_opts({ - highlights = { intra = { algorithm = 'default', max_lines = 500 } }, + highlights = { intra = { max_lines = 500 } }, }) ) diff --git a/spec/helpers.lua b/spec/helpers.lua index 297d2335..64d78982 100644 --- a/spec/helpers.lua +++ b/spec/helpers.lua @@ -16,21 +16,6 @@ ensure_parser('vim') local M = {} -function M.default_conflict_keymaps(overrides) - local keymaps = { - ours = 'go', - theirs = 'gt', - both = 'gb', - none = 'g0', - next = ']x', - prev = '[x', - } - if overrides then - keymaps = vim.tbl_extend('force', keymaps, overrides) - end - return keymaps -end - function M.create_buffer(lines) local bufnr = vim.api.nvim_create_buf(false, true) vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines or {}) diff --git a/spec/highlight_spec.lua b/spec/highlight_spec.lua index c73be68c..863262ce 100644 --- a/spec/highlight_spec.lua +++ b/spec/highlight_spec.lua @@ -1462,7 +1462,7 @@ describe('highlight', function() ns, hunk, default_opts({ - highlights = { intra = { algorithm = 'default', max_lines = 500 } }, + highlights = { intra = { max_lines = 500 } }, }) ) @@ -1504,7 +1504,7 @@ describe('highlight', function() ns, hunk, default_opts({ - highlights = { intra = { algorithm = 'default', max_lines = 500 } }, + highlights = { intra = { max_lines = 500 } }, }) ) @@ -1541,7 +1541,7 @@ describe('highlight', function() default_opts({ highlights = { background = true, - intra = { algorithm = 'default', max_lines = 500 }, + intra = { max_lines = 500 }, }, }) ) @@ -1795,7 +1795,7 @@ describe('highlight', function() ns, hunk, default_opts({ - highlights = { intra = { algorithm = 'default', max_lines = 500 } }, + highlights = { intra = { max_lines = 500 } }, }) ) @@ -1954,7 +1954,7 @@ describe('highlight', function() highlights = { treesitter = false, background = true, - intra = { algorithm = 'default', max_lines = 500 }, + intra = { max_lines = 500 }, }, }) @@ -1962,7 +1962,7 @@ describe('highlight', function() highlights = { treesitter = { max_lines = 500 }, background = true, - intra = { algorithm = 'default', max_lines = 500 }, + intra = { max_lines = 500 }, }, }) syntax.syntax_only = true diff --git a/spec/jj_conflict_spec.lua b/spec/jj_conflict_spec.lua index 21a9ef46..d6ca7cdc 100644 --- a/spec/jj_conflict_spec.lua +++ b/spec/jj_conflict_spec.lua @@ -1,15 +1,5 @@ local conflict = require('diffs.conflict') -local function default_config(overrides) - local cfg = { - keymaps = false, - } - if overrides then - cfg = vim.tbl_deep_extend('force', cfg, overrides) - end - return cfg -end - local function create_file_buffer(lines) local bufnr = vim.api.nvim_create_buf(false, false) vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines or {}) @@ -88,7 +78,7 @@ describe('jj conflict markers', function() local bufnr = create_file_buffer(snapshot_lines()) vim.api.nvim_set_current_buf(bufnr) vim.api.nvim_win_set_cursor(0, { 4, 0 }) - conflict.resolve_ours(bufnr, default_config()) + conflict.resolve_ours(bufnr) assert.are.same({ 'line1', 'AAA', 'line3' }, vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)) vim.api.nvim_buf_delete(bufnr, { force = true }) end) @@ -97,7 +87,7 @@ describe('jj conflict markers', function() local bufnr = create_file_buffer(snapshot_lines()) vim.api.nvim_set_current_buf(bufnr) vim.api.nvim_win_set_cursor(0, { 4, 0 }) - conflict.resolve_theirs(bufnr, default_config()) + conflict.resolve_theirs(bufnr) assert.are.same({ 'line1', 'BBB', 'line3' }, vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)) vim.api.nvim_buf_delete(bufnr, { force = true }) end) @@ -106,14 +96,14 @@ describe('jj conflict markers', function() local bufnr = create_file_buffer(snapshot_lines()) vim.api.nvim_set_current_buf(bufnr) vim.api.nvim_win_set_cursor(0, { 2, 0 }) - conflict.resolve_none(bufnr, default_config()) + conflict.resolve_none(bufnr) assert.are.same({ 'line1', 'line3' }, vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)) vim.api.nvim_buf_delete(bufnr, { force = true }) end) it('highlights the opening marker', function() local bufnr = create_file_buffer(snapshot_lines()) - conflict.attach(bufnr, default_config()) + conflict.attach(bufnr) local rows = {} for _, mark in ipairs( @@ -150,7 +140,7 @@ describe('jj conflict markers', function() it('does not attach when nothing parses', function() local bufnr = create_file_buffer(diff_lines()) - conflict.attach(bufnr, default_config({ keymaps = { ours = 'gto' } })) + conflict.attach(bufnr) assert.are.equal( 0, #vim.api.nvim_buf_get_extmarks( diff --git a/spec/merge_spec.lua b/spec/merge_spec.lua index 245d6561..a302ce3c 100644 --- a/spec/merge_spec.lua +++ b/spec/merge_spec.lua @@ -2,16 +2,6 @@ local helpers = require('spec.helpers') local merge = require('diffs.merge') local rails = require('diffs.rails') -local function default_config(overrides) - local cfg = { - keymaps = false, - } - if overrides then - cfg = vim.tbl_deep_extend('force', cfg, overrides) - end - return cfg -end - local function create_diff_buffer(lines, working_path) local bufnr = helpers.create_buffer(lines) if working_path then @@ -315,7 +305,7 @@ describe('merge', function() setup_buffers() vim.api.nvim_win_set_cursor(0, { 5, 0 }) - merge.resolve_ours(diff_bufnr, default_config()) + merge.resolve_ours(diff_bufnr) local lines = vim.api.nvim_buf_get_lines(working_bufnr, 0, -1, false) assert.are.equal(1, #lines) @@ -328,7 +318,7 @@ describe('merge', function() setup_buffers() vim.api.nvim_win_set_cursor(0, { 5, 0 }) - merge.resolve_theirs(diff_bufnr, default_config()) + merge.resolve_theirs(diff_bufnr) local lines = vim.api.nvim_buf_get_lines(working_bufnr, 0, -1, false) assert.are.equal(1, #lines) @@ -341,7 +331,7 @@ describe('merge', function() setup_buffers() vim.api.nvim_win_set_cursor(0, { 5, 0 }) - merge.resolve_both(diff_bufnr, default_config()) + merge.resolve_both(diff_bufnr) local lines = vim.api.nvim_buf_get_lines(working_bufnr, 0, -1, false) assert.are.equal(2, #lines) @@ -355,7 +345,7 @@ describe('merge', function() setup_buffers() vim.api.nvim_win_set_cursor(0, { 5, 0 }) - merge.resolve_none(diff_bufnr, default_config()) + merge.resolve_none(diff_bufnr) local lines = vim.api.nvim_buf_get_lines(working_bufnr, 0, -1, false) assert.are.equal(1, #lines) @@ -369,7 +359,7 @@ describe('merge', function() vim.api.nvim_win_set_cursor(0, { 5, 0 }) assert.is_false(merge.is_resolved(diff_bufnr, 1)) - merge.resolve_ours(diff_bufnr, default_config()) + merge.resolve_ours(diff_bufnr) assert.is_true(merge.is_resolved(diff_bufnr, 1)) cleanup() @@ -405,7 +395,7 @@ describe('merge', function() assert.is_not_nil(merge.match_hunk_to_conflict(hunks[1], w_bufnr)) vim.api.nvim_win_set_cursor(0, { 5, 0 }) - merge.resolve_theirs(d_bufnr, default_config()) + merge.resolve_theirs(d_bufnr) local lines = vim.api.nvim_buf_get_lines(w_bufnr, 0, -1, false) assert.are.same({ 'local x = 2' }, lines) @@ -418,7 +408,7 @@ describe('merge', function() setup_buffers() vim.api.nvim_win_set_cursor(0, { 5, 0 }) - merge.resolve_ours(diff_bufnr, default_config()) + merge.resolve_ours(diff_bufnr) local notified = false local orig_notify = vim.notify @@ -428,7 +418,7 @@ describe('merge', function() end end - merge.resolve_ours(diff_bufnr, default_config()) + merge.resolve_ours(diff_bufnr) vim.notify = orig_notify assert.is_true(notified) @@ -461,7 +451,7 @@ describe('merge', function() end end - merge.resolve_ours(d_bufnr, default_config()) + merge.resolve_ours(d_bufnr) vim.notify = orig_notify assert.is_true(notified) @@ -714,7 +704,7 @@ describe('merge', function() vim.api.nvim_set_current_buf(d_bufnr) vim.api.nvim_win_set_cursor(0, { 5, 0 }) - merge.resolve_ours(d_bufnr, default_config()) + merge.resolve_ours(d_bufnr) vim.api.nvim_win_set_cursor(0, { 1, 0 }) merge.goto_next(d_bufnr) @@ -747,8 +737,7 @@ describe('merge', function() vim.api.nvim_set_current_buf(d_bufnr) vim.api.nvim_win_set_cursor(0, { 5, 0 }) - local cfg = default_config() - merge.resolve_ours(d_bufnr, cfg) + merge.resolve_ours(d_bufnr) assert.is_true(merge.is_resolved(d_bufnr, 1)) local ready_bufnr @@ -759,65 +748,13 @@ describe('merge', function() ready_bufnr = event.data.bufnr end, }) - merge.attach(d_bufnr, cfg) + merge.attach(d_bufnr) assert.are.equal(d_bufnr, ready_bufnr) assert.is_false(merge.is_resolved(d_bufnr, 1)) helpers.delete_buffer(d_bufnr) helpers.delete_buffer(w_bufnr) end) - - it('does not replace pre-existing buffer-local keymaps', function() - local d_bufnr = create_diff_buffer({ - 'diff --git a/file.lua b/file.lua', - '--- a/file.lua', - '+++ b/file.lua', - '@@ -1,1 +1,1 @@', - '-local x = 1', - '+local x = 2', - }) - vim.keymap.set('n', 'gt', '', { buffer = d_bufnr, desc = 'user theirs' }) - local cfg = default_config({ keymaps = helpers.default_conflict_keymaps() }) - - merge.attach(d_bufnr, cfg) - - local theirs = helpers.get_keymap(d_bufnr, 'gt') - local ours = helpers.get_keymap(d_bufnr, 'go') - assert.are.equal('user theirs', theirs.desc) - assert.are.equal('(diffs-merge-ours)', ours.rhs) - - merge.attach(d_bufnr, default_config()) - - theirs = helpers.get_keymap(d_bufnr, 'gt') - assert.are.equal('user theirs', theirs.desc) - assert.is_false(helpers.has_keymap(d_bufnr, 'go')) - - helpers.delete_buffer(d_bufnr) - end) - - it('does not remove a user replacement during cleanup', function() - local d_bufnr = create_diff_buffer({ - 'diff --git a/file.lua b/file.lua', - '--- a/file.lua', - '+++ b/file.lua', - '@@ -1,1 +1,1 @@', - '-local x = 1', - '+local x = 2', - }) - local cfg = default_config({ keymaps = helpers.default_conflict_keymaps() }) - - merge.attach(d_bufnr, cfg) - assert.are.equal('(diffs-merge-ours)', helpers.get_keymap(d_bufnr, 'go').rhs) - - vim.keymap.set('n', 'go', '', { buffer = d_bufnr, desc = 'user ours' }) - merge.attach(d_bufnr, default_config()) - - local ours = helpers.get_keymap(d_bufnr, 'go') - assert.are.equal('user ours', ours.desc) - assert.is_false(helpers.has_keymap(d_bufnr, 'gt')) - - helpers.delete_buffer(d_bufnr) - end) end) describe('fugitive integration', function() diff --git a/spec/plugin_spec.lua b/spec/plugin_spec.lua index 23205814..2a3855bf 100644 --- a/spec/plugin_spec.lua +++ b/spec/plugin_spec.lua @@ -129,7 +129,7 @@ vim.fn.delete(path) 'vim.notify = function(message, level)', '_G.diffs_notifications[#_G.diffs_notifications + 1] = { message = message, level = level }', 'end', - 'vim.g.diffs = { view = { prefix = false }, highlights = { background = false, intra = { algorithm = "vscode" } }, conflict = { keymaps = { ours = "co" } }, integrations = { "fugitive", "neogit", "neojj", "gitsigns", "telescope" } }', + 'vim.g.diffs = { view = { prefix = false }, highlights = { background = false }, conflict = false, integrations = { "fugitive", "neogit", "neojj", "gitsigns", "telescope" } }', ('vim.opt.runtimepath:prepend(%s)'):format(vim.inspect(vim.fn.getcwd())), } @@ -140,10 +140,6 @@ vim.fn.delete(path) "local runtime = require('diffs.runtime')", 'runtime.attach(0)', 'runtime.attach(0)', - "print('warning=' .. _G.diffs_notifications[1].message)", - "print('warning_level=' .. _G.diffs_notifications[1].level)", - "print('keymap_warning=' .. _G.diffs_notifications[2].message)", - "print('keymap_warning_level=' .. _G.diffs_notifications[2].level)", "print('after_attach_notifications=' .. #(_G.diffs_notifications or {}))", 'local runtime_config = runtime._test.get_config()', 'local highlight_opts = runtime.get_highlight_opts()', @@ -154,7 +150,7 @@ vim.fn.delete(path) "print('runtime_gitsigns=' .. tostring(runtime_config.integrations.gitsigns))", "print('runtime_telescope=' .. tostring(runtime_config.integrations.telescope))", "print('runtime_background=' .. tostring(runtime_config.highlights.background))", - "print('runtime_conflict_keymaps=' .. tostring(runtime_config.conflict.keymaps.ours))", + "print('runtime_conflict=' .. tostring(runtime_config.conflict))", "print('runtime_config_priorities=' .. tostring(runtime_config.highlights.priorities))", "print('highlight_priority_clear=' .. tostring(highlight_opts.highlights.priorities.clear))", "print('highlight_priority_syntax=' .. tostring(highlight_opts.highlights.priorities.syntax))", @@ -182,13 +178,7 @@ vim.fn.delete(path) assert.matches('loaded=1', output, 1, true) assert.matches('notifications=0', output, 1, true) - assert.matches('after_attach_notifications=2', output, 1, true) - assert.matches('libvscodediff support will be removed on 30 November 2026.', output, 1, true) - assert.matches('Remove highlights.intra.algorithm', output, 1, true) - assert.matches('conflict.keymaps will be removed on 30 November 2026.', output, 1, true) - assert.matches(':help diffs.nvim-conflict-keymaps', output, 1, true) - assert.matches('keymap_warning_level=' .. vim.log.levels.WARN, output, 1, true) - assert.matches('warning_level=' .. vim.log.levels.WARN, output, 1, true) + assert.matches('after_attach_notifications=0', output, 1, true) assert.matches('runtime_view_prefix=false', output, 1, true) assert.matches('runtime_fugitive=true', output, 1, true) assert.matches('runtime_neogit=true', output, 1, true) @@ -196,7 +186,7 @@ vim.fn.delete(path) assert.matches('runtime_gitsigns=true', output, 1, true) assert.matches('runtime_telescope=true', output, 1, true) assert.matches('runtime_background=false', output, 1, true) - assert.matches('runtime_conflict_keymaps=co', output, 1, true) + assert.matches('runtime_conflict=false', output, 1, true) assert.matches('runtime_config_priorities=nil', output, 1, true) assert.matches('highlight_priority_clear=198', output, 1, true) assert.matches('highlight_priority_syntax=199', output, 1, true)