Method definition highlighting

Tim Pope vim-ruby-devel at
Tue Feb 20 10:47:49 EST 2007

On Tue, Feb 20, 2007 at 10:02:36PM +1100, Doug Kearns wrote:
> One of the reasons I'd temporarily forgotten that the current CVS wasn't
> highlighting method names specially in method definitions is because
> I've never liked it and have a local customization to prevent it.

Well, I can't say I ever particularly cared for it either, although it
is a common practice in Vim syntax highlighting.  Recently, I was
working on cloning "vibrant ink," a TextMate theme popular with Rails
users.  I added the rubyRegexp group in pursuit of this goal, which is
when I discovered the method name highlighting problem.  The theme in
question definitely looks better with such method name highlighting in
place.  So I'd at least like to keep it as a possibility.

> I much prefer the "self" in:
> def end 
> and the "Foo" in:
> def Foo::bar; end
> to be highlighted normally as rubyPseudoVariable, rubyConstant and
> rubyLocalVariableOrMethod respectively rather than all of them being
> highlighted as part of the artificial rubyFunction.

Certainly a possibility.  To get the original effect, you'd have to
highlight all rubyLocalVariableOrMethod objects as Identifier, at
which point it'd probably be easier to highlight all the things that
aren't identifiers, as the screen is going to be saturated with it.

The amount of Identifier highlighting has always bothered me with the
current syntax file, actually.  I've tried disabling various things to
reduce it,  I'm happy to hack around it, but if while we're discussing
the subject, I figure I may as well throw my two cents into the pot.

One possible alternative is to move symbols into the Constant group
with numbers and strings.  This is more logical, in a way, and my
understanding is this is how TextMate works.  I do like having symbols
highlighted differently from strings, but from a theoretical
perspective it might make more sense to change String highlighting in
the color scheme instead.  Of course, this is not the default, so that
should be taken into account as well.

One group that doesn't get much play is Type.  Might it make more
sense to highlight constants (the capitalized kind) using this group.
This makes sense in cases where constants are classes.  In the cases
where they're not, well, keep in mind method declarations aren't
exactly PreProc either.  Making this change would basically allow us
to drop all the fanciness for module/class declarations as well.  The
colons would be different, but I don't think that's a bad thing.

Going on a real tangent now, it just occured to me a different use for
the Type group.  I find the variations of highlighting of "end" to be
extrordinarily useful.  Perhaps it would make sense to use the Type
group as a third color?  This strikes me as potentially very useful
for keeping things matched up.  You could also drop the module/class
fanciness in this case, as you'd want the class/module name to be
distinct from the introducing keyword.  I'm committing changes that
make this possible, but I am leaving the default highlighting for it
as PreProc until I have spent some time playing with it.



More information about the vim-ruby-devel mailing list