Skip to content

feat(neogit): use new neogit apis for highlight and repo root#133

Merged
barrettruth merged 1 commit intomainfrom
feat/neogit-apis
Feb 25, 2026
Merged

feat(neogit): use new neogit apis for highlight and repo root#133
barrettruth merged 1 commit intomainfrom
feat/neogit-apis

Conversation

@barrettruth
Copy link
Owner

Problem

diffs.nvim was blanking 18 Neogit highlight groups globally on attach to prevent Neogit's line_hl_group fg from stomping treesitter syntax. It also fell back to getcwd() plus a subprocess call for repo root detection on Neogit buffers, and had no mechanism to refresh the hunk cache when Neogit lazy-loaded new diff sections.

Solution

Adopts three APIs introduced in NeogitOrg/neogit#1897:

  • Sets vim.b.neogit_disable_hunk_highlight = true on the Neogit buffer at attach time. Neogit's HunkLine renderer skips all its own highlight logic when this is set, replacing the need to blank 18 hl groups globally and the associated ColorScheme re-application.
  • Reads vim.b.neogit_git_dir in get_repo_root() as a reliable fallback between the existing b:git_dir check and the getcwd() subprocess path.
  • Registers a buffer-local User NeogitDiffLoaded autocmd on attach that calls M.refresh() when Neogit lazy-loads a new diff section, keeping the hunk cache in sync.

Closes #128

Problem: diffs.nvim blanked 18 Neogit highlight groups globally on
attach and fell back to getcwd() plus a subprocess call for repo root
detection, with no cache refresh when Neogit lazy-loads new hunks.

Solution: adopt three APIs from Neogit PR #1897:
- set vim.b.neogit_disable_hunk_highlight = true on attach instead
  of overriding 18 hl groups globally
- read vim.b.neogit_git_dir for reliable repo root resolution
- register User NeogitDiffLoaded per-buffer to refresh hunk cache

Closes #128
@barrettruth barrettruth merged commit 2feb8a8 into main Feb 25, 2026
7 checks passed
@barrettruth barrettruth deleted the feat/neogit-apis branch February 25, 2026 16:43
barrettruth added a commit that referenced this pull request Feb 25, 2026
## Problem

Regressions #119 and #120 showed the test suite had no coverage of the
decoration provider cache pipeline, no end-to-end pipeline tests from
buffer content to extmarks, and no Neogit-specific integration tests.

## Solution

Adds three new spec files (28 new tests, 316 total):

- `spec/decoration_provider_spec.lua` — indirect cache pipeline tests
via `_test` table: `ensure_cache` population, content fingerprint guard,
`pending_clear` semantics, BufWipeout cleanup
- `spec/integration_spec.lua` — full pipeline: diff buffer → `attach` →
extmarks; verifies `DiffsAdd`/`DiffsDelete` on correct lines, treesitter
captures, multi-hunk coverage
- `spec/neogit_integration_spec.lua` — `neogit_disable_hunk_highlight`
behavior, NeogitStatus/NeogitDiffView attach and cache population,
parser neogit filename patterns

Depends on #133.

Closes #122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use New neogit apis

1 participant