当我正在填写提交消息时,我可以看到文件列表,但它们是相同的颜色(new / modify / del)
我问文件列表突出显示,没有消息突出显示,不重复Configure git commit editor colors的问题
我只能得到标签名称是gitcommitSelectedFile
,如何区分它们?
第一张图片在我的vim中,第二张图片在vs代码中
您可以通过修改gitcommit.vim
进行更改
你可以在gitcommit.vim
dir找到你的syntax/
。
您可以在vim内轻松找到
:echo $VIMRUNTIME
的vim目录。
在gitcommit.vim
里面,你必须找到你想要改变的群体。
在我的环境中,它是gitcommitSelectedType
。这是gitcommitSelectedType匹配 - 它使用\t\@<=[[:lower:]][^:]*[[:lower:]]:
在提交模板中匹配modified:
和new file:
。
syn match gitcommitSelectedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitSelectedFile skipwhite
举个简单的例子,我清除gitcoomitSelectedType
并为gitcommitNew
和gitcommitModified
添加新的匹配。 (例如,简单匹配。您可以使用正则表达式)
syn clear gitcommitSelectedType
" match for new file and modified
syn match gitcommitNew "\t\@<=new file: " contained containedin=gitcommitComment nextgroup=gitcommitSelectedType skipwhite
syn match gitcommitModified "\t\@<=modified: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitModified skipwhite
" give other color type for these group
hi link gitcommitNew Type
hi link gitcommitModified Special
" add two groups we made to gitcommitSelected
syn region gitcommitSelected start=/^# Changes to be committed:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitSelectedType,gitcommitNew,gitcommitModified fold
也许有更好的解决方案 - 不使用组但在gitcommitSelectedType之后使用异常 - 但我不知道如何。也许你可以找到它。
此外,它将在未来添加。检查here