feat: remove config deprecation in v0.3.0 (#129)
This commit is contained in:
parent
d68cddb1a4
commit
b1abfe4f4a
3 changed files with 4 additions and 84 deletions
|
|
@ -36,7 +36,7 @@ etc.) works without vim-fugitive.
|
||||||
==============================================================================
|
==============================================================================
|
||||||
SETUP *diffs-setup*
|
SETUP *diffs-setup*
|
||||||
|
|
||||||
Using lazy.nvim: >lua
|
Install with lazy.nvim: >lua
|
||||||
{
|
{
|
||||||
'barrettruth/diffs.nvim',
|
'barrettruth/diffs.nvim',
|
||||||
dependencies = { 'tpope/vim-fugitive' },
|
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
|
re-defines its groups then. When `neogit = false`, no highlight overrides
|
||||||
are applied.
|
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*
|
API *diffs-api*
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@
|
||||||
---@class diffs.Config
|
---@class diffs.Config
|
||||||
---@field debug boolean|string
|
---@field debug boolean|string
|
||||||
---@field hide_prefix boolean
|
---@field hide_prefix boolean
|
||||||
---@field filetypes? string[] @deprecated use fugitive, neogit, extra_filetypes
|
|
||||||
---@field extra_filetypes string[]
|
---@field extra_filetypes string[]
|
||||||
---@field highlights diffs.Highlights
|
---@field highlights diffs.Highlights
|
||||||
---@field fugitive diffs.FugitiveConfig|false
|
---@field fugitive diffs.FugitiveConfig|false
|
||||||
|
|
@ -193,16 +192,13 @@ end
|
||||||
---@param opts table
|
---@param opts table
|
||||||
---@return string[]
|
---@return string[]
|
||||||
function M.compute_filetypes(opts)
|
function M.compute_filetypes(opts)
|
||||||
if opts.filetypes then
|
|
||||||
return opts.filetypes
|
|
||||||
end
|
|
||||||
local fts = { 'git', 'gitcommit' }
|
local fts = { 'git', 'gitcommit' }
|
||||||
local fug = opts.fugitive
|
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')
|
table.insert(fts, 'fugitive')
|
||||||
end
|
end
|
||||||
local neo = opts.neogit
|
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, 'NeogitStatus')
|
||||||
table.insert(fts, 'NeogitCommitView')
|
table.insert(fts, 'NeogitCommitView')
|
||||||
table.insert(fts, 'NeogitDiffView')
|
table.insert(fts, 'NeogitDiffView')
|
||||||
|
|
@ -450,62 +446,15 @@ local function init()
|
||||||
|
|
||||||
local opts = vim.g.diffs or {}
|
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' }
|
local fugitive_defaults = { horizontal = 'du', vertical = 'dU' }
|
||||||
if opts.fugitive == true then
|
if opts.fugitive == true then
|
||||||
opts.fugitive = vim.deepcopy(fugitive_defaults)
|
opts.fugitive = vim.deepcopy(fugitive_defaults)
|
||||||
elseif type(opts.fugitive) == 'table' then
|
elseif type(opts.fugitive) == 'table' then
|
||||||
if opts.fugitive.enabled == false then
|
opts.fugitive = vim.tbl_extend('keep', opts.fugitive, fugitive_defaults)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts.neogit == true then
|
if opts.neogit == true then
|
||||||
opts.neogit = {}
|
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
|
end
|
||||||
|
|
||||||
vim.validate({
|
vim.validate({
|
||||||
|
|
|
||||||
|
|
@ -390,31 +390,6 @@ describe('diffs', function()
|
||||||
assert.is_true(vim.tbl_contains(fts, 'NeogitStatus'))
|
assert.is_true(vim.tbl_contains(fts, 'NeogitStatus'))
|
||||||
assert.is_true(vim.tbl_contains(fts, 'diff'))
|
assert.is_true(vim.tbl_contains(fts, 'diff'))
|
||||||
end)
|
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)
|
end)
|
||||||
|
|
||||||
describe('diff mode', function()
|
describe('diff mode', function()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue