Skip to content

Commit e7fd13a

Browse files
committed
fix: syntax mismatch in git diff
1 parent edc603d commit e7fd13a

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

syntax/gitmessengerpopup.vim

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ if exists('b:current_syntax')
22
finish
33
endif
44

5-
syn match gitmessengerHeader '^ \=\%(History\|Commit\|\%(Author \|Committer \)\=Date\|Author\|Committer\):' display
6-
syn match gitmessengerHash '\%(^ \=Commit: \+\)\@<=[[:xdigit:]]\+' display
7-
syn match gitmessengerHistory '\%(^ \=History: \+\)\@<=#\d\+' display
8-
syn match gitmessengerEmail '\%(^ \=\%(Author\|Committer\): \+.*\)\@<=<.\+>' display
5+
if g:git_messenger_popup_content_margins
6+
let margin_pat = '^ '
7+
else
8+
let margin_pat = '^'
9+
endif
10+
11+
syn sync fromstart
12+
13+
exe 'syn match gitmessengerHeader "' . margin_pat . '\%(History\|Commit\|\%(Author \|Committer \)\=Date\|Author\|Committer\):" display'
14+
exe 'syn match gitmessengerHash "\%(' . margin_pat . 'Commit: \+\)\@<=[[:xdigit:]]\+" display'
15+
exe 'syn match gitmessengerHistory "\%(' . margin_pat . 'History: \+\)\@<=#\d\+" display'
16+
exe 'syn match gitmessengerEmail "\%(' . margin_pat . '\%(Author\|Committer\): \+.*\)\@<=<.\+>" display'
917

1018
" Diff included in popup
1119
" There are two types of diff format; 'none' 'current', 'all', 'current.word', 'all.word'.
@@ -21,15 +29,17 @@ if get(b:, '__gitmessenger_diff', '') =~# '\.word$'
2129
syn region diffWordsAdded start=/{+/ end=/+}/ oneline
2230
endif
2331
else
24-
syn match diffRemoved "^ \=-.*" display
25-
syn match diffAdded "^ \=+.*" display
32+
exe 'syn match diffRemoved "' . margin_pat . '-.*" contained containedin=gitDiff display'
33+
exe 'syn match diffAdded "' . margin_pat . '+.*" contained containedin=gitDiff display'
2634
endif
2735

28-
syn match diffFile "^ \=diff --git .*" display
29-
syn match diffOldFile "^ \=--- a\>.*" display
30-
syn match diffNewFile "^ \=+++ b\>.*" display
31-
syn match diffIndexLine "^ \=index \x\{7,}\.\.\x\{7,}.*" display
32-
syn match diffLine "^ \=@@ .*" display
36+
exe 'syn match diffFile "' . margin_pat . 'diff --git .*" display'
37+
exe 'syn match diffOldFile "' . margin_pat . '--- \(a\>.*\|/dev/null\)" display'
38+
exe 'syn match diffNewFile "' . margin_pat . '+++ \(b\>.*\|/dev/null\)" display'
39+
exe 'syn match diffIndexLine "' . margin_pat . 'index \x\{7,}\.\.\x\{7,}.*" display'
40+
exe 'syn match diffLine "' . margin_pat . '@@ .*" contained containedin=gitDiff display'
41+
42+
exec 'syn region gitDiff start=/' .. margin_pat . '\%(@@ -\)\@=/ end=/' . margin_pat . '\%(diff --git \|$\)\@=/ contains=diffRemoved,diffAdded,diffLine'
3343

3444
hi def link gitmessengerHeader Identifier
3545
hi def link gitmessengerHash Comment

0 commit comments

Comments
 (0)