feat: fix highlighting

This commit is contained in:
Barrett Ruth 2026-02-02 00:57:41 -05:00
parent b3e687c954
commit d7537e93d0
5 changed files with 37 additions and 39 deletions

View file

@ -66,9 +66,11 @@ CONFIGURATION *fugitive-ts-config*
this many lines. Prevents lag on massive diffs.
{conceal_prefixes} (boolean, default: true)
Hide diff prefixes (`+`/`-`/` `) using extmark
conceal. Makes code appear without the leading
diff character.
Hide diff prefixes (`+`/`-`/` `) using virtual
text overlay. Makes code appear without the
leading diff character. When `highlights.background`
is also enabled, the overlay inherits the line's
background color.
{highlights} (table, default: see below)
Controls which highlight features are enabled.
@ -79,23 +81,22 @@ CONFIGURATION *fugitive-ts-config*
{treesitter} (boolean, default: true)
Apply treesitter syntax highlighting to code.
{headers} (boolean, default: true)
Highlight function context in hunk headers.
The context portion of `@@ -10,3 +10,4 @@ func()`
will receive treesitter highlighting.
{background} (boolean, default: true)
Apply `DiffAdd` background to `+` lines and
`DiffDelete` background to `-` lines.
Apply background highlighting to `+`/`-` lines
using `FugitiveTsAdd`/`FugitiveTsDelete` groups
(derived from `DiffAdd`/`DiffDelete` backgrounds).
{linenr} (boolean, default: true)
Highlight line numbers with `DiffAdd`/`DiffDelete`
colors matching the line background.
Highlight line numbers with matching colors.
Only visible if line numbers are enabled.
{vim} (boolean, default: false)
Experimental: Use vim syntax highlighting as
fallback when no treesitter parser is available.
Note: Header context (e.g., `@@ -10,3 +10,4 @@ func()`) is always
highlighted with treesitter when a parser is available.
==============================================================================
API *fugitive-ts-api*
@ -129,10 +130,10 @@ IMPLEMENTATION *fugitive-ts-implementation*
- Language is detected from the filename using |vim.filetype.match()|
- Diff prefixes (`+`/`-`/` `) are stripped from code lines
- Code is parsed with |vim.treesitter.get_string_parser()|
- Background extmarks (`DiffAdd`/`DiffDelete`) applied at priority 198
- Background extmarks (`FugitiveTsAdd`/`FugitiveTsDelete`) at priority 198
- `Normal` extmarks at priority 199 clear underlying diff foreground
- Treesitter highlights are applied as extmarks at priority 200
- Conceal extmarks hide diff prefixes when `conceal_prefixes` is enabled
- Virtual text overlays hide diff prefixes when `conceal_prefixes` is enabled
4. Re-highlighting occurs on `TextChanged` (debounced) and `Syntax` events
==============================================================================