feat: treesitter highlighting for diff headers

Apply treesitter highlighting to diff metadata lines (diff --git, index,
---, +++) using the diff language parser. Header info is attached only
to the first hunk of each file to avoid duplicate highlighting.

Based on PR #52 by @phanen with fixes:
- header_lines now only contains diff metadata, not hunk content
- header info attached only to first hunk per file
- removed arbitrary hunk count restriction
This commit is contained in:
Barrett Ruth 2026-02-04 14:49:27 -05:00
parent 4008df3558
commit a25f1e9d84
7 changed files with 292 additions and 5 deletions

View file

@ -10,6 +10,7 @@ syntax highlighting.
## Features
- Treesitter syntax highlighting in `:Git` diffs and commit views
- Diff header highlighting (`diff --git`, `index`, `---`, `+++`)
- `:Gdiffsplit` / `:Gvdiffsplit` syntax through diff backgrounds
- Background-only diff colors for any `&diff` buffer (`:diffthis`, `vimdiff`)
- Vim syntax fallback for languages without a treesitter parser
@ -66,3 +67,4 @@ luarocks install diffs.nvim
- [`vim-fugitive`](https://github.com/tpope/vim-fugitive)
- [`codediff.nvim`](https://github.com/esmuellert/codediff.nvim)
- [`diffview.nvim`](https://github.com/sindrets/diffview.nvim)
- [@phanen](https://github.com/phanen) - diff header highlighting