feat: add committia.vim integration (#166)

## Problem

committia.vim's diff pane (`ft=git`, buffer name `__committia_diff__`)
is rejected by the `ft=git` guard in the `FileType` callback, preventing
diffs.nvim from highlighting it.

## Solution

Add a `committia` config toggle following the same pattern as
`neogit`/`gitsigns`. When enabled, the `ft=git` guard also allows
committia's `__committia_diff__` buffer through.

Closes #161
This commit is contained in:
Barrett Ruth 2026-03-06 13:04:21 -05:00 committed by GitHub
parent d06144450c
commit dc6fd7a387
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View file

@ -40,6 +40,8 @@
---@class diffs.GitsignsConfig ---@class diffs.GitsignsConfig
---@class diffs.CommittiaConfig
---@class diffs.ConflictKeymaps ---@class diffs.ConflictKeymaps
---@field ours string|false ---@field ours string|false
---@field theirs string|false ---@field theirs string|false
@ -65,6 +67,7 @@
---@field fugitive diffs.FugitiveConfig|false ---@field fugitive diffs.FugitiveConfig|false
---@field neogit diffs.NeogitConfig|false ---@field neogit diffs.NeogitConfig|false
---@field gitsigns diffs.GitsignsConfig|false ---@field gitsigns diffs.GitsignsConfig|false
---@field committia diffs.CommittiaConfig|false
---@field conflict diffs.ConflictConfig ---@field conflict diffs.ConflictConfig
---@class diffs ---@class diffs
@ -145,6 +148,7 @@ local default_config = {
fugitive = false, fugitive = false,
neogit = false, neogit = false,
gitsigns = false, gitsigns = false,
committia = false,
conflict = { conflict = {
enabled = true, enabled = true,
disable_diagnostics = true, disable_diagnostics = true,
@ -599,6 +603,10 @@ local function init()
opts.gitsigns = {} opts.gitsigns = {}
end end
if opts.committia == true then
opts.committia = {}
end
vim.validate('debug', opts.debug, function(v) vim.validate('debug', opts.debug, function(v)
return v == nil or type(v) == 'boolean' or type(v) == 'string' return v == nil or type(v) == 'boolean' or type(v) == 'string'
end, 'boolean or string (file path)') end, 'boolean or string (file path)')
@ -612,6 +620,9 @@ local function init()
vim.validate('gitsigns', opts.gitsigns, function(v) vim.validate('gitsigns', opts.gitsigns, function(v)
return v == nil or v == false or type(v) == 'table' return v == nil or v == false or type(v) == 'table'
end, 'table or false') end, 'table or false')
vim.validate('committia', opts.committia, function(v)
return v == nil or v == false or type(v) == 'table'
end, 'table or false')
vim.validate('extra_filetypes', opts.extra_filetypes, 'table', true) vim.validate('extra_filetypes', opts.extra_filetypes, 'table', true)
vim.validate('highlights', opts.highlights, 'table', true) vim.validate('highlights', opts.highlights, 'table', true)
@ -995,6 +1006,12 @@ function M.get_fugitive_config()
return config.fugitive return config.fugitive
end end
---@return diffs.CommittiaConfig|false
function M.get_committia_config()
init()
return config.committia
end
---@return diffs.ConflictConfig ---@return diffs.ConflictConfig
function M.get_conflict_config() function M.get_conflict_config()
init() init()

View file

@ -23,7 +23,10 @@ vim.api.nvim_create_autocmd('FileType', {
callback = function(args) callback = function(args)
local diffs = require('diffs') local diffs = require('diffs')
if args.match == 'git' then if args.match == 'git' then
if not diffs.get_fugitive_config() or not diffs.is_fugitive_buffer(args.buf) then local is_fugitive = diffs.get_fugitive_config() and diffs.is_fugitive_buffer(args.buf)
local is_committia = diffs.get_committia_config()
and vim.api.nvim_buf_get_name(args.buf):match('__committia_diff__$')
if not is_fugitive and not is_committia then
return return
end end
end end