--- /dev/null
+To syntax highlight StGit commit messages in vim:
+
+ * For the current user only:
+ > mkdir -p ~/.vim/ftdetect ~/.vim/syntax
+ > cp syntax/*.vim ~/.vim/syntax/
+ > cp ftdetect/*.vim ~/.vim/ftdetect/
+
+ * For all users:
+ # cp syntax/*.vim /usr/share/vim/site/syntax/
+ # cp ftdetect/*.vim /usr/share/vim/site/ftdetect/
--- /dev/null
+" Vim filetype detection plugin
+" Language: StGit commit messages
+" Author: Zane Bitter <zane.bitter@alliedtelesis.co.nz>
+
+
+if has("autocmd")
+
+ " Detect 'stg new' files
+ autocmd BufNewFile,BufRead .stgit-new.txt setf stgnew
+ autocmd BufNewFile,BufRead .stgitmsg.txt setf stgnew
+ " Ignore the modeline so we get type 'stgnew' instead of 'diff'
+ autocmd BufNewFile,BufRead .stgitmsg.txt setlocal nomodeline
+
+ " Detect 'stg edit' files
+ autocmd BufNewFile,BufRead .stgit-edit.txt setf stgedit
+ " Use set filetype instead of setfiletype to override detection as patch
+ autocmd BufNewFile,BufRead .stgit-edit.patch setlocal filetype=stgedit
+ autocmd BufNewFile,BufRead .stgit-edit.diff setlocal filetype=stgedit
+ autocmd BufNewFile,BufRead .stgit-failed.patch setlocal filetype=stgedit
+
+ " Detect 'stg squash' files
+ autocmd BufNewFile,BufRead .stgit-squash.txt setf stgsquash
+
+ " Detect 'stg mail' files
+ autocmd BufNewFile,BufRead .stgitmail.txt setf stgmail
+
+
+ " A modeline in a diff belongs to the diffed file, so ignore it
+ autocmd BufNewFile,BufRead .stgit-edit.patch setlocal nomodeline
+ autocmd BufNewFile,BufRead .stgit-edit.diff setlocal nomodeline
+ autocmd BufNewFile,BufRead .stgit-failed.patch setlocal nomodeline
+ autocmd BufNewFile,BufRead .stgitmail.txt setlocal nomodeline
+
+
+ " Set parameters on 'stg new' files to be consistent with the modeline
+ autocmd FileType stgnew setlocal textwidth=75
+ autocmd FileType stgnew setlocal nobackup
+
+ " For other stg files set textwidth the same as 'stg new'
+ autocmd FileType stgedit setlocal textwidth=75
+ autocmd FileType stgmail setlocal textwidth=75
+ autocmd FileType stgsquash setlocal textwidth=75
+
+endif " has("autocmd")
--- /dev/null
+" Vim syntax file
+" Language: StGit 'stg edit' commit message file
+" Author: Zane Bitter <zane.bitter@alliedtelesis.co.nz>
+
+if exists("b:current_syntax")
+ finish
+endif
+
+
+runtime! syntax/mail.vim
+unlet b:current_syntax
+
+syn include @stgDiff syntax/diff.vim
+
+
+syn case match
+syn sync minlines=50
+
+
+if has("spell")
+ syn spell toplevel
+endif
+
+
+syn match stgeditFrom "\%^From:.*" contains=mailHeader nextgroup=stgeditFirstLine skipempty
+syn match stgeditFirstLine "^.\+" contained nextgroup=stgeditDiffs,stgeditComment,stgeditBlank skipnl
+syn match stgeditSummary "^.\{0,50\}" contained containedin=stgeditFirstLine nextgroup=stgeditOverflow contains=@Spell
+syn match stgeditOverflow ".*" contained contains=@Spell
+syn match stgeditBlank "^.\+" contained contains=@Spell
+syn match stgeditComment "^#.*"
+syn region stgeditDiffs start="^---" end="%$" contains=@stgDiff fold
+syn region stgeditDiff start="^\%(diff --git \)\@=" end="^\%(diff --git \|$\)\@=" contained containedin=stgeditDiffs contains=@stgDiff fold
+
+hi def link stgeditSummary Keyword
+hi def link stgeditComment Comment
+hi def link stgeditBlank Error
+
+
+let b:current_syntax = "stgedit"
--- /dev/null
+" Vim syntax file
+" Language: StGit 'stg mail' file
+" Author: Zane Bitter <zane.bitter@alliedtelesis.co.nz>
+
+if exists("b:current_syntax")
+ finish
+endif
+
+
+runtime! syntax/mail.vim
+unlet b:current_syntax
+
+syn include @stgDiff syntax/diff.vim
+
+
+syn case match
+syn sync minlines=50
+
+
+if has("spell")
+ syn spell toplevel
+endif
+
+
+syn match stgmailComment "^#.*"
+syn region stgmailDiffs start="^---" end="%$" contains=@stgDiff fold
+syn region stgmailDiff start="^\%(diff --git \)\@=" end="^\%(diff --git \|$\)\@=" contained containedin=stgmailDiffs contains=@stgDiff fold
+
+hi def link stgmailComment Comment
+
+
+let b:current_syntax = "stgmail"
--- /dev/null
+" Vim syntax file
+" Language: StGit 'stg new' commit message file
+" Author: Zane Bitter <zane.bitter@alliedtelesis.co.nz>
+
+if exists("b:current_syntax")
+ finish
+endif
+
+
+syn case match
+syn sync minlines=50
+
+
+if has("spell")
+ syn spell toplevel
+endif
+
+
+syn match stgnewFirstLine "\%^.*" nextgroup=stgnewSTG,stgnewComment,stgnewBlank skipnl
+syn match stgnewSummary "^.\{0,50\}" contained containedin=stgnewFirstLine nextgroup=stgnewOverflow contains=@Spell
+syn match stgnewOverflow ".*" contained contains=@Spell
+syn match stgnewBlank "^.\+" contained contains=@Spell
+syn match stgnewSTG "^STG:.*"
+syn match stgnewComment "^#.*"
+
+hi def link stgnewSummary Keyword
+hi def link stgnewComment Comment
+hi def link stgnewSTG Comment
+hi def link stgnewBlank Error
+
+
+let b:current_syntax = "stgnew"
--- /dev/null
+" Vim syntax file
+" Language: StGit 'stg squash' commit message file
+" Author: Zane Bitter <zane.bitter@alliedtelesis.co.nz>
+
+if exists("b:current_syntax")
+ finish
+endif
+
+
+syn case match
+syn sync minlines=50
+
+
+if has("spell")
+ syn spell toplevel
+endif
+
+
+syn match stgsqFirstLine "\%^.*" nextgroup=stgsqComment,stgsqContext,stgsqBlank skipnl
+syn match stgsqSummary "^.\{0,50\}" contained containedin=stgsqFirstLine nextgroup=stgsqOverflow contains=@Spell
+syn match stgsqOverflow ".*" contained contains=@Spell
+syn match stgsqBlank "^.\+" contained contains=@Spell
+syn match stgsqSeparator "-\+$" contained
+syn region stgsqPatch start="^\(.\{66\}-\{4\}$\)\@=" end="\(^.\{66\}-\{4\}$\)\@=" contained containedin=stgsqContext contains=@Spell fold
+syn match stgsqNextPatch "^.\{66\}-\{4\}$" contained containedin=stgsqPatch contains=stgsqPatchName
+syn match stgsqPatchName "^.\{-\}\(-*$\)\@=" contained containedin=stgsqNextPatch nextgroup=stgsqSeparator
+syn region stgsqContext start="^---" end="%$" contains=@Spell fold
+syn match stgsqComment "^#.*"
+
+hi def link stgsqSummary Keyword
+hi def link stgsqComment Comment
+hi def link stgsqBlank Error
+hi def link stgsqContext Comment
+hi def link stgsqPatch Constant
+hi def link stgsqPatchName Identifier
+hi def link stgsqSeparator Comment
+
+
+let b:current_syntax = "stgsquash"