svn/git/etc blame compatible syntax highlighting

144 views
Skip to first unread message

Richard Hartmann

unread,
Jan 21, 2009, 12:26:24 PM1/21/09
to v...@vim.org
Hi all.

if I run

git blame foo.file | vim -

or

svn blame foo.file | vim -

I get the blame-annotated file in Vim. Is there a way to have the syntax
highlighting ignore the blame stuff and simply highlight the actual
code?


Thanks,
Richard

Markus Heidelberg

unread,
Jan 25, 2009, 6:50:06 PM1/25/09
to vim...@googlegroups.com, Richard Hartmann, v...@vim.org
Richard Hartmann, 21.01.2009:

I'm not sure if everybody is familiar with the blame output. Maybe you
have more chance of getting responses with an example.

In the blame output, each line of the considered file is prepended with
various information. This can be the version, author, date, line number,
maybe more. The blame output between various VCSs may not be compatible
with each other and can also be reduced in the amount of information.

4 example lines from git-blame:

6acbcb92 (Johannes Schindelin 2006-07-25 20:24:22 +0200 112) } else if (!strcmp(cmd, "--bare")) {
ef5ddb2f (Shawn O. Pearce 2006-12-30 23:28:53 -0500 113) static char git_dir[PATH_MAX+1];
6adcca3f (Junio C Hamano 2007-08-27 00:58:06 -0700 114) is_bare_repository_cfg = 1;
9277d602 (Junio C Hamano 2007-08-27 22:41:23 -0700 115) setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 0);

Ted Pavlic

unread,
Jan 25, 2009, 10:04:46 PM1/25/09
to vim_use, Richard Hartmann, vim
> I'm not sure if everybody is familiar with the blame output. Maybe you
> have more chance of getting responses with an example.

"blame" is git's funny way of saying "annotate."

There are several annotate-type syntax highlighting schemes for Vim (for
example, CVSAnnotate.vim and HGAnnotate.vim). However, IIRC, these just
highlight everything to the "left" of the actual code.

It seems like you would need a way to say... "Use these syntax
highlighting rules for everything up to column 80, and autodetect which
syntax highlighting rules to use after column 80." So it's almost like
Vim needs new options...

:set annotatetype=git (for the "left" side of git blame)
:set filetype=perl (for the "right" side of git blame)

Otherwise, you'd need something like "gitBlamePerl.vim" and
"gitBlameC.vim" and . . .

(and a way to autodetect which one to use)

--Ted


--
Ted Pavlic <t...@tedpavlic.com>

Please visit my ALS association page:
http://web.alsa.org/goto/tedpavlic
My family appreciates your support in the fight to defeat ALS.

Bob Hiestand

unread,
Feb 10, 2009, 2:24:11 PM2/10/09
to vim...@googlegroups.com

Users of the vcscommand plugin are encouraged to try a preliminary
version that provides exactly this functionality. It can be
downloaded at:

http://repo.or.cz/w/vcscommand.git?a=snapshot;h=refs/heads/dev/split-blame;sf=zip

Please note, the above link will give a zip with an extra directory.
I'll package it once it has more testing and documentation. If you
use stock options for blame/annotate, it should Just Work as-is for
CVS, SVN, and git.

Please let me know if there are any issues with this.

Thank you,

bob

Richard Hartmann

unread,
Feb 10, 2009, 3:31:51 PM2/10/09
to vim...@googlegroups.com
On Tue, Feb 10, 2009 at 20:24, Bob Hiestand <bob.hi...@gmail.com> wrote:

> http://repo.or.cz/w/vcscommand.git?a=snapshot;h=refs/heads/dev/split-blame;sf=zip

In case people prefer to track the WIP:
http://repo.or.cz/w/vcscommand.git?h=refs/heads/dev/split-blame


> Please let me know if there are any issues with this.

Will do after playing with this. Thanks :)


Richard

Richard Hartmann

unread,
Feb 10, 2009, 4:41:52 PM2/10/09
to vim...@googlegroups.com
On Tue, Feb 10, 2009 at 21:31, Richard Hartmann
<richih.ma...@gmail.com> wrote:

>> Please let me know if there are any issues with this.
>
> Will do after playing with this. Thanks :)

Assuming all I need to do is to copy this into one of my
plugin dirs (and removing the old svncommand.vim), this
does not work. I don't get any highlighting in any file.
Tested with svn & git.

Also, in doc/vcscommand.txt you mention vcscvs,
vcssvn and vcssvk, but not vcsgit in Installation.


Richard

Reply all
Reply to author
Forward
0 new messages