Merge pull request #46 from barrettruth/fix/remove-enabled-flag

fix: remove useless `enabled` flag
This commit is contained in:
Barrett Ruth 2026-02-03 02:55:12 -05:00 committed by GitHub
commit 1cd3e9b750
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 1 additions and 46 deletions

View file

@ -44,7 +44,7 @@ luarocks install diffs.nvim
The buffer is then re-painted after `debounce_ms` milliseconds, causing an
unavoidable visual "flash" even when `debounce_ms = 0`.
## Acknowledgements
# Acknowledgements
- [vim-fugitive](https://github.com/tpope/vim-fugitive)
- [codediff.nvim](https://github.com/esmuellert/codediff.nvim)

View file

@ -48,9 +48,6 @@ CONFIGURATION *diffs-config*
*diffs.Config*
Fields: ~
{enabled} (boolean, default: true)
Enable or disable highlighting globally.
{debug} (boolean, default: false)
Enable debug logging to |:messages| with
`[diffs]` prefix.

View file

@ -11,7 +11,6 @@
---@field max_lines integer
---@class diffs.Config
---@field enabled boolean
---@field debug boolean
---@field debounce_ms integer
---@field hide_prefix boolean
@ -65,7 +64,6 @@ end
---@type diffs.Config
local default_config = {
enabled = true,
debug = false,
debounce_ms = 0,
hide_prefix = false,
@ -102,10 +100,6 @@ local dbg = log.dbg
---@param bufnr integer
local function highlight_buffer(bufnr)
if not config.enabled then
return
end
if not vim.api.nvim_buf_is_valid(bufnr) then
return
end
@ -242,10 +236,6 @@ local DIFF_WINHIGHLIGHT = table.concat({
}, ',')
function M.attach_diff()
if not config.enabled then
return
end
local tabpage = vim.api.nvim_get_current_tabpage()
local wins = vim.api.nvim_tabpage_list_wins(tabpage)
@ -282,7 +272,6 @@ function M.setup(opts)
opts = opts or {}
vim.validate({
enabled = { opts.enabled, 'boolean', true },
debug = { opts.debug, 'boolean', true },
debounce_ms = { opts.debounce_ms, 'number', true },
hide_prefix = { opts.hide_prefix, 'boolean', true },

View file

@ -131,26 +131,6 @@ describe('diffs', function()
end)
end)
describe('config options', function()
it('enabled=false prevents highlighting', function()
diffs.setup({ enabled = false })
local bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {
'M test.lua',
'@@ -1,1 +1,2 @@',
' local x = 1',
'+local y = 2',
})
diffs.attach(bufnr)
local ns = vim.api.nvim_create_namespace('diffs')
local extmarks = vim.api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, {})
assert.are.equal(0, #extmarks)
vim.api.nvim_buf_delete(bufnr, { force = true })
end)
end)
describe('is_fugitive_buffer', function()
it('returns true for fugitive:// URLs', function()
local bufnr = vim.api.nvim_create_buf(false, true)
@ -204,17 +184,6 @@ describe('diffs', function()
close_window(win)
end)
it('does nothing when enabled=false', function()
diffs.setup({ enabled = false })
local win, _ = create_diff_window()
diffs.attach_diff()
local whl = vim.api.nvim_get_option_value('winhighlight', { win = win })
assert.are.equal('', whl)
close_window(win)
end)
it('is idempotent', function()
local win, _ = create_diff_window()
assert.has_no.errors(function()