feat: gitsigns blame popup highlighting (#157)
## Problem
gitsigns' `:Gitsigns blame_line` popup shows flat
`GitSignsAddPreview`/`GitSignsDeletePreview` line highlights with basic
word-level inline diffs, but no treesitter syntax or diffs.nvim's
character-level intra-line highlighting.
## Solution
Add `lua/diffs/gitsigns.lua` which patches gitsigns' `Popup.create` and
`Popup.update` to intercept blame popups. Parses `Hunk N of M` sections
from the popup buffer, clears gitsigns' own `gitsigns_popup` namespace
on the diff region, and applies `highlight_hunk` with manual
`@diff.plus`/`@diff.minus` prefix extmarks. Uses a separate
`diffs-gitsigns` namespace to avoid colliding with the main decoration
provider.
Enabled via `vim.g.diffs = { gitsigns = true }`. Wired in
`plugin/diffs.lua` with a `User GitAttach` lazy-load retry for when
gitsigns loads after diffs.nvim. Config plumbing adds
`get_highlight_opts()` as a public getter, replacing the
`debug.getupvalue` hack used by the standalone `blame_hl.nvim` plugin.
Closes #155.
This commit is contained in:
parent
c498fd2bac
commit
993fed4a45
7 changed files with 492 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue