git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] contrib/vim: add syntax highlighting file for commits
@ 2006-09-11 23:22 Jeff King
  2006-09-12  2:08 ` Tom Prince
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2006-09-11 23:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git


Signed-off-by: Jeff King <peff@peff.net>
---
There were at least a few positive comments on this, and hey, we have to
balance the contrib/emacs directory!

 contrib/vim/README            |    7 +++++++
 contrib/vim/commit-syntax.vim |   18 ++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/contrib/vim/README b/contrib/vim/README
new file mode 100644
index 0000000..bad0a05
--- /dev/null
+++ b/contrib/vim/README
@@ -0,0 +1,7 @@
+To syntax highlight git's commit messages, you need to:
+  1. Copy commit-syntax.vim to vim's syntax directory:
+     $ cp commit-syntax.vim $HOME/.vim/syntax/gitcommit.vim
+  2. Auto-detect the editing of git commit files:
+     $ cat >>$HOME/.vimrc <<'EOF'
+     autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit
+     EOF
diff --git a/contrib/vim/commit-syntax.vim b/contrib/vim/commit-syntax.vim
new file mode 100644
index 0000000..a9de09f
--- /dev/null
+++ b/contrib/vim/commit-syntax.vim
@@ -0,0 +1,18 @@
+syn region gitLine start=/^#/ end=/$/
+syn region gitCommit start=/^# Updated but not checked in:$/ end=/^#$/ contains=gitHead,gitCommitFile
+syn region gitHead contained start=/^#   (.*)/ end=/^#$/
+syn region gitChanged start=/^# Changed but not updated:/ end=/^#$/ contains=gitHead,gitChangedFile
+syn region gitUntracked start=/^# Untracked files:/ end=/^#$/ contains=gitHead,gitUntrackedFile
+
+syn match gitCommitFile contained /^#\t.*/hs=s+2
+syn match gitChangedFile contained /^#\t.*/hs=s+2
+syn match gitUntrackedFile contained /^#\t.*/hs=s+2
+
+hi def link gitLine Comment
+hi def link gitCommit Comment
+hi def link gitChanged Comment
+hi def link gitHead Comment
+hi def link gitUntracked Comment
+hi def link gitCommitFile Type
+hi def link gitChangedFile Constant
+hi def link gitUntrackedFile Constant
-- 
1.4.2.g39f1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-09-13  6:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-11 23:22 [PATCH] contrib/vim: add syntax highlighting file for commits Jeff King
2006-09-12  2:08 ` Tom Prince
2006-09-12  2:32   ` Jeff King
2006-09-13  6:12     ` Junio C Hamano
2006-09-13  6:25       ` Jeff King
2006-09-13  6:46         ` Tom Prince

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).