PATCH: highlighting optional 'do' in loops

Doug Kearns dougkearns at gmail.com
Wed Aug 17 10:39:54 EDT 2005


This should allow for the optional 'do' and ':' in looping constructs
(for|until|while) to mostly be highlighted correctly...mostly...

Regards,
Doug


Index: syntax/ruby.vim
===================================================================
RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v
retrieving revision 1.58
diff -u -r1.58 ruby.vim
--- syntax/ruby.vim	17 Aug 2005 12:43:27 -0000	1.58
+++ syntax/ruby.vim	17 Aug 2005 14:23:21 -0000
@@ -148,7 +148,7 @@
   syn match  rubyControl "\<\%(if\|unless\|while\|until\)\>" display
 
   " *do* requiring *end*
-  syn region rubyDoBlock matchgroup=rubyControl start="\%(\<\%(for\|until\|while\)\s.*\s\)\@<!do\>" end="\<end\>" contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo fold
+  syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo fold
 
   " *{* requiring *}*
   syn region rubyCurlyBlock start="{" end="}" contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo fold
@@ -157,10 +157,8 @@
   syn region rubyNoDoBlock matchgroup=rubyControl start="\<\%(case\|begin\)\>" start="\%(^\|\.\.\.\=\|[;=([<>~+-\*/]\)\s*\zs\%(if\|unless\)\>" end="\<end\>" contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo fold
 
   " statement with optional *do*
-  syn region rubyOptDoBlock matchgroup=rubyControl start="\<for\>" start="\%(^\|;\)\s*\zs\%(while\|until\)\>" end="\<end\>" contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo fold
-
-  " optional *do*
-  syn match  rubyControl "\%(\<\%(for\|until\|while\)\s.*\s\)\@<=\%(do\|:\)\>"
+  syn region rubyOptDoLine matchgroup=rubyControl start="\<\%(for\|until\|while\)\>" end="\%(\<do\>\|:\)" end="\ze\%(;\|$\)" oneline contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo
+  syn region rubyOptDoBlock start="\<\%(for\|until\|while\)\>" matchgroup=rubyControl end="\<end\>" contains=ALLBUT, at rubyExtendedStringSpecial,rubyTodo nextgroup=rubyOptDoLine fold
 
   if !exists("ruby_minlines")
     let ruby_minlines = 50


More information about the vim-ruby-devel mailing list