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 The buffer is then re-painted after `debounce_ms` milliseconds, causing an
unavoidable visual "flash" even when `debounce_ms = 0`. unavoidable visual "flash" even when `debounce_ms = 0`.
## Acknowledgements # Acknowledgements
- [vim-fugitive](https://github.com/tpope/vim-fugitive) - [vim-fugitive](https://github.com/tpope/vim-fugitive)
- [codediff.nvim](https://github.com/esmuellert/codediff.nvim) - [codediff.nvim](https://github.com/esmuellert/codediff.nvim)

View file

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

View file

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

View file

@ -131,26 +131,6 @@ describe('diffs', function()
end) end)
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() describe('is_fugitive_buffer', function()
it('returns true for fugitive:// URLs', function() it('returns true for fugitive:// URLs', function()
local bufnr = vim.api.nvim_create_buf(false, true) local bufnr = vim.api.nvim_create_buf(false, true)
@ -204,17 +184,6 @@ describe('diffs', function()
close_window(win) close_window(win)
end) 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() it('is idempotent', function()
local win, _ = create_diff_window() local win, _ = create_diff_window()
assert.has_no.errors(function() assert.has_no.errors(function()