diffs.nvim/plugin/diffs.lua
Barrett Ruth bf2c91f79f feat: add :Gdiff command for unified diff against git revision
Compares current buffer against any git revision (default HEAD), opens result
in vsplit with full diffs.nvim syntax highlighting.
2026-02-04 18:14:18 -05:00

28 lines
585 B
Lua

if vim.g.loaded_diffs then
return
end
vim.g.loaded_diffs = 1
require('diffs.commands').setup()
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'fugitive', 'git' },
callback = function(args)
local diffs = require('diffs')
if args.match == 'git' and not diffs.is_fugitive_buffer(args.buf) then
return
end
diffs.attach(args.buf)
end,
})
vim.api.nvim_create_autocmd('OptionSet', {
pattern = 'diff',
callback = function()
if vim.wo.diff then
require('diffs').attach_diff()
else
require('diffs').detach_diff()
end
end,
})