From 4ec18dcc542c207d249e5c190c76521a9d412640 Mon Sep 17 00:00:00 2001 From: Nate Fischer Date: Wed, 18 Nov 2015 01:50:44 -0800 Subject: [PATCH] Adding syntax highlighting for normal log files --- autoload/vundle/scripts.vim | 3 +- ftplugin/vundlechangelog.vim | 15 ++++++++++ ftplugin/vundlelog.vim | 3 +- syntax/vundlechangelog.vim | 36 ++++++++++++++++++++++ syntax/vundlelog.vim | 58 ++++++++++++++++++++---------------- 5 files changed, 86 insertions(+), 29 deletions(-) create mode 100644 ftplugin/vundlechangelog.vim create mode 100644 syntax/vundlechangelog.vim diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index f789762f..01421dfb 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -67,6 +67,7 @@ func! s:view_log() setl buftype=nofile setl noswapfile setl ro noma + setfiletype vundlelog wincmd P | wincmd H endf @@ -124,7 +125,7 @@ func! s:view_changelog() setl buftype=nofile setl noswapfile setl ro noma - setfiletype vundlelog + setfiletype vundlechangelog wincmd P | wincmd H endf diff --git a/ftplugin/vundlechangelog.vim b/ftplugin/vundlechangelog.vim new file mode 100644 index 00000000..0f338eb8 --- /dev/null +++ b/ftplugin/vundlechangelog.vim @@ -0,0 +1,15 @@ +" --------------------------------------------------------------------------- +" Standard ftplugin boilerplate; see ':help ftplugin'. +" --------------------------------------------------------------------------- +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + + +" --------------------------------------------------------------------------- +" Settings for the Vundle update log buffer. +" --------------------------------------------------------------------------- +setlocal textwidth=0 +setlocal nowrap +setlocal noswapfile diff --git a/ftplugin/vundlelog.vim b/ftplugin/vundlelog.vim index 0f338eb8..d7cd95ed 100644 --- a/ftplugin/vundlelog.vim +++ b/ftplugin/vundlelog.vim @@ -8,8 +8,7 @@ let b:did_ftplugin = 1 " --------------------------------------------------------------------------- -" Settings for the Vundle update log buffer. +" Settings for the Vundle log buffer. " --------------------------------------------------------------------------- setlocal textwidth=0 -setlocal nowrap setlocal noswapfile diff --git a/syntax/vundlechangelog.vim b/syntax/vundlechangelog.vim new file mode 100644 index 00000000..64e81e32 --- /dev/null +++ b/syntax/vundlechangelog.vim @@ -0,0 +1,36 @@ +" --------------------------------------------------------------------------- +" Syntax highlighting for the line which identifies the plugin. +" --------------------------------------------------------------------------- +syntax match VundlePluginName '\v(^Updated Plugin: )@<=.*$' +highlight link VundlePluginName Keyword + +" --------------------------------------------------------------------------- +" Syntax highlighting for the 'compare at' line of each plugin. +" --------------------------------------------------------------------------- +syntax region VundleCompareLine start='\v^Compare at: https:' end='\v\n' + \ contains=VundleCompareUrl +syntax match VundleCompareUrl '\vhttps:\S+' +highlight link VundleCompareLine Comment +highlight link VundleCompareUrl Underlined + +" --------------------------------------------------------------------------- +" Syntax highlighting for individual commits. +" --------------------------------------------------------------------------- +" The main commit line. +" Note that this regex is intimately related to the one for VundleCommitTree, +" and the two should be changed in sync. +syntax match VundleCommitLine '\v(^ [|*]( *[\\|/\*])* )@<=[^*|].*$' + \ contains=VundleCommitMerge,VundleCommitUser,VundleCommitTime +highlight link VundleCommitLine String +" Sub-regions inside the commit message. +syntax match VundleCommitMerge '\v Merge pull request #\d+.*' +syntax match VundleCommitUser '\v( )@<=\S+( \S+)*(, \d+ \w+ ago$)@=' +syntax match VundleCommitTime '\v(, )@<=\d+ \w+ ago$' +highlight link VundleCommitMerge Ignore +highlight link VundleCommitUser Identifier +highlight link VundleCommitTime Comment +" The git history DAG markers are outside of the main commit line region. +" Note that this regex is intimately related to the one for VundleCommitLine, +" and the two should be changed in sync. +syntax match VundleCommitTree '\v(^ )@<=[|*]( *[\\|/\*])*' +highlight link VundleCommitTree Label diff --git a/syntax/vundlelog.vim b/syntax/vundlelog.vim index 64e81e32..a7f4f410 100644 --- a/syntax/vundlelog.vim +++ b/syntax/vundlelog.vim @@ -1,36 +1,42 @@ " --------------------------------------------------------------------------- " Syntax highlighting for the line which identifies the plugin. " --------------------------------------------------------------------------- -syntax match VundlePluginName '\v(^Updated Plugin: )@<=.*$' +syntax match VundlePluginName '\v\C(Plugin )@<=\S+/\S+(\s|$)' highlight link VundlePluginName Keyword " --------------------------------------------------------------------------- -" Syntax highlighting for the 'compare at' line of each plugin. +" Syntax highlighting for diffs on each plugin " --------------------------------------------------------------------------- -syntax region VundleCompareLine start='\v^Compare at: https:' end='\v\n' - \ contains=VundleCompareUrl -syntax match VundleCompareUrl '\vhttps:\S+' -highlight link VundleCompareLine Comment -highlight link VundleCompareUrl Underlined +syntax match VundleGitAddition '\v(\|\s*\d+ )@<=\++' +highlight VundleGitAddition guifg=darkgreen guibg=NONE gui=bold + \ ctermfg=darkgreen ctermbg=NONE cterm=bold + +syntax match VundleGitDeletion '\v(\|\s*\d+ \+*)@<=-+' +highlight VundleGitDeletion guifg=red guibg=NONE gui=bold ctermfg=red + \ ctermbg=NONE cterm=bold " --------------------------------------------------------------------------- -" Syntax highlighting for individual commits. +" Syntax highlighting for log-specific features " --------------------------------------------------------------------------- -" The main commit line. -" Note that this regex is intimately related to the one for VundleCommitTree, -" and the two should be changed in sync. -syntax match VundleCommitLine '\v(^ [|*]( *[\\|/\*])* )@<=[^*|].*$' - \ contains=VundleCommitMerge,VundleCommitUser,VundleCommitTime -highlight link VundleCommitLine String -" Sub-regions inside the commit message. -syntax match VundleCommitMerge '\v Merge pull request #\d+.*' -syntax match VundleCommitUser '\v( )@<=\S+( \S+)*(, \d+ \w+ ago$)@=' -syntax match VundleCommitTime '\v(, )@<=\d+ \w+ ago$' -highlight link VundleCommitMerge Ignore -highlight link VundleCommitUser Identifier -highlight link VundleCommitTime Comment -" The git history DAG markers are outside of the main commit line region. -" Note that this regex is intimately related to the one for VundleCommitLine, -" and the two should be changed in sync. -syntax match VundleCommitTree '\v(^ )@<=[|*]( *[\\|/\*])*' -highlight link VundleCommitTree Label +syntax match VundleCaret '\V >' +highlight link VundleCaret Label + +" Make path to tags file stand out +syntax match VundleTagPath '\v\C(:helptags )@<=/\S+$' +highlight link VundleTagPath Comment + +" Make URL stand out +syntax match VundleCompareUrl '\v\Chttps:\S+' +highlight link VundleCompareUrl Underlined + +" Make errors (from git) stand out +syntax match VundleError '\v\C( \> )@<=fatal:.*$' +highlight link VundleError Error + +" Make git messages stand out +syntax match VundleGitMsg '\v\C( \> )@<=git:.*$' +highlight link VundleGitMsg Type + +" De-emphasize the time stamp +syntax match VundleTimeStamp '\m^\[\d\{4}-\d\{2}-\d\{2} \d\{2}:\d\{2}:\d\{2}]' +highlight link VundleTimeStamp String