From 910c21bd09e69837ed76ff802fbf04c9b757efd4 Mon Sep 17 00:00:00 2001
From: Jerome Reybert <jreybert@gmail.com>
Date: Wed, 22 Feb 2017 21:42:44 +0100
Subject: [PATCH] syntax/magit.vim: rework syntax file

simplify some rules, prefer match VS region when possible
(region where misused, as match is enough)
---
 syntax/magit.vim | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/syntax/magit.vim b/syntax/magit.vim
index b438072..b8fe2f1 100644
--- a/syntax/magit.vim
+++ b/syntax/magit.vim
@@ -13,7 +13,8 @@ syn include @diff syntax/diff.vim
 execute 'syn match titleEntry "' . g:magit_section_re . '\n=\+"'
 hi def link titleEntry Comment
 
-execute 'syn match commitMsgExceed "\(=\+\n.\{' . g:magit_commit_title_limit . '}\)\@<=.*$"'
+execute 'syn region commitMsg start=/' . g:magit_sections.commit . '/ end=/\%(' . g:magit_section_re . '\)\@=/ contains=titleEntry'
+execute 'syn match commitMsgExceed "\%(=\+\n\+\_^.\{' . g:magit_commit_title_limit . '}\)\@<=.*$" contained containedin=commitMsg'
 hi def link commitMsgExceed Comment
 
 execute 'syn match stashEntry "' . g:magit_stash_re . '"'
@@ -22,8 +23,6 @@ hi def link stashEntry String
 execute 'syn match fileEntry "' . g:magit_file_re . '"'
 hi def link fileEntry String
 
-execute 'syn region gitTitle start=/^$\n' . g:magit_section_re . '/ end=/^$/ contains=titleEntry,commitMsgExceed'
-
 execute 'syn region gitStash start=/' . g:magit_stash_re . '/ end=/\%(' .
  \ g:magit_stash_re . '\)\@=/ contains=stashEntry fold'
 
@@ -34,23 +33,15 @@ execute 'syn region gitHunk start=/' .
  \ g:magit_hunk_re . '/ end=/\%(' . g:magit_end_diff_re . '\|' . g:magit_hunk_re 
  \ '\)\@=/ contains=@diff fold'
 
-execute 'syn region gitInfo start=/^' . g:magit_sections.info . '$/ end=/' .
- \ g:magit_section_re . '/'
+execute 'syn match gitInfoRepo   "\%(' . g:magit_section_info.cur_repo .    ':\)\@<=.*$" oneline'
+execute 'syn match gitInfoBranch "\%(' . g:magit_section_info.cur_branch .  ':\)\@<=.*$" oneline'
+execute 'syn match gitCommitMode "\%(' . g:magit_section_info.commit_mode . ':\)\@<=.*$" oneline'
+execute 'syn match gitInfoCommit "\%(' . g:magit_section_info.cur_commit .  ':\)\@<=.*$" contains=infoSha1 oneline'
+syntax match infoSha1 containedin=gitInfoCommit "\x\{7}"
 
-execute 'syn region gitInfoRepo start=/^' . g:magit_section_info.cur_repo .
- \ ':\s*.*/hs=s+20 end=/$/ oneline'
 highlight default link gitInfoRepo Directory
-execute 'syn region gitInfoBranch start=/^' . g:magit_section_info.cur_branch .
- \ ':\s*.*/hs=s+20 end=/$/ oneline'
 highlight default link gitInfoBranch Identifier
-execute 'syn region gitCommitMode start=/^' . g:magit_section_info.commit_mode .
- \ ':\s*.*/hs=s+20 end=/$/ oneline'
 highlight default link gitCommitMode Special
-
-execute 'syn region gitInfoCommit start=/^' . g:magit_section_info.cur_commit .
- \ ':\s*\(.*\)/ end=/$/ contains=infoSha1 oneline'
-syntax match infoSha1 containedin=gitInfoCommit "\x\{7}"
 highlight default link infoSha1 Identifier
 
-
 let b:current_syntax = "magit"
-- 
GitLab