feat(config): replace algorithm 'auto'/'native' with 'default'/'vscode'

'default' inherits algorithm and linematch from diffopt, 'vscode' uses
the FFI library. Removes the need for diffs.nvim to duplicate settings
that users already control globally.
This commit is contained in:
Barrett Ruth 2026-02-06 21:23:40 -05:00
parent cc947167c3
commit 10af59a70d
6 changed files with 85 additions and 47 deletions

View file

@ -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' }, 'native')
local result = diff.compute_intra_hunks({ '+line1', '+line2' }, 'default')
assert.is_nil(result)
end)
it('returns nil for all-deletion hunks', function()
local result = diff.compute_intra_hunks({ '-line1', '-line2' }, 'native')
local result = diff.compute_intra_hunks({ '-line1', '-line2' }, 'default')
assert.is_nil(result)
end)
it('returns nil for context-only hunks', function()
local result = diff.compute_intra_hunks({ ' line1', ' line2' }, 'native')
local result = diff.compute_intra_hunks({ ' line1', ' line2' }, 'default')
assert.is_nil(result)
end)
@ -91,7 +91,7 @@ describe('diff', function()
local result = diff.compute_intra_hunks({
'-local x = 1',
'+local x = 2',
}, 'native')
}, 'default')
assert.is_not_nil(result)
assert.is_true(#result.del_spans > 0)
assert.is_true(#result.add_spans > 0)
@ -101,7 +101,7 @@ describe('diff', function()
local result = diff.compute_intra_hunks({
'-local x = 1',
'+local x = 2',
}, 'native')
}, 'default')
assert.is_not_nil(result)
assert.are.equal(1, #result.del_spans)
@ -121,7 +121,7 @@ describe('diff', function()
' local b = 3',
'-local c = 4',
'+local c = 5',
}, 'native')
}, 'default')
assert.is_not_nil(result)
assert.is_true(#result.del_spans >= 2)
assert.is_true(#result.add_spans >= 2)
@ -132,7 +132,7 @@ describe('diff', function()
'-line one',
'-line two',
'+line combined',
}, 'native')
}, 'default')
assert.is_not_nil(result)
end)
@ -140,7 +140,7 @@ describe('diff', function()
local result = diff.compute_intra_hunks({
'-local x = "héllo"',
'+local x = "wörld"',
}, 'native')
}, 'default')
assert.is_not_nil(result)
assert.is_true(#result.del_spans > 0)
assert.is_true(#result.add_spans > 0)
@ -150,7 +150,7 @@ describe('diff', function()
local result = diff.compute_intra_hunks({
'-local x = 1',
'+local x = 1',
}, 'native')
}, 'default')
assert.is_nil(result)
end)
end)

View file

@ -45,7 +45,7 @@ describe('highlight', function()
},
intra = {
enabled = false,
algorithm = 'native',
algorithm = 'default',
max_lines = 500,
},
},
@ -828,7 +828,7 @@ describe('highlight', function()
default_opts({
highlights = {
background = true,
intra = { enabled = true, algorithm = 'native', max_lines = 500 },
intra = { enabled = true, algorithm = 'default', max_lines = 500 },
},
})
)
@ -873,7 +873,7 @@ describe('highlight', function()
ns,
hunk,
default_opts({
highlights = { intra = { enabled = true, algorithm = 'native', max_lines = 500 } },
highlights = { intra = { enabled = true, algorithm = 'default', max_lines = 500 } },
})
)
@ -913,7 +913,7 @@ describe('highlight', function()
ns,
hunk,
default_opts({
highlights = { intra = { enabled = false, algorithm = 'native', max_lines = 500 } },
highlights = { intra = { enabled = false, algorithm = 'default', max_lines = 500 } },
})
)
@ -947,7 +947,7 @@ describe('highlight', function()
ns,
hunk,
default_opts({
highlights = { intra = { enabled = true, algorithm = 'native', max_lines = 500 } },
highlights = { intra = { enabled = true, algorithm = 'default', max_lines = 500 } },
})
)
@ -984,7 +984,7 @@ describe('highlight', function()
default_opts({
highlights = {
background = true,
intra = { enabled = true, algorithm = 'native', max_lines = 500 },
intra = { enabled = true, algorithm = 'default', max_lines = 500 },
},
})
)