Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions doc/diffs.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down Expand Up @@ -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*

Expand Down
57 changes: 3 additions & 54 deletions lua/diffs/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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({
Expand Down
25 changes: 0 additions & 25 deletions spec/init_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading