Skip to contentSkip to conversation

be more vim-ish, and also syntax hilight Signed-off-by lines.

PATCH In review Pierre Habouzit 6 participants 23 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 be more vim-ish, and also syntax hilight Signed-off-by lines.

---
 contrib/vim/syntax/gitcommit.vim |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
contrib/vim/syntax/gitcommit.vim +18 -0
index a9de09f..d0c6e5d 100644
@@ -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
Signature · 1 line
1.4.2.3
#1 lore raw

PATCH 1/1 nice ftplugin for vim, that shows the commited diff in a split'ed buffer.

---
 contrib/vim/README                 |    6 ++++
 contrib/vim/ftplugin/gitcommit.vim |   61 ++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 0 deletions(-)
contrib/vim/README +6 -0
index 9e7881f..26c1682 100644
@@ -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).
contrib/vim/ftplugin/gitcommit.vim new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
1.4.2.3
#2 lore raw

Re: [PATCH] nice ftplugin for vim, that shows the commited diff in a split'ed buffer.

2006/10/17, Pierre Habouzit <[email protected]>:

Quoted 65 lines
---
 contrib/vim/README                 |    6 ++++
 contrib/vim/ftplugin/gitcommit.vim |   61 ++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 0 deletions(-)
contrib/vim/README +6 -0
index 9e7881f..26c1682 100644
@@ -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).
contrib/vim/ftplugin/gitcommit.vim new file +39 -0
new file mode 100644
index 0000000..f9efd59
@@ -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 line =~ '^#\s*[a-z ]*:'
+            let file = substitute(line, '\v^#[^:]*:\s*(.*)\s*$', '\1', '')
+            let list_of_files = list_of_files . ' '.file
+        elseif line =~ '^#\s*$'
+            break

contrib/vim/ftplugin/gitcommit.vim line 49

Quoted 10 lines
contrib/vim/ftplugin/gitcommit.vim new file +10 -0
+        endif
+
+        let i = i + 1
+    endwhile
+
+    if list_of_files == ""
+        return
+    endif
+
+    rightbelow vnew

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:

below new

contrib/vim/ftplugin/gitcommit.vim line 52

Quoted 3 lines
contrib/vim/ftplugin/gitcommit.vim new file +3 -0
+    silent! setlocal ft=diff previewwindow bufhidden=delete nobackup noswf nobuflisted nowrap buftype=nofile
+    exe 'normal :r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . "\n1Gdd"
+    exe 'normal :r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . " \| git apply --stat\no\<esc>1GddO\<esc>"

Why changing directory? I had to remove the cd .. to make it work. Otherwise git diff couldn't find the repository.

Greetings,
Peter

#3 lore raw

Re: [PATCH] nice ftplugin for vim, that shows the commited diff in a split'ed buffer.

Quoted 88 lines · Peter Baumann

2006/10/17, Pierre Habouzit <[email protected]>:

Quoted 68 lines
---
 contrib/vim/README                 |    6 ++++
 contrib/vim/ftplugin/gitcommit.vim |   61

++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 0 deletions(-)

contrib/vim/README +0 -0
index 9e7881f..26c1682 100644
@@ -6,3 +6,9 @@ To syntax highlight git's commit message
      $ cat >>$HOME/.vimrc <<'EOF'
      autocmd BufNewFile,BufRead COMMIT_EDITMSG set

filetype=gitcommit EOF

contrib/vim/README +2 -0
+
+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

contrib/vim/README +2 -0
+     $ cp ftplugin/gitcommit.vim $HOME/.vim/ftplugin
+  2. Auto-detect the editing of git commit files (see above).
(quoted diff) +0 -0

b/contrib/vim/ftplugin/gitcommit.vim new file mode 100644 index 0000000..f9efd59

contrib/vim/ftplugin/gitcommit.vim new file +16 -0
@@ -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('$')

contrib/vim/ftplugin/gitcommit.vim new file +14 -0
+        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

