rubyFunction, rubyClass, and rubyModule no longer highlighted

Doug Kearns dougkearns at gmail.com
Fri Feb 23 03:47:33 EST 2007


On Sun, Feb 18, 2007 at 08:07:21PM -0600, Tim Pope wrote:
> On Mon, Feb 19, 2007 at 12:43:43PM +1100, Doug Kearns wrote:
> > So, unfortunately, this won't work.
> 
> I've already committed.  Since none of the three patterns is perfect,
> I guess we need to come up with something different.

Yes, I guess it's time to rethink the way this is done.  Just a couple
of quick comments on some of your changes below.

Index: syntax/ruby.vim
===================================================================
RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v
retrieving revision 1.95
retrieving revision 1.97
diff -u -r1.95 -r1.97
--- syntax/ruby.vim     8 Nov 2006 13:01:57 -0000       1.95
+++ syntax/ruby.vim     20 Feb 2007 22:52:49 -0000      1.97
@@ -150,14 +150,14 @@

 " Expensive Mode - colorize *end* according to opening statement
 if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive")
-  syn region rubyFunction matchgroup=rubyDefine start="\<def\(\s\+\)\@="    end="\%(\s*\%(\s\|(\|;\|$\|#\)\)\@=" oneline
-  syn region rubyClass   matchgroup=rubyDefine start="\<class\(\s\+\)\@="  end="\%(\s*\%(\s\|<\|;\|$\|#\)\)\@=" oneline
-  syn match  rubyDefine   "\<class\ze<<"
-  syn region rubyModule   matchgroup=rubyDefine start="\<module\(\s\+\)\@=" end="\%(\s*\%(\s\|;\|$\|#\)\)\@="    oneline
+  syn region rubyFunction matchgroup=rubyDefine start="\<def\>\s*"    end="\%(\s*\%(\s\|(\|;\|$\|#\)\)\@=" oneline contains=rubyPseudoVariable

Is there a reason you think this is a better start pattern than
\<def\s\+, or \<def\_s\+, which is closer to how the parser works?  Am I
missing something?  Whilst not a big deal this now allows incorrect
syntax (like def.foobar) to be highlighted.  You can probably find an
orange for my apple though. ;-)

How about reverting to this in the interim?

syn region rubyFunction matchgroup=rubyDefine start="\<def\s\+" end="\ze\%([[:space:](;#]\|$\)" oneline contains=rubyPseudoVariable

+  syn region rubyClass   matchgroup=rubyType   start="\<class\>\s*"  end="\%(\s*\%(\s\|<\|;\|$\|#\)\)\@=" oneline
+  syn match  rubyType     "\<class\ze\s*<<"

This line can actually be removed if we use the pattern you've changed it to
above.  It was just a special case since it's the only time something other
than \s can follow the class keyword.

+  syn region rubyModule   matchgroup=rubyType   start="\<module\>\s*" end="\%(\s*\%(\s\|;\|$\|#\)\)\@="          oneline

   syn region rubyBlock start="\<def\>"   matchgroup=rubyDefine end="\<end\>" contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo nextgroup=rubyFunction fold
-  syn region rubyBlock start="\<class\>"  matchgroup=rubyDefine end="\<end\>" contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo nextgroup=rubyClass   fold
-  syn region rubyBlock start="\<module\>" matchgroup=rubyDefine end="\<end\>" contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo nextgroup=rubyModule  fold
+  syn region rubyBlock start="\<class\>"  matchgroup=rubyType   end="\<end\>" contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo nextgroup=rubyClass   fold
+  syn region rubyBlock start="\<module\>" matchgroup=rubyType   end="\<end\>" contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo nextgroup=rubyModule  fold

   " modifiers
   syn match  rubyControl "\<\%(if\|unless\|while\|until\)\>" display

<snip>

Regards,
Doug


More information about the vim-ruby-devel mailing list