feat(init): add gitsigns config field and get_highlight_opts() getter

Problem: gitsigns blame popup highlighting needs access to diffs.nvim's
highlight config, but no public API exposes it.

Solution: add `diffs.GitsignsConfig` type, `gitsigns` field (default
`false`) with normalization and validation, and a public
`get_highlight_opts()` getter returning `hide_prefix` + `highlights`.
This commit is contained in:
Barrett Ruth 2026-03-06 08:35:08 -05:00
parent c498fd2bac
commit c64ca827f3

View file

@ -38,6 +38,8 @@
---@class diffs.NeogitConfig
---@class diffs.GitsignsConfig
---@class diffs.ConflictKeymaps
---@field ours string|false
---@field theirs string|false
@ -62,6 +64,7 @@
---@field highlights diffs.Highlights
---@field fugitive diffs.FugitiveConfig|false
---@field neogit diffs.NeogitConfig|false
---@field gitsigns diffs.GitsignsConfig|false
---@field conflict diffs.ConflictConfig
---@class diffs
@ -141,6 +144,7 @@ local default_config = {
},
fugitive = false,
neogit = false,
gitsigns = false,
conflict = {
enabled = true,
disable_diagnostics = true,
@ -591,6 +595,10 @@ local function init()
opts.neogit = {}
end
if opts.gitsigns == true then
opts.gitsigns = {}
end
vim.validate('debug', opts.debug, function(v)
return v == nil or type(v) == 'boolean' or type(v) == 'string'
end, 'boolean or string (file path)')
@ -601,6 +609,9 @@ local function init()
vim.validate('neogit', opts.neogit, function(v)
return v == nil or v == false or type(v) == 'table'
end, 'table or false')
vim.validate('gitsigns', opts.gitsigns, 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('highlights', opts.highlights, 'table', true)
@ -990,6 +1001,12 @@ function M.get_conflict_config()
return config.conflict
end
---@return diffs.HunkOpts
function M.get_highlight_opts()
init()
return { hide_prefix = config.hide_prefix, highlights = config.highlights }
end
local function process_pending_clear(bufnr)
local entry = hunk_cache[bufnr]
if entry and entry.pending_clear then