It would be nice if there was some feature that would allow something like:
:set scmtype=git
:set filetype=c
That is, an output of "git blame myfile.c | vim -" would get highlighted
so that the "left" side of the blame output was highlighted matching
"git blame" rules, and the "right" side of the blame output would use
standard highlighting rules for c.
Then left/right autodetection would be the next nice feature... That is,
Vim would have to be able to detect that it's looking at a
blame/annotate-type file and then detect which SCM format to use on the
left and which filetype to use on the right.
I have a feeling that such a feature is non-trivial. That being said, I
think the demand for such a feature is growing.
Thanks --
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.
Hi Ted,
You're right, such a feature would be difficult to accommodate with the current
mechanism for syntax highlighting (and without duplicating and maintaining an
entire suite of git-c, git-cpp, ... syntaxes). I also cannot imagine support for
a new ':set scmtype' setting within VIM; after all, it is a text editor, and
those SCM annotations are usually only viewed, not edited, right?
However, I can imagine a quick solution that could be implemented relatively
cheaply in vimscript, and might be suitable if all you want is _view_ these
kinds of output. Here's a sketch:
1. Create two scratch buffers (buftype=nofile, etc), vertically split, with :set
scrollbind.
2. Open the 'git blame' output in a third buffer and use e.g. blockwise Visual
mode (CTRL-V) to copy-and-paste the left (git) block into the left scratch
buffer, and the right (programming-language) block into the right one.
3. Close the third buffer, :set filetype=git on the left, trigger a filetype
detection on the right buffer.
If you put these actions in a custom command, you could "prettify" the output
with a few keystrokes, or even use the existing filetype detection mechanism to
auto-detect and auto-prettify this.
Of course, it's two buffers, not one, so jumping around isn't completely
natural. On the other hand, the two-buffer split may even make certain
copy-paste actions easier to do.
-- regards, ingo
PS: Ben, just saw your reply coming in when I wanted to press "send". Seems you
have had the same idea?!
--
-- Ingo Karkat -- /^-- /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --
--
Shift happens. -- Doppler
> On Jan 26, 9:30 am, Ted Pavlic <t...@tedpavlic.com> wrote:
>
> > That is, an output of "git blame myfile.c | vim -" would get highlighted
> > so that the "left" side of the blame output was highlighted matching
> > "git blame" rules, and the "right" side of the blame output would use
> > standard highlighting rules for c.
>
> While it is possible in some cases to highlight certain areas of a
> file using rules for a different filetype (http://vim.wikia.com/wiki/
> Different_syntax_highlighting_within_regions_of_a_file) what you are
> asking is currently not possible in Vim.
>
> [ ... ]
>
> All this being said, you could probably make some sort of plugin to
> get functionality similar to what you want. After reading in the
> "blame" output, you could fairly easily split the file into a left and
> right window, with the left window containing only the blame output
> and the right containing only the un-annotated file.
Ideally, wouldn't annotate look very much like the 'number' option in terms
of how it's put on the screen? They're both per-line metadata, after all.
Danek