Signed-off-by: Pierre Habouzit <madcoder@debian.org> --- contrib/vim/syntax/gitcommit.vim | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/contrib/vim/syntax/gitcommit.vim b/contrib/vim/syntax/gitcommit.vim index a9de09f..d0c6e5d 100644 --- a/contrib/vim/syntax/gitcommit.vim +++ b/contrib/vim/syntax/gitcommit.vim @@ -1,3 +1,14 @@ +" Vim syntax file +" Language: git commit message + +" Quit when a (custom) syntax file was already loaded +if exists("b:current_syntax") + finish +endif + +syn region gitSignedOff start=/^Signed-off-by:/ end=/$/ contains=gitAuthor,gitEmail +syn region gitAuthor contained start=/\s/ end=/$/ + syn region gitLine start=/^#/ end=/$/ syn region gitCommit start=/^# Updated but not checked in:$/ end=/^#$/ contains=gitHead,gitCommitFile syn region gitHead contained start=/^# (.*)/ end=/^#$/ @@ -8,6 +19,9 @@ syn match gitCommitFile contained /^#\t. syn match gitChangedFile contained /^#\t.*/hs=s+2 syn match gitUntrackedFile contained /^#\t.*/hs=s+2 +hi def link gitSignedOff Keyword +hi def link gitAuthor Normal + hi def link gitLine Comment hi def link gitCommit Comment hi def link gitChanged Comment @@ -16,3 +30,7 @@ hi def link gitUntracked Comment hi def link gitCommitFile Type hi def link gitChangedFile Constant hi def link gitUntrackedFile Constant + +let b:current_syntax = "git" + +" vim: ts=8 sw=2 -- 1.4.2.3 -
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
contrib/vim/README | 6 ++++
contrib/vim/ftplugin/gitcommit.vim | 61 ++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/contrib/vim/README b/contrib/vim/README
index 9e7881f..26c1682 100644
--- a/contrib/vim/README
+++ b/contrib/vim/README
@@ -6,3 +6,9 @@ To syntax highlight git's commit message
$ cat >>$HOME/.vimrc <<'EOF'
autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit
EOF
+
+To use the fancy split-view with the currently commited diff, you need to:
+ 1. Copy ftplugin/gitcommit.vim to vim's ftplugin directory:
+ $ mkdir -p $HOME/.vim/ftplugin
+ $ cp ftplugin/gitcommit.vim $HOME/.vim/ftplugin
+ 2. Auto-detect the editing of git commit files (see above).
diff --git a/contrib/vim/ftplugin/gitcommit.vim b/contrib/vim/ftplugin/gitcommit.vim
new file mode 100644
index 0000000..f9efd59
--- /dev/null
+++ b/contrib/vim/ftplugin/gitcommit.vim
@@ -0,0 +1,61 @@
+if exists("b:did_ftplugin")
+ finish
+endif
+
+let b:did_ftplugin = 1
+
+setlocal tw=74
+setlocal nowarn nowb
+
+"{{{ function Git_diff_windows
+
+function! Git_diff_windows()
+ let i = 0
+ let list_of_files = ''
+
+ " drop everything until '# (will commit)' and the next empty line
+ while i <= line('$')
+ let line = getline(i)
+ if line =~ '^#\s*(will commit)$'
+ let i = i + 2
+ break
+ endif
+
+ let i = i + 1
+ endwhile
+
+ " read file names until we have EOF or an empty line
+ while i <= line('$')
+ let line = getline(i)
+ if line =~ '^#\s*[a-z ]*:.*->.*$'
+ let file = substitute(line, '\v^#[^:]*:.*->\s*(.*)\s*$', '\1', '')
+ let list_of_files = list_of_files . ' '.file
+ let file = substitute(line, '\v^#[^:]*:\s*(.*)\s*->.*$', '\1', '')
+ let list_of_files = list_of_files . ' '.file
+ elseif ...I find it confusing that you split vertically, especially if I work in small terminals. I would prefere a horizontal split, thats why I changed it to the way to the way it is handled in the svn.vim commit case: Why changing directory? I had to remove the cd .. to make it work. Otherwise git diff couldn't find the repository. Greetings, Peter -
because for me, wherever I'm from, the cwd is .git/ but it's maybe due=20 to the fact that I use autochdir, I don't know. =2D-=20 =C2=B7O=C2=B7 Pierre Habouzit =C2=B7=C2=B7O madcoder@debia= n.org OOO http://www.madism.org
2006/10/17, Pierre Habouzit <madcoder@debian.org>: > Le mar 17 octobre 2006 10:22, Peter Baumann a
Yes it does, SungHyun Nam already sent a patch to me about that, that is=20
quite interesting. I've merged it partly, and will make that commit=20
plugin slightly better, so that people can:
1/ trig it by hand
2/ chose if the split is vertical or horizontal (I always have very big
terms with a lot of vertical splits in vim, so I like the latter,
other prefer the former)
3/ chose via a let g:gitcommit_diff_mode or sth like that in the vimrc
if that has to spawn automatically (0: none, 1: horiz split, 2: vert
split)
and that time, I'll send that to the git contrib/vim maintainer so that=20
I won't bother the list too much :)
a corrected version of the commit file wrt the cwd is on my site=20
already, with a bit of SungHyun changes[1].
[1] http://madism.org/~madcoder/dotfiles/vim/ftplugin/git.vim
=2D-=20
=C2=B7O=C2=B7 Pierre Habouzit
=C2=B7=C2=B7O madcoder@debia=
n.org
OOO http://www.madism.org
so there is a contrib/vim maintainer ? Sorry I'm new on git list (though Pierre gave me some hints already with git/vim). I'm interested in testing more of these goodies. Because I actually use git now on a daily basis for tcl/verilog/EDA together with (g)vim. I'd like particularly to know if a git-explorer type of plugin makes sense for (g)vim and would like in this case be part of the team developping it... using git of course :) -- Christian -
If you have git sources, check contrib/README please. What I asked Pierre was to CC the patch to Jeff King who did contrib/vim -- it was "send it to him too", and not "do not send it to me". I do not actively use vim myself so I am a wrong person to judge patches to that part of the source tree. Apparently Pierre seems to have thought that I thought patches to the contrib/ part is "bothering the list", but that was not my intention. I believe showing your patches for review by wider audiences is a good thing. -
Dear diary, on Tue, Oct 17, 2006 at 11:48:51PM CEST, I got a letter See also http://news.gmane.org/find-root.php?message_id=<20051124093322.GA3899@mail.yhbt.net... Personally, I'd say "just use tig". :-) If you insist on living instide vim, that particular script comes from the age before git-show and git-cat-file -p so it would probably make sense to move the bulk of the functionality there. -- Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ #!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj $/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1 lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/) -
