I have a terminal color scheme that makes the default highlighting settings for diffs relatively hard to read. To address this, I’ve added my own custom settings inside of ~/.vim/after/syntax/diff.vim:
hi diffAdded term=NONE ctermfg=Green
hi diffRemoved term=NONE ctermfg=Red
This works great for git diff, for example, but the customizations do not apply when I use git commit -v, so I still get unreadable diffs. I looked in the syntax definition for gitcommit.vim, and I noticed that it uses syn include to create a nested region:
" gitcommit.vim
syn include @gitcommitDiff syntax/diff.vim
syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ fold contains=@gitcommitDiff
Since it looks like it just uses diff.vim under the hood, I figured that copying my custom styles to ~/.vim/after/syntax/gitcommit.vim would do the trick:
" identical to diff.vim
hi diffAdded term=NONE ctermfg=Green
hi diffRemoved term=NONE ctermfg=Red
Unfortunately, this doesn’t seem to work—vim still uses the default syntax highlighting.
What’s wrong? How can I customize the syntax highlighting for a region included with syn include?
hi diffAdded term=NONE ctermfg=Greendirectly while editing a commit message doesn’t seem to do anything. – Alexis King Apr 05 '16 at 16:13:echo synIDattr(synID(line('.'), col('.'), 1), 'name')... I tried this withgit commit -vby the way, and it works fine for me ... Not sure why it doesn't for you. You can try following the stepts in How do I debug my vimrc file? – Martin Tournoij Apr 05 '16 at 16:19Greencolor renders differently when I rungit commit -vandgit diff. Anyway, that’s a separate problem, so I will continue to investigate it myself. Sorry for the small XY problem, and thanks for your help! – Alexis King Apr 05 '16 at 16:35