pretty colouring and folding for message show
authorBart Trojanowski <bart@jukie.net>
Fri, 20 Nov 2009 06:15:00 +0000 (01:15 -0500)
committerBart Trojanowski <bart@jukie.net>
Wed, 25 Nov 2009 05:48:50 +0000 (00:48 -0500)
vim/plugin/notmuch.vim
vim/syntax/notmuch-show.vim

index d77237811667e618172b1d1272b1403eb378e392..6e1f8b14a8ed7a8f1b25df1c5d52db3aef7810a7 100644 (file)
@@ -301,6 +301,21 @@ function! s:NM_cmd_show_mkfolds()
         endfor
 endfunction
 
+function! s:NM_cmd_show_mksyntax()
+        let info = b:nm_raw_info
+        let cnt = 0
+        for msg in info['msgs']
+                let cnt = cnt + 1
+                let start = msg['start']
+                let hdr_start = msg['hdr_start']
+                let body_start = msg['body_start']
+                let end = msg['end']
+                exec printf('syntax region nmShowMsg%dDesc start=''\%%%dl'' end=''\%%%dl'' contains=@nmShowMsgDesc', cnt, start, start+1)
+                exec printf('syntax region nmShowMsg%dHead start=''\%%%dl'' end=''\%%%dl'' contains=@nmShowMsgHead', cnt, hdr_start, body_start)
+                exec printf('syntax region nmShowMsg%dBody start=''\%%%dl'' end=''\%%%dl'' contains=@nmShowMsgBody', cnt, body_start, end)
+        endfor
+endfunction
+
 function! NM_cmd_show_foldtext()
         let foldtext = b:nm_raw_info['foldtext']
         return foldtext[v:foldstart]
index 02e12e997141c30762ee8f4ac080334e47bc8022..20c6b88feaa4a172c7f0b980126e013ba5de8685 100644 (file)
@@ -1,20 +1,23 @@
 " notmuch show mode syntax file
 
-syntax region nmShowMessage    start='\fmessage{'    end='\fmessage}'    contains=nmBlockStart,nmShowHeader,nmShowBody,nmShowAttachment,nmShowPart,nmBlockEnd
-syntax region nmShowHeader     start='\fheader{'     end='\fheader}'     contained contains=nmBlockStart,nmBlockEnd
-syntax region nmShowBody       start='\fbody{'       end='\fbody}'       contained contains=nmBlockStart,nmShowAttachment,nmShowPart,nmBlockEnd
-syntax region nmShowAttachment start='\fattachment{' end='\fattachment}' contained contains=nmBlockStart,nmBlockEnd
-syntax region nmShowPart       start='\fpart{'       end='\fpart}'       contained contains=nmBlockStart,nmBlockEnd
+syntax cluster nmShowMsgDesc contains=nmShowMsgDescWho,nmShowMsgDescDate,nmShowMsgDescTags
+syntax match   nmShowMsgDescWho /[^)]\+)/ contained
+syntax match   nmShowMsgDescDate / ([^)]\+[0-9]) / contained
+syntax match   nmShowMsgDescTags /([^)]\+)$/ contained
 
-syntax region nmBlockStart     start='^\f[a-z]\+{'    end='$'            oneline
-syntax region nmBlockEnd       start='^\f[a-z]\+}'    end='$'            oneline
+syntax cluster nmShowMsgHead contains=nmShowMsgHeadKey,nmShowMsgHeadVal
+syntax match   nmShowMsgHeadKey /^[^:]\+: / contained
+syntax match   nmShowMsgHeadVal /^\([^:]\+: \)\@<=.*/ contained
 
-highlight link nmShowMessage    Error
-highlight link nmShowHeader     Type
-highlight link nmShowBody       Statement
-highlight link nmShowAttachment Statement
-highlight link nmShowPart       String
-highlight link nmBlockStart     Ignore
-highlight link nmBlockEnd       Ignore
+syntax cluster nmShowMsgBody contains=@nmShowMsgBodyMail,@nmShowMsgBodyGit
+syntax include @nmShowMsgBodyMail syntax/mail.vim
+syntax include @nmShowMsgBodyGit syntax/git-diff.vim
+
+highlight nmShowMsgDescWho term=reverse cterm=reverse gui=reverse
+highlight link nmShowMsgDescDate Type
+highlight link nmShowMsgDescTags String
+
+highlight link nmShowMsgHeadKey  Macro
+"highlight link nmShowMsgHeadVal  NONE
 
 highlight Folded term=reverse ctermfg=LightGrey ctermbg=Black guifg=LightGray guibg=Black