contrib/vim/ftplugin/gitcommit.vim new file +2 -0
+        elseif line =~ '^#\s*[a-z ]*:'
+            let file = substitute(line, '\v^#[^:]*:\s*(.*)\s*$',

'\1', '') + let list_of_files = list_of_files . ' '.file

contrib/vim/ftplugin/gitcommit.vim new file +2 -0
+        elseif line =~ '^#\s*$'
+            break

contrib/vim/ftplugin/gitcommit.vim line 49

Quoted 10 lines
contrib/vim/ftplugin/gitcommit.vim new file +10 -0
+        endif
+
+        let i = i + 1
+    endwhile
+
+    if list_of_files == ""
+        return
+    endif
+
+    rightbelow vnew

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:

below new

Quoted 8 lines
Quoted 5 lines

+ silent! setlocal ft=diff previewwindow bufhidden=delete
nobackup noswf nobuflisted nowrap buftype=nofile + exe 'normal
:r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . "\n1Gdd" + exe 'normal :r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . " \| git apply --stat\no\<esc>1GddO\<esc>"

Why changing directory? I had to remove the cd .. to make it work. Otherwise git diff couldn't find the repository.

because for me, wherever I'm from, the cwd is .git/ but it's maybe due to the fact that I use autochdir, I don't know.

Signature · 3 lines
·O·  Pierre Habouzit
··O                                                [email protected]
OOO                                                http://www.madism.org
#4 lore raw

Re: [PATCH] nice ftplugin for vim, that shows the commited diff in a split'ed buffer.

2006/10/17, Pierre Habouzit <[email protected]>:

Quoted 95 lines · Peter Baumann
Quoted 94 lines

2006/10/17, Pierre Habouzit <[email protected]>:

Quoted 68 lines
---
 contrib/vim/README                 |    6 ++++
 contrib/vim/ftplugin/gitcommit.vim |   61

++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 0 deletions(-)

contrib/vim/README +0 -0
index 9e7881f..26c1682 100644
@@ -6,3 +6,9 @@ To syntax highlight git's commit message
      $ cat >>$HOME/.vimrc <<'EOF'
      autocmd BufNewFile,BufRead COMMIT_EDITMSG set

filetype=gitcommit EOF

contrib/vim/README +2 -0
+
+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

contrib/vim/README +2 -0
+     $ cp ftplugin/gitcommit.vim $HOME/.vim/ftplugin
+  2. Auto-detect the editing of git commit files (see above).
(quoted diff) +0 -0

b/contrib/vim/ftplugin/gitcommit.vim new file mode 100644 index 0000000..f9efd59

contrib/vim/ftplugin/gitcommit.vim new file +16 -0
@@ -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('$')

contrib/vim/ftplugin/gitcommit.vim new file +14 -0
+        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

contrib/vim/ftplugin/gitcommit.vim new file +2 -0
+        elseif line =~ '^#\s*[a-z ]*:'
+            let file = substitute(line, '\v^#[^:]*:\s*(.*)\s*$',

'\1', '') + let list_of_files = list_of_files . ' '.file

contrib/vim/ftplugin/gitcommit.vim new file +2 -0
+        elseif line =~ '^#\s*$'
+            break

contrib/vim/ftplugin/gitcommit.vim line 49

Quoted 10 lines
contrib/vim/ftplugin/gitcommit.vim new file +10 -0
+        endif
+
+        let i = i + 1
+    endwhile
+
+    if list_of_files == ""
+        return
+    endif
+
+    rightbelow vnew

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:

below new

Quoted 5 lines

+ silent! setlocal ft=diff previewwindow bufhidden=delete
nobackup noswf nobuflisted nowrap buftype=nofile + exe 'normal
:r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . "\n1Gdd" + exe 'normal :r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . " \| git apply --stat\no\<esc>1GddO\<esc>"

Quoted 6 lines
Quoted 2 lines

Why changing directory? I had to remove the cd .. to make it work. Otherwise git diff couldn't find the repository.

because for me, wherever I'm from, the cwd is .git/ but it's maybe due to the fact that I use autochdir, I don't know.

