feat(highlight): add character-level intra-line diff highlighting

Line-level backgrounds (DiffsAdd/DiffsDelete) now get a second tier:
changed characters within modified lines receive an intense background
overlay (DiffsAddText/DiffsDeleteText at 70% alpha vs 40% for lines).
Treesitter foreground colors show through since the extmarks only set bg.

diff.lua extracts contiguous -/+ change groups from hunk lines and diffs
each group byte-by-byte using vim.diff(). An optional libvscodediff FFI
backend (lib.lua) auto-downloads the .so from codediff.nvim releases and
falls back to native if unavailable.

New config: highlights.intra.{enabled, algorithm, max_lines}. Gated by
max_lines (default 200) to avoid stalling on huge hunks. Priority 201
sits above treesitter (200) so the character bg always wins.

Closes #60
This commit is contained in:
Barrett Ruth 2026-02-06 13:53:58 -05:00
parent 294cbad749
commit 997bc49f8b
7 changed files with 842 additions and 0 deletions

View file

@ -15,6 +15,13 @@ function M.check()
else
vim.health.warn('vim-fugitive not detected (required for unified diff highlighting)')
end
local lib = require('diffs.lib')
if lib.has_lib() then
vim.health.ok('libvscode_diff found at ' .. lib.lib_path())
else
vim.health.info('libvscode_diff not found (optional, using native vim.diff fallback)')
end
end
return M