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:
Barrett Ruth 2026-03-06 08:42:02 -05:00 committed by GitHub
parent c498fd2bac
commit 993fed4a45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 492 additions and 10 deletions

View file

@ -5,6 +5,19 @@ vim.g.loaded_diffs = 1
require('diffs.commands').setup()
local gs_cfg = (vim.g.diffs or {}).gitsigns
if gs_cfg == true or type(gs_cfg) == 'table' then
if not require('diffs.gitsigns').setup() then
vim.api.nvim_create_autocmd('User', {
pattern = 'GitAttach',
once = true,
callback = function()
require('diffs.gitsigns').setup()
end,
})
end
end
vim.api.nvim_create_autocmd('FileType', {
pattern = require('diffs').compute_filetypes(vim.g.diffs or {}),
callback = function(args)