Wouldn't it make sense to use something like 'git-rev-parse --git-dir' or 'git-rev-parse --show-cdup' to get to the root of the repository?

Greetings,
Peter

#5 lore raw

Re: [PATCH] nice ftplugin for vim, that shows the commited diff in a split'ed buffer.

Quoted 8 lines · Peter Baumann

2006/10/17, Pierre Habouzit <[email protected]>:

Quoted 2 lines

because for me, wherever I'm from, the cwd is .git/ but it's maybe due to the fact that I use autochdir, I don't know.

Wouldn't it make sense to use something like 'git-rev-parse --git-dir' or 'git-rev-parse --show-cdup' to get to the root of the repository?

Yes it does, SungHyun Nam already sent a patch to me about that, that is quite interesting. I've merged it partly, and will make that commit 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 I won't bother the list too much :)

a corrected version of the commit file wrt the cwd is on my site already, with a bit of SungHyun changes[1].

[1] http://madism.org/~madcoder/dotfiles/vim/ftplugin/git.vim

Signature · 3 lines
·O·  Pierre Habouzit
··O                                                [email protected]
OOO                                                http://www.madism.org
#6 lore raw

Re: [PATCH] nice ftplugin for vim, that shows the commited diff in a split'ed buffer.

Quoted 3 lines · Pierre Habouzit

and that time, I'll send that to the git contrib/vim maintainer so that I won't bother the list too much :)

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 :)

Signature · 1 line
Christian
#7 lore raw

Re: [PATCH] nice ftplugin for vim, that shows the commited diff in a split'ed buffer.

Dear diary, on Tue, Oct 17, 2006 at 11:48:51PM CEST, I got a letter where Christian MICHON <[email protected]> said that...

Quoted 3 lines

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 :)

See also

	http://news.gmane.org/find-root.php?message_id=<[email protected]>

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.

Signature · 5 lines
				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*',/((..)*)$/)
#8 lore raw

Re: [PATCH] nice ftplugin for vim, that shows the commited diff in a split'ed buffer.

In reply to Christian MICHON
Quoted 7 lines · Christian MICHON
Quoted 3 lines · Pierre Habouzit

and that time, I'll send that to the git contrib/vim maintainer so that I won't bother the list too much :)

so there is a contrib/vim maintainer ? Sorry I'm new on git list (though Pierre gave me some hints already with git/vim).

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.

#9 lore raw
In reply to Pierre Habouzit

I'd prefer patches to contrib/ sections to be CC'ed to the owners of them (in this case that would be Jeff King) to be Acked, since I do not actively maintain anything under contrib/ myself.

Jeff, are you Ok with Pierre's two patches?

#10 lore raw

contrib/vim patches, replace the previous set

here is a brand new set of patches, the same update on the syntax
file, and an enhanced ftplugin that is very configureable.

Those two patches replace the two previous ones.

#11 lore raw

contrib/vim patches, replace the previous set

In reply to Junio C Hamano

here is a brand new set of patches, the same update on the syntax
file, and an enhanced ftplugin that is very configureable.

Those two patches replace the two previous ones.

#12 lore raw

PATCH 1/1 be more vim-ish, and also syntax hilight Signed-off-by lines.

---
 contrib/vim/syntax/gitcommit.vim |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
contrib/vim/syntax/gitcommit.vim +18 -0
index a9de09f..d0c6e5d 100644
@@ -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
Signature · 1 line
1.4.2.3
#13 lore raw

PATCH 1/1 Nice ftplugin for vim, that shows the commited diff in a split'ed buffer.

---
 contrib/vim/README                 |   10 +++++
 contrib/vim/ftplugin/gitcommit.vim |   75 ++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 0 deletions(-)
contrib/vim/README +10 -0
index 9e7881f..e5ca9ae 100644
@@ -6,3 +6,13 @@ 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).
+  3. You can configure the diff to spawn automatically by setting:
+     let git_diff_spawn_mode = 1 (or 2) for an horiz (resp. vert) split.
+     else you have the bindings ,gd or ,ghd to spawn an horiz split with
+     the diff, and ,gvd for the same with a vertical diff.
contrib/vim/ftplugin/gitcommit.vim new file +75 -0

