feat: remove config deprecation in v0.3.0 (#129)

This commit is contained in:
Barrett Ruth 2026-02-18 13:34:43 -05:00 committed by GitHub
parent d68cddb1a4
commit b1abfe4f4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 84 deletions

View file

@ -36,7 +36,7 @@ etc.) works without vim-fugitive.
==============================================================================
SETUP *diffs-setup*
Using lazy.nvim: >lua
Install with lazy.nvim: >lua
{
'barrettruth/diffs.nvim',
dependencies = { 'tpope/vim-fugitive' },
@ -621,10 +621,6 @@ line visuals. The overrides are reapplied on `ColorScheme` since Neogit
re-defines its groups then. When `neogit = false`, no highlight overrides
are applied.
Deprecated: ~
The `filetypes` config key still works but is deprecated and will be
removed in 0.3.0. Use `fugitive`, `neogit`, and `extra_filetypes` instead.
==============================================================================
API *diffs-api*

View file

@ -58,7 +58,6 @@
---@class diffs.Config
---@field debug boolean|string
---@field hide_prefix boolean
---@field filetypes? string[] @deprecated use fugitive, neogit, extra_filetypes
---@field extra_filetypes string[]
---@field highlights diffs.Highlights
---@field fugitive diffs.FugitiveConfig|false
@ -193,16 +192,13 @@ end
---@param opts table
---@return string[]
function M.compute_filetypes(opts)
if opts.filetypes then
return opts.filetypes
end
local fts = { 'git', 'gitcommit' }
local fug = opts.fugitive
if fug == true or (type(fug) == 'table' and fug.enabled ~= false) then
if fug == true or type(fug) == 'table' then
table.insert(fts, 'fugitive')
end
local neo = opts.neogit
if neo == true or (type(neo) == 'table' and neo.enabled ~= false) then
if neo == true or type(neo) == 'table' then
table.insert(fts, 'NeogitStatus')
table.insert(fts, 'NeogitCommitView')
table.insert(fts, 'NeogitDiffView')
@ -450,62 +446,15 @@ local function init()
local opts = vim.g.diffs or {}
if opts.filetypes then
vim.deprecate(
'vim.g.diffs.filetypes',
'fugitive, neogit, and extra_filetypes',
'0.3.0',
'diffs.nvim'
)
end
if not opts.filetypes and opts.fugitive == nil and opts.neogit == nil then
local has_diff_ft = false
if type(opts.extra_filetypes) == 'table' then
for _, ft in ipairs(opts.extra_filetypes) do
if ft == 'diff' then
has_diff_ft = true
break
end
end
end
if not has_diff_ft then
vim.notify(
'[diffs.nvim] fugitive, neogit, and diff filetypes are now opt-in.\n'
.. 'Add the integrations you use to your config:\n\n'
.. ' vim.g.diffs = {\n'
.. ' fugitive = true,\n'
.. ' neogit = true,\n'
.. " extra_filetypes = { 'diff' },\n"
.. ' }\n\n'
.. 'This warning will be removed in 0.3.0.',
vim.log.levels.WARN
)
end
end
local fugitive_defaults = { horizontal = 'du', vertical = 'dU' }
if opts.fugitive == true then
opts.fugitive = vim.deepcopy(fugitive_defaults)
elseif type(opts.fugitive) == 'table' then
if opts.fugitive.enabled == false then
opts.fugitive = false
else
---@diagnostic disable-next-line: inject-field
opts.fugitive.enabled = nil
opts.fugitive = vim.tbl_extend('keep', opts.fugitive, fugitive_defaults)
end
opts.fugitive = vim.tbl_extend('keep', opts.fugitive, fugitive_defaults)
end
if opts.neogit == true then
opts.neogit = {}
elseif type(opts.neogit) == 'table' then
if opts.neogit.enabled == false then
opts.neogit = false
else
---@diagnostic disable-next-line: inject-field
opts.neogit.enabled = nil
end
end
vim.validate({

View file

@ -390,31 +390,6 @@ describe('diffs', function()
assert.is_true(vim.tbl_contains(fts, 'NeogitStatus'))
assert.is_true(vim.tbl_contains(fts, 'diff'))
end)
it('returns custom filetypes when filetypes key is set', function()
local fts = compute({ filetypes = { 'custom' } })
assert.are.same({ 'custom' }, fts)
end)
it('backward compat: includes fugitive when enabled = true in table', function()
local fts = compute({ fugitive = { enabled = true } })
assert.is_true(vim.tbl_contains(fts, 'fugitive'))
end)
it('backward compat: excludes fugitive when enabled = false in table', function()
local fts = compute({ fugitive = { enabled = false } })
assert.is_false(vim.tbl_contains(fts, 'fugitive'))
end)
it('backward compat: includes neogit when enabled = true in table', function()
local fts = compute({ neogit = { enabled = true } })
assert.is_true(vim.tbl_contains(fts, 'NeogitStatus'))
end)
it('backward compat: excludes neogit when enabled = false in table', function()
local fts = compute({ neogit = { enabled = false } })
assert.is_false(vim.tbl_contains(fts, 'NeogitStatus'))
end)
end)
describe('diff mode', function()