Skip to content

Commit

Permalink
Show refs in log in Gstatus
Browse files Browse the repository at this point in the history
Display refs (the output of %D from git log's format=pretty) next
to commit summaries in Gstatus.

Use basic syntax highlighting for all refs. Use digraphs to reduce the
possibility of false positives when syntax highlighting.
  • Loading branch information
Gelio committed Mar 24, 2021
1 parent 857496c commit 0b70bb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions autoload/fugitive.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1701,14 +1701,14 @@ function! s:ReplaceCmd(cmd) abort
endfunction

function! s:QueryLog(refspec) abort
let lines = s:LinesError(['log', '-n', '256', '--pretty=format:%h%x09%s', a:refspec, '--'])[0]
let lines = s:LinesError(['log', '-n', '256', '--pretty=format:%h%x09%s%x09%D', a:refspec, '--'])[0]
call map(lines, 'split(v:val, "\t")')
call map(lines, '{"type": "Log", "commit": v:val[0], "subject": v:val[-1]}')
call map(lines, '{"type": "Log", "commit": v:val[0], "subject": v:val[1], "ref": get(v:val, 2, "")}')
return lines
endfunction

function! s:FormatLog(dict) abort
return a:dict.commit . ' ' . a:dict.subject
return a:dict.commit . ' ' . a:dict.subject .. ((len(a:dict.ref) > 0) ? (' «' . a:dict.ref . '»') : '')
endfunction

function! s:FormatRebase(dict) abort
Expand Down
2 changes: 2 additions & 0 deletions syntax/fugitive.vim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ syn match fugitiveModifier /^[MADRCU?]\{1,2} / contained containedin=@fugitiveSe
syn match fugitiveSymbolicRef /\.\@!\%(\.\.\@!\|[^[:space:][:cntrl:]\:.]\)\+\.\@<!/ contained
syn match fugitiveHash /^\x\{4,\}\S\@!/ contained containedin=@fugitiveSection
syn match fugitiveHash /\S\@<!\x\{4,\}\S\@!/ contained
syn match fugitiveRefs /«[^»]\+»/hs=s+1,he=e-1 contained containedin=@fugitiveSection

syn region fugitiveHunk start=/^\%(@@\+ -\)\@=/ end=/^\%([A-Za-z?@]\|$\)\@=/ contains=@fugitiveDiff containedin=@fugitiveSection fold

Expand All @@ -51,6 +52,7 @@ hi def link fugitiveStagedModifier Typedef
hi def link fugitiveInstruction Type
hi def link fugitiveStop Function
hi def link fugitiveHash Identifier
hi def link fugitiveRefs Function
hi def link fugitiveSymbolicRef Function
hi def link fugitiveCount Number

Expand Down

0 comments on commit 0b70bb3

Please sign in to comment.