Skip to content

Emit "NeogitDiffLoaded" event#1897

Merged
CKolkey merged 5 commits intomasterfrom
diff-loaded-event
Feb 21, 2026
Merged

Emit "NeogitDiffLoaded" event#1897
CKolkey merged 5 commits intomasterfrom
diff-loaded-event

Conversation

@CKolkey
Copy link
Member

@CKolkey CKolkey commented Feb 15, 2026

  • Add User event NeogitDiffLoaded
  • Expose repo dir as buffer local variable
  • Expose buffer local variable to disable hunk highlighting

@CKolkey CKolkey marked this pull request as ready for review February 21, 2026 21:11
@CKolkey CKolkey merged commit d5af26e into master Feb 21, 2026
5 of 6 checks passed
@CKolkey CKolkey deleted the diff-loaded-event branch February 21, 2026 21:11
barrettruth added a commit to barrettruth/diffs.nvim that referenced this pull request Feb 25, 2026
## 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
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.

1 participant