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

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
This commit is contained in:
Barrett Ruth 2026-02-25 10:22:33 -05:00
parent 700a9a21ad
commit 4e11858c6e
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
2 changed files with 27 additions and 35 deletions

View file

@ -110,6 +110,11 @@ local function get_repo_root(bufnr)
return vim.fn.fnamemodify(git_dir, ':h')
end
local ok3, neogit_git_dir = pcall(vim.api.nvim_buf_get_var, bufnr, 'neogit_git_dir')
if ok3 and neogit_git_dir then
return vim.fn.fnamemodify(neogit_git_dir, ':h')
end
local cwd = vim.fn.getcwd()
local git = require('diffs.git')
return git.get_repo_root(cwd .. '/.')