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

* Re: [PATCH] contrib/vim: add syntax highlighting file for commits
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Prince @ 2006-09-12  2:08 UTC (permalink / raw)
  To: git

On Mon, Sep 11, 2006 at 07:22:49PM -0400, Jeff King wrote:
> +  1. Copy commit-syntax.vim to vim's syntax directory:
> +     $ cp commit-syntax.vim $HOME/.vim/syntax/gitcommit.vim
...
> diff --git a/contrib/vim/commit-syntax.vim b/contrib/vim/commit-syntax.vim

It would be more obvious if you could do cp gitcomit.vim $HOME/.vim/syntax/

  Tom

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

* Re: [PATCH] contrib/vim: add syntax highlighting file for commits
  2006-09-12  2:08 ` Tom Prince
@ 2006-09-12  2:32   ` Jeff King
  2006-09-13  6:12     ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2006-09-12  2:32 UTC (permalink / raw)
  To: git

On Mon, Sep 11, 2006 at 08:08:13PM -0600, Tom Prince wrote:

> > +  1. Copy commit-syntax.vim to vim's syntax directory:
> > +     $ cp commit-syntax.vim $HOME/.vim/syntax/gitcommit.vim
> It would be more obvious if you could do cp gitcomit.vim $HOME/.vim/syntax/

It would be with only one file, but you could just as easily have a
.vim/ftplugin/gitcommit.vim file (I think there are others, too). If you
want to give it the "proper" name, it should probably be
syntax/gitcommit.vim.

-Peff

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

* Re: [PATCH] contrib/vim: add syntax highlighting file for commits
  2006-09-12  2:32   ` Jeff King
@ 2006-09-13  6:12     ` Junio C Hamano
  2006-09-13  6:25       ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2006-09-13  6:12 UTC (permalink / raw)
  To: Jeff King; +Cc: git, Tom Prince

Jeff King <peff@peff.net> writes:

> On Mon, Sep 11, 2006 at 08:08:13PM -0600, Tom Prince wrote:
>
>> > +  1. Copy commit-syntax.vim to vim's syntax directory:
>> > +     $ cp commit-syntax.vim $HOME/.vim/syntax/gitcommit.vim
>> It would be more obvious if you could do cp gitcomit.vim $HOME/.vim/syntax/
>
> It would be with only one file, but you could just as easily have a
> .vim/ftplugin/gitcommit.vim file (I think there are others, too). If you
> want to give it the "proper" name, it should probably be
> syntax/gitcommit.vim.

I am not a vim user, but my reading of Tom's comment is that he
thinks it would have been nicer if the file the patch adds were
named gitcommit.vim, not commit-syntax.vim.  As you seem to
agree that the preferred name for this file when deployed is
gitcommit.vim, how about something like this on top of your
patch perhaps?


diff --git a/contrib/vim/README b/contrib/vim/README
index bad0a05..f574cc8 100644
--- a/contrib/vim/README
+++ b/contrib/vim/README
@@ -1,6 +1,6 @@
 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
+  1. Copy gitcommit.vim to vim's syntax directory:
+     $ cp gitcommit.vim $HOME/.vim/syntax/
   2. Auto-detect the editing of git commit files:
      $ cat >>$HOME/.vimrc <<'EOF'
      autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit
diff --git a/contrib/vim/commit-syntax.vim b/contrib/vim/gitcommit.vim
similarity index 100%
rename from contrib/vim/commit-syntax.vim
rename to contrib/vim/gitcommit.vim

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

* Re: [PATCH] contrib/vim: add syntax highlighting file for commits
  2006-09-13  6:12     ` Junio C Hamano
@ 2006-09-13  6:25       ` Jeff King
  2006-09-13  6:46         ` Tom Prince
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2006-09-13  6:25 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Tom Prince

On Tue, Sep 12, 2006 at 11:12:08PM -0700, Junio C Hamano wrote:

> I am not a vim user, but my reading of Tom's comment is that he
> thinks it would have been nicer if the file the patch adds were
> named gitcommit.vim, not commit-syntax.vim.  As you seem to
> agree that the preferred name for this file when deployed is
> gitcommit.vim, how about something like this on top of your
> patch perhaps?

My point was that there may be many files named gitcommit.vim; the
directory they appear in under your .vim directory has significance. If
we add another such file, they will conflict in the flattened namespace
of contrib/vim.  See below (which also adds the necessary mkdir
command):

-- >8 --
contrib/vim: give commit-syntax a more sensible name

diff --git a/contrib/vim/README b/contrib/vim/README
index bad0a05..9e7881f 100644
--- a/contrib/vim/README
+++ b/contrib/vim/README
@@ -1,6 +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
+  1. Copy syntax/gitcommit.vim to vim's syntax directory:
+     $ mkdir -p $HOME/.vim/syntax
+     $ cp syntax/gitcommit.vim $HOME/.vim/syntax
   2. Auto-detect the editing of git commit files:
      $ cat >>$HOME/.vimrc <<'EOF'
      autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit
diff --git a/contrib/vim/commit-syntax.vim b/contrib/vim/syntax/gitcommit.vim
similarity index 100%
rename from contrib/vim/commit-syntax.vim
rename to contrib/vim/syntax/gitcommit.vim

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

* Re: [PATCH] contrib/vim: add syntax highlighting file for commits
  2006-09-13  6:25       ` Jeff King
@ 2006-09-13  6:46         ` Tom Prince
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Prince @ 2006-09-13  6:46 UTC (permalink / raw)
  To: git

On Wed, Sep 13, 2006 at 02:25:57AM -0400, Jeff King wrote:
 
> My point was that there may be many files named gitcommit.vim; the
> directory they appear in under your .vim directory has significance. If
> we add another such file, they will conflict in the flattened namespace
> of contrib/vim.  See below (which also adds the necessary mkdir
> command):
> 

Much clearer. I had glanced at the readme and did
cp commit-syntax.vim ~/.vim/syntax
and it took me a minute or so to figure what was wrong.

  Tom

^ permalink raw reply	[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).