Skip to content

[Feature Request] Git Log (and Log Graph) Branch Name Highlighting #78

Closed
@KSR-Yasuda

Description

@KSR-Yasuda

Couldn't you highlight branch name in git log --decorate and git log --decorate --graph?

In --all mode, highlighting would be strongly expected to find branches easily.

LogGraph_BranchRefName_Highlight


I started the first step with the diff below,
however, by my poor vim-syntax knowledge,
I couldn't avoid the false positive that contains () in commit message...

--- a/syntax/git.vim
+++ b/syntax/git.vim
@@ -18,8 +18,10 @@ syn region gitHead start=/\%(^commit\%( \x\{4,\}\)\{1,\}\%(\s*(.*)\)\=$\)\@=/ en
 " minimize false positives by verifying contents of buffer
 if getline(1) =~# '^\x\{7,\} ' && getline('$') =~# '^\x\{7,\} '
   syn match gitHashAbbrev /^\x\{7,\} \@=/ contains=@NoSpell
+  syn match gitHashRef    /(.\{-})/ contains=@NoSpell
 elseif getline(1) =~#     '^[|\/\\_ ]\{-\}\*[|\/\\_ ]\{-\} \x\{7,\} '
   syn match gitHashAbbrev /^[|\/\\_ ]\{-\}\*[|\/\\_ ]\{-\} \zs\x\{7,\} \@=/ contains=@NoSpell
+  syn match gitHashRef    /(.\{-})/ contains=@NoSpell
 endif
 " git log --graph
 syn region gitGraph start=/\%(^[|\/\\_ ]*\*[|\/\\_ ]\{-\} commit\%( \x\{4,\}\)\{1,\}\%(\s*(.*)\)\=$\)\@=/ end=/^\%([|\/\\_ ]*$\)\@=/ contains=@NoSpell
@@ -74,12 +76,13 @@ syn match  gitDate      /-\=\d\+ [+-]\d\d\d\d\>/               contained
 syn match  gitDate      /\<\d\+ \l\+ ago\>/                    contained
 syn match  gitType      /\<\%(tag\|commit\|tree\|blob\)\>/     contained nextgroup=gitHashAbbrev skipwhite
 syn match  gitReference /\S\+\S\@!/                            contained
-syn match  gitHash      /\<\x\{40,\}\>/             contained nextgroup=gitIdentity,gitHash skipwhite contains=@NoSpell
+syn match  gitHash      /\<\x\{40,\}\>/             contained nextgroup=gitIdentity,gitHash,gitHashRef skipwhite contains=@NoSpell
 syn match  gitReflogOld /^\x\{40,\} \@=/            contained nextgroup=gitReflogNew skipwhite contains=@NoSpell
 syn match  gitReflogNew /\<\x\{40,\} \@=/           contained nextgroup=gitIdentity skipwhite contains=@NoSpell
-syn match  gitHashAbbrev /\<\x\{4,\}\>/             contained nextgroup=gitHashAbbrev skipwhite contains=@NoSpell
-syn match  gitHashAbbrev /\<\x\{4,39\}\.\.\./he=e-3 contained nextgroup=gitHashAbbrev skipwhite contains=@NoSpell
+syn match  gitHashAbbrev /\<\x\{4,\}\>/             contained nextgroup=gitHashAbbrev,gitHashRef skipwhite contains=@NoSpell
+syn match  gitHashAbbrev /\<\x\{4,39\}\.\.\./he=e-3 contained nextgroup=gitHashAbbrev,gitHashRef skipwhite contains=@NoSpell
 syn match  gitHashStage /\<\x\{4,\}\>/              contained nextgroup=gitStage skipwhite contains=@NoSpell
+syn match  gitHashRef /(.\{-})/                     contained skipwhite contains=@NoSpell
 syn match  gitStage     /\<\d\t\@=/                 contained
 
 
@@ -98,6 +101,7 @@ hi def link gitDate              Number
 hi def link gitMode              Number
 hi def link gitHashStage         gitHash
 hi def link gitHashAbbrev        gitHash
+hi def link gitHashRef           gitIdentityKeyword
 hi def link gitReflogOld         gitHash
 hi def link gitReflogNew         gitHash
 hi def link gitHash              Identifier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions