On Jan 26, 9:30 am, Ted Pavlic <[email protected]> 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. Syntax highlighting works
using regular expressions, often spanning multiple lines. You would
need to somehow force Vim to skip over the "left" side when applying
the rules and highlighting to the right, and the same for the left.
Modifying syntax rules to accomplish this for specific cases might be
possible, but really isn't feasible. To include "blame" rules in the
filetype for the base file, you could modify the syntax rules of every
possible filetype you're going to be using "blame" on, adding regions
for the blame output that can be contained in every multi-line syntax
group. You'd also need to change any rules that match the beginning of
a line. This would be a never-ending task, and wouldn't really be very
maintainable. It might not even be possible for some syntax rules
without a wholesale rewrite. The opposite approach, including basic
file types in the blame syntax rules, would be even more daunting. You
would somehow need to duplicate or apply the rules for multi-line
matches in the file within the single-line matches of the blame
output.
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. Set filetypes in
each window appropriately, set scrollbind, and you're basically done.
This method could even be generalized to fit _any_ blame output and
_any_ base file type. It would rely on a simple regex to recognize
where the blame output ends and a line in the file starts. Obviously
you'd want several blame types built in, but simply allowing a custom
regex would make it infinitely extensible. Perhaps there is even a
plugin that does this already?
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---