Git diff highlighting are not working anymore in gitcommit filetype

Hello,

I use git commit -v to have the git diff display in the editor when I commit. Until a couple of months ago, the diff was correctly highlighted, but one day, it stops to highlight the diff. Since I run neovim HEAD, I thought this would get fixed after a couple of days / weeks, but it didn’t, and now I’m wondering if something change that I’m supposed to enable to have my diff highlighting work again.

It was working out of the box and I checked the GitHub issue about HEAD breaking change, but I didn’t find anything that could help me. I’ve also asked on IRC, but nobody had any idea, so if you have an idea, let me know.

Works for me:

This is weird, because I’ve tried with the latest stable version of neovim, and it doesn’t work either. I’ll try to play with my config to see what’s going on.

[edit]

I just comment out my treesitter config, and it starts to work again, so I’ll try to find what’s missing there.

[edit2]

Got it, the issue is with the gitcommit treesitter’s parser. I disable it and it works now.

1 Like

You need to install diff and git_rebase parsers as per gitcommit doco

I’ve all the parsers installed, the solution was to bind the treesitter diff elements with the old diff colors in my theme that was not supoorting treesitter diff elements.

vim.cmd [[highlight def link @text.diff.add DiffAdded]]
vim.cmd [[highlight def link @text.diff.delete DiffRemoved]]

I am hitting this as well. It looks like I have to manually define highlights for @diff.minus.diff and @diff.plus.diff. This is not an issue with missing injected languages as Playground clearly shows that the TS parse isn’t errored. It’s something dropping the ball linking the highlights.

1 Like

Hello,

The issue is probably with your theme. After playing around the issue, that was my understanding of the issue.