Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions syntax/gitmessengerpopup.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ if exists('b:current_syntax')
finish
endif

syn match gitmessengerHeader '^ \=\%(History\|Commit\|\%(Author \|Committer \)\=Date\|Author\|Committer\):' display
syn match gitmessengerHash '\%(^ \=Commit: \+\)\@<=[[:xdigit:]]\+' display
syn match gitmessengerHistory '\%(^ \=History: \+\)\@<=#\d\+' display
syn match gitmessengerEmail '\%(^ \=\%(Author\|Committer\): \+.*\)\@<=<.\+>' display
if get(g:, 'git_messenger_popup_content_margins', v:true)
let s:margin_pat = '^ '
else
let s:margin_pat = '^'
endif

exe 'syn sync minlines=' . &lines

exe 'syn match gitmessengerHeader "' . s:margin_pat . '\%(History\|Commit\|\%(Author \|Committer \)\=Date\|Author\|Committer\):" display'
exe 'syn match gitmessengerHash "\%(' . s:margin_pat . 'Commit: \+\)\@<=[[:xdigit:]]\+" display'
exe 'syn match gitmessengerHistory "\%(' . s:margin_pat . 'History: \+\)\@<=#\d\+" display'
exe 'syn match gitmessengerEmail "\%(' . s:margin_pat . '\%(Author\|Committer\): \+.*\)\@<=<.\+>" display'

" Diff included in popup
" There are two types of diff format; 'none' 'current', 'all', 'current.word', 'all.word'.
Expand All @@ -14,22 +22,24 @@ syn match gitmessengerEmail '\%(^ \=\%(Author\|Committer\): \+.*\)\@<=<.\+>' dis
" b:__gitmessenger_diff is set by Blame.render() in blame.vim.
if get(b:, '__gitmessenger_diff', '') =~# '\.word$'
if has('conceal') && get(g:, 'git_messenger_conceal_word_diff_marker', v:true)
syn region diffWordsRemoved matchgroup=Conceal start=/\[-/ end=/-]/ concealends oneline
syn region diffWordsAdded matchgroup=Conceal start=/{+/ end=/+}/ concealends oneline
syn region diffWordsRemoved matchgroup=Conceal start=/\[-/ end=/-]/ concealends oneline contained containedin=gitDiff
syn region diffWordsAdded matchgroup=Conceal start=/{+/ end=/+}/ concealends oneline contained containedin=gitDiff
else
syn region diffWordsRemoved start=/\[-/ end=/-]/ oneline
syn region diffWordsAdded start=/{+/ end=/+}/ oneline
syn region diffWordsRemoved start=/\[-/ end=/-]/ oneline contained containedin=gitDiff
syn region diffWordsAdded start=/{+/ end=/+}/ oneline contained containedin=gitDiff
endif
else
syn match diffRemoved "^ \=-.*" display
syn match diffAdded "^ \=+.*" display
exe 'syn match diffRemoved "' . s:margin_pat . '-.*" contained containedin=gitDiff display'
exe 'syn match diffAdded "' . s:margin_pat . '+.*" contained containedin=gitDiff display'
endif

syn match diffFile "^ \=diff --git .*" display
syn match diffOldFile "^ \=--- a\>.*" display
syn match diffNewFile "^ \=+++ b\>.*" display
syn match diffIndexLine "^ \=index \x\{7,}\.\.\x\{7,}.*" display
syn match diffLine "^ \=@@ .*" display
exe 'syn match diffFile "' . s:margin_pat . 'diff --git .*" display'
exe 'syn match diffOldFile "' . s:margin_pat . '--- \(a\>.*\|/dev/null\)" display'
exe 'syn match diffNewFile "' . s:margin_pat . '+++ \(b\>.*\|/dev/null\)" display'
exe 'syn match diffIndexLine "' . s:margin_pat . 'index \x\{7,}\.\.\x\{7,}.*" display'
exe 'syn match diffLine "' . s:margin_pat . '@@ .*" contained containedin=gitDiff display'

exec 'syn region gitDiff start=/' . s:margin_pat . '\%(@@ -\)\@=/ end=/' . s:margin_pat . '\%(diff --git\)\@=/ contains=diffRemoved,diffAdded,diffLine,diffWordsRemoved,diffWordsAdded'

hi def link gitmessengerHeader Identifier
hi def link gitmessengerHash Comment
Expand Down
Loading