More syntax highlighting fun

Tim Pope vim-ruby-devel at
Fri Feb 23 13:10:53 EST 2007

On Fri, Feb 23, 2007 at 07:56:03PM +1100, Doug Kearns wrote:
> On Thu, Feb 22, 2007 at 11:32:36AM -0600, Tim Pope wrote:
> > More important than a few cosmetic changes is the overhaul I gave to
> > method, module, and class definitions.
> From a quick inspection I noticed that the following are not being
> highlighted properly:
> def foo    ; end  # whitespace after method name
> def foo(x);  end  # with parameter list (also empty list)
> def Foo::bar;end  # specified with ::

Fixed all 3.  Turns out the difference between .\@<! and \.\@<! is
quite large :).

> def [];      end  # all redefinable operator methods

You may not have intended it, but this is by far the best case I have
heard for highlighting method names:  indicating whether they are
valid, including the appropriate operators.  I've added matching for
all operators that can be overloaded; the list is hopefully both
exhaustive and exclusive.  Building on this, I added highlighting for
aliases as well.  The way I did this is a little crude and may need
some refining, so let me know if there are problems.

> > Things like if/unless are in the Conditional group and
> > while/until in the Loop group.
> Shouldn't that be the Repeat group?

Doh, shows how often I use these primitive constructs.  I see you
fixed the hi link; I renamed the group as well.

> It's really just the "Vim Way" of doing things - at least as I
> understand it.  Generally the configuration options are there to allow
> people to customize the highlighting without any need to understand
> syntax files.  I think you'd be surprised how many people use Vim with
> absolutely no understanding of these details. ;-)

True to an extent, but some of this strikes me as "giving a man a
fish".  Actually, I think in my example, the "hi link" is *easier* to
understand.  You don't have to know how "let" differs from "set", and
why it sometimes but not always needs a "g:" in there to work.  Plus,
having such config variables in place sends the message, "the changes
you can make are limited to these config variables".

I'm updating the documentation in the repository to recommend my
alternative instead ruby_no_identifiers.  There is precedent for this
in other syntax file documentation, including ft-c-syntax.  If nobody
reverts this change, I may do this for other options as well, but the
highlighting code needs to be restructured first in order to enable
this.  I'm leaving ruby_no_identifiers in syntax/ruby.vim itself for
backwards compatibility.



More information about the vim-ruby-devel mailing list