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
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue