More syntax highlighting fun

Doug Kearns dougkearns at gmail.com
Sat Feb 24 05:14:52 EST 2007


On Fri, Feb 23, 2007 at 12:10:53PM -0600, Tim Pope wrote:
> 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 :).

The following are incorrect at the moment:

def end?; end
def end=; end
def end!; end

Here's a couple of quick fixes:

Index: syntax/ruby.vim
===================================================================
RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v
retrieving revision 1.104
diff -u -b -r1.104 ruby.vim
--- syntax/ruby.vim	24 Feb 2007 04:02:50 -0000	1.104
+++ syntax/ruby.vim	24 Feb 2007 10:08:08 -0000
@@ -163,7 +163,7 @@
   syn match  rubyDefine "\<def\>"		nextgroup=rubyMethodDeclaration skipwhite skipnl
   syn match  rubyClass  "\<class\>"		nextgroup=rubyClassDeclaration  skipwhite skipnl
   syn match  rubyModule "\<module\>"		nextgroup=rubyModuleDeclaration skipwhite skipnl
-  syn region rubyBlock start="\<def\>"		matchgroup=rubyDefine end="\<end\>" contains=TOP fold
+  syn region rubyBlock start="\<def\>"		matchgroup=rubyDefine end="\<end\>[?!=]\@!" contains=TOP fold
   syn region rubyBlock start="\<class\>"	matchgroup=rubyClass  end="\<end\>" contains=TOP fold
   syn region rubyBlock start="\<module\>"	matchgroup=rubyModule end="\<end\>" contains=TOP fold
 

Index: syntax/ruby.vim
===================================================================
RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v
retrieving revision 1.104
diff -u -b -r1.104 ruby.vim
--- syntax/ruby.vim	24 Feb 2007 04:02:50 -0000	1.104
+++ syntax/ruby.vim	24 Feb 2007 10:09:34 -0000
@@ -163,7 +163,7 @@
   syn match  rubyDefine "\<def\>"		nextgroup=rubyMethodDeclaration skipwhite skipnl
   syn match  rubyClass  "\<class\>"		nextgroup=rubyClassDeclaration  skipwhite skipnl
   syn match  rubyModule "\<module\>"		nextgroup=rubyModuleDeclaration skipwhite skipnl
-  syn region rubyBlock start="\<def\>"		matchgroup=rubyDefine end="\<end\>" contains=TOP fold
+  syn region rubyBlock start="\<def\>"		matchgroup=rubyDefine end="\<end\>" contains=TOP fold skip="\<end[?!=]"
   syn region rubyBlock start="\<class\>"	matchgroup=rubyClass  end="\<end\>" contains=TOP fold
   syn region rubyBlock start="\<module\>"	matchgroup=rubyModule end="\<end\>" contains=TOP fold
 
<snip>

Regards,
Doug


More information about the vim-ruby-devel mailing list