Conversation
Problem: diffs.nvim only activates on fugitive/git/gitcommit filetypes. Neogit uses its own filetypes (NeogitStatus, NeogitCommitView, NeogitDiffView) and doesn't set b:git_dir, so the plugin never attaches and repo root resolution fails. Solution: add the three Neogit filetypes to the default filetypes list, and add a cwd-based fallback in get_repo_root() that uses git.get_repo_root() when neither b:diffs_repo_root nor b:git_dir are set.
|
lmk if there's anything that I could add to neogit that would make your life easier here :) |
Problem: Neogit's line_hl_group extmarks define foreground colors that
override diffs.nvim's treesitter hl_group syntax regardless of priority,
making syntax invisible on +/- lines.
Solution: on first Neogit buffer attach, set all 17 Neogit diff line
highlight groups to {} (empty) so diffs.nvim has sole control. Reapply
on ColorScheme since Neogit re-defines its groups then.
Problem: line backgrounds used hl_group with hl_eol, which only covers the text area. Neogit buffers have a sign column that remains uncolored, creating a visual gap. Also required two separate extmark calls for background and gutter. Solution: use line_hl_group instead, which covers text, sign, number, and fold columns. Merge gutter number_hl_group into the same extmark. Safe for fugitive since DiffsAdd/DiffsDelete define only bg (no fg).
Problem: Neogit untracked file diffs show a bare filename (e.g. "newfile.rs") with no status prefix before the @@ header. The parser did not recognize this pattern. Solution: add a bare filename match for lines with no whitespace and at least one dot, guarded by not being inside a hunk.
Problem: disabling a single integration (fugitive or neogit) required redefining the entire filetypes list and knowing all defaults. Solution: add fugitive.enabled, neogit.enabled, and extra_filetypes config keys. compute_filetypes() builds the filetype list from these toggles at load time. The old filetypes key still works but emits a vim.deprecate warning (removed in 0.3.0). Boolean shorthands (fugitive = false, neogit = false) are normalized to tables before validation.
Problem: config docs referenced the removed filetypes list and lacked
documentation for the new fugitive/neogit/extra_filetypes keys.
Solution: replace {filetypes} field docs with {fugitive}, {neogit},
and {extra_filetypes}. Document fugitive.enabled in FugitiveConfig.
Update neogit section with disable example and deprecation note.
Problem: enabling integrations by default couples diffs.nvim to plugins the user may not have installed. Solution: set fugitive.enabled and neogit.enabled to false in default_config. compute_filetypes now treats nil as disabled (opt-in). Users enable integrations explicitly with fugitive = true or neogit = true.
Problem: the filetypes key was kept as a deprecated fallback with a vim.deprecate warning targeting 0.3.0. No reason to keep it around. Solution: remove filetypes support entirely from compute_filetypes, init normalization, and type annotations. Drop deprecation note from docs.
Problem: the filetypes key was fully removed, but a proper deprecation period is preferable. Solution: restore filetypes fallback in compute_filetypes and emit a vim.deprecate warning in init(). The old key still works but will be removed in v0.3.0 (#118).
|
actually @CKolkey there may be. or there may not be, depending on what you deem is best. Some context: The only way for me to do this with neogit is to disable a list of hard-coded neogit HL groups. The end product looks pretty cool (note that my colorscheme is not optimized for neogit since I, well, don't use it):
Potential asks include:
Happy to discuss this further and formalize this into issues on neogit itself if you like. If I end up merging this pr and closing it please respond here and just @ me. |
|
@barrettruth Your biggest ask was, I think, the easiest. Something like this? NeogitOrg/neogit#1897 edit: Turns out it was all pretty easy. Let me know if it's right or if it needs some tweaking. |

TODO
Problem
diffs.nvim only activates on
fugitive,git, andgitcommitfiletypes.Neogit uses its own custom filetypes (
NeogitStatus,NeogitCommitView,NeogitDiffView) and doesn't setb:git_dir, so the plugin never attachesand repo root resolution fails for filetype detection within diff hunks.
Solution
Two changes:
lua/diffs/init.lua— Add the three Neogit filetypes to the defaultfiletypeslist. TheFileTypeautocmd inplugin/diffs.luaalreadyhandles them correctly since the
is_fugitive_bufferguard only appliesto the
gitfiletype.lua/diffs/parser.lua— Add a CWD-based fallback inget_repo_root().After the existing
b:diffs_repo_rootandb:git_dirchecks, fall back tovim.fn.getcwd()viagit.get_repo_root()(already cached). Without this,the parser can't resolve filetypes for files in Neogit buffers.
Neogit's expanded diffs use standard unified diff format, so the parser handles
them without modification.
Closes #110.