75 lines not on this page · raw message

Signature · 1 line
1.4.2.3
#15 lore raw

Make the ftplugin right wrt gitdir

In reply to Pierre Habouzit

sorry for the mess, I'm a bit tired :)
Here is a third patch to fix the plugin to find the git-dir properly.

Also add a nice shortcut to quit that buffer.

#16 lore raw

PATCH 1/1 be more robust wrt the git-dir.

---
 contrib/vim/ftplugin/gitcommit.vim |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
contrib/vim/ftplugin/gitcommit.vim +10 -2
index a9cb946..e958fb1 100644
@@ -52,9 +52,17 @@ function! Git_diff_windows(vertsplit, au
         rightbelow new
     endif
     silent! setlocal ft=diff previewwindow bufhidden=delete nobackup noswf nobuflisted nowrap buftype=nofile
-    exe 'normal :r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . "\n1Gdd"
-    exe 'normal :r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . " \| git apply --stat\no\<esc>1GddO\<esc>"
+    let gitDir = system('git rev-parse --git-dir 2>/dev/null')
+    let gitDir = substitute(gitDir, '.git\n', '', '')
+    let wd = getcwd()
+    if gitDir != ''
+        exe 'cd '.gitDir
+    endif
+    exe 'normal :r!LANG=C git diff HEAD -- ' . list_of_files . "\n1Gdd"
+    exe 'normal :r!LANG=C git diff HEAD -- ' . list_of_files . " \| git apply --stat\no\<esc>1GddO\<esc>"
+    exe 'cd '.wd
     setlocal nomodifiable
+    noremap <buffer> q :bw<cr>
     if a:auto
         redraw!
         wincmd p
Signature · 1 line
1.4.2.3
#17 lore raw

Re: Make the ftplugin right wrt gitdir

In reply to Pierre Habouzit
Quoted 4 lines · Pierre Habouzit

sorry for the mess, I'm a bit tired :)
Here is a third patch to fix the plugin to find the git-dir properly.

Also add a nice shortcut to quit that buffer.

Looks like the patch is missing (more sleep required?).

-Peff

#18 lore raw

Re: Make the ftplugin right wrt gitdir

Quoted 8 lines · Jeff King
Quoted 5 lines · Pierre Habouzit

sorry for the mess, I'm a bit tired :)
Here is a third patch to fix the plugin to find the git-dir properly.

Also add a nice shortcut to quit that buffer.

Looks like the patch is missing (more sleep required?).

err, the patch is here:
<[email protected]>

at least I see it on the list for my part

Signature · 3 lines
·O·  Pierre Habouzit
··O                                                [email protected]
OOO                                                http://www.madism.org
#19 lore raw

Re: Make the ftplugin right wrt gitdir

Quoted 4 lines · Pierre Habouzit
Quoted 1 line

Looks like the patch is missing (more sleep required?).

err, the patch is here:
<[email protected]>

Right, that's the "be more robust" patch which applies on top of something else (presumably "nice ftplugin for vim"), but the last one I got of that (<[email protected]>) causes vim errors and you immediately followed up with "that's still not the good one." Where is that patch?

-Peff

#20 lore raw

Re: Make the ftplugin right wrt gitdir

Quoted 11 lines · Jeff King
Quoted 4 lines · Pierre Habouzit
Quoted 1 line

Looks like the patch is missing (more sleep required?).

err, the patch is here:
<[email protected]>

Right, that's the "be more robust" patch which applies on top of something else (presumably "nice ftplugin for vim"), but the last one I got of that (<[email protected]>) causes vim errors and you immediately followed up with "that's still not the good one." Where is that patch?

hmm I see, curious though, I must have do sth stupid :|

well the result file is here:
http://madism.org/~madcoder/dotfiles/vim/ftplugin/git.vim

I've not access to my git repo from here, feel free to grab it and commit it, I don't care if there is not my name on it.

and as of gitEmail you're right I don't use it, I wanted to to hilight the email address in the gitAuthor zone, but well, basically, it sucks, that makes too many colors.

Signature · 3 lines
·O·  Pierre Habouzit
··O                                                [email protected]
OOO                                                http://www.madism.org
#21 lore raw

Re: Make the ftplugin right wrt gitdir

Quoted 2 lines · Pierre Habouzit

well the result file is here:
http://madism.org/~madcoder/dotfiles/vim/ftplugin/git.vim

I was able to grab it...my comments are below.

Quoted 8 lines

if exists("b:did_ftplugin")
finish
endif

let b:did_ftplugin = 1

setlocal tw=74
setlocal nowarn nowb

Do things like tw really have anything to do with the ftplugin? Shouldn't they instead go into the user's vimrc?

Quoted 39 lines

"{{{ function Git_diff_windows

function! Git_diff_windows(vertsplit, auto)
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 line =~ '^#\s*[a-z ]*:'
let file = substitute(line, '\v^#[^:]*:\s*(.*)\s*$', '\1', '') let list_of_files = list_of_files . ' '.file
elseif line =~ '^#\s*$'
break
endif

let i = i + 1
endwhile

if list_of_files == ""
return
endif

Quoted 5 lines

if a:vertsplit
rightbelow vnew
else
rightbelow new
endif

This all looks OK to me, but then I don't really know vim script very well. :)

Quoted 11 lines

silent! setlocal ft=diff previewwindow bufhidden=delete nobackup noswf nobuflisted nowrap buftype=nofile let gitDir = system('git rev-parse --git-dir 2>/dev/null')
let gitDir = substitute(gitDir, '.git\n', '', '')
let wd = getcwd()
if gitDir != ''
exe 'cd '.gitDir
endif
exe 'normal :r!LANG=C git diff HEAD -- ' . list_of_files . "\n1Gdd"
exe 'normal :r!LANG=C git diff HEAD -- ' . list_of_files . " \| git apply --stat\no\<esc>1GddO\<esc>" exe 'cd '.wd
setlocal nomodifiable

This procedure seems a bit hack-ish and fragile. I think the chdir is necessary not just to handle autochdir, but also because we want to do any diff from the top-level instead of a subdir. Why do we unconditionally set LANG=C? What about quoting for the file list?

In general, is this really that much nicer than simply using the '-v' flag to git-commit?

Quoted 5 lines

if g:git_diff_spawn_mode == 1

     call Git_diff_windows(0, 1)
 elseif g:git_diff_spawn_mode == 2
     call Git_diff_windows(1, 1)

endif

This should probably handle the case where g:git_diff_spawn_mode is not defined (otherwise vim complains loudly):
if exists("g:git_diff_spawn_mode")
" do nothing
elseif g:git_diff_spawn_mode == 1
etc.

-Peff

#22 lore raw
In reply to Pierre Habouzit

contrib/vim/syntax/gitcommit.vim line 7

Quoted 3 lines · Pierre Habouzit
contrib/vim/syntax/gitcommit.vim +3 -0
+if exists("b:current_syntax")
+  finish
+endif

I think this is a good change (along with commenting), but please write a more descriptive commit message than "be more vim-ish" (I wouldn't mind seeing this and the highlighting change broken into two patches, since they are functionally completely unrelated).

contrib/vim/syntax/gitcommit.vim line 10

Quoted 2 lines
contrib/vim/syntax/gitcommit.vim +2 -0
+syn region gitSignedOff start=/^Signed-off-by:/ end=/$/ contains=gitAuthor,gitEmail
+syn region gitAuthor contained start=/\s/ end=/$/

You mention gitEmail but never define it. Are people using other things besides Signed-off-by? I think we might do better to simply write:
syn region gitCommentHeader start=/^[^ ]\+:/ end=/$/ contains=gitCommentValue syn region gitCommentValue contained start=/\s/ end=/$/

Highlighting only the header is inconsistent with other highlighting (e.g., all of "new file: foo" is highlighted), but it looks so ugly to highlight the whole line, so I think this is fine.

-Peff