String interpolation highlighting (was Re: rubyFunction, rubyClass, and rubyModule no longer highlighted)

Doug Kearns dougkearns at gmail.com
Wed Feb 28 05:08:13 EST 2007


On Mon, Feb 26, 2007 at 09:21:40AM -0600, Tim Pope wrote:
> On Mon, Feb 26, 2007 at 08:56:47PM +1100, Doug Kearns wrote:
> > FWIW, I suspect that some of the highlighting will break when in an
> > interpolation region since it makes assumptions about what can appear
> > before and after syntax 'elements'.  When I wrote these I didn't do so
> > with this new addition in mind.  Have you come across any yet?
> 
> No, but it didn't take much searching:
> 
> "#{if true then 1 end}"
> 
> However, syntax highlighting also fails on
> 
> 3.times { if true then 1 end }
> 
> Of these two, the latter is more serious because it affects future end
> highlighting.
> 
> Adding { to the monster regexp setting off if/unless does not fix
> this.  Apparently Vim doesn't like backtracking through the beginning
> of a region definition.  I'll investigate a bit more; let me know if
> you have any ideas.

This seems to work:


Index: syntax/ruby.vim
===================================================================
RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v
retrieving revision 1.115
diff -u -r1.115 ruby.vim
--- syntax/ruby.vim	27 Feb 2007 13:17:36 -0000	1.115
+++ syntax/ruby.vim	28 Feb 2007 10:08:14 -0000
@@ -183,7 +183,7 @@
   " statements without *do*
   syn region rubyNoDoBlock	  matchgroup=rubyControl     start="\<begin\>" end="\<end\>" contains=TOP fold
   syn region rubyCaseBlock	  matchgroup=rubyConditional start="\<case\>"  end="\<end\>" contains=TOP fold
-  syn region rubyConditionalBlock matchgroup=rubyConditional start="\%(^\|\.\.\.\=\|[,;=([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\zs\%(if\|unless\)\>" end="\<end\>" contains=TOP fold
+  syn region rubyConditionalBlock matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{,;=([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\%(if\|unless\)\>" end="\<end\>" contains=TOP fold
   syn keyword rubyConditional then else when  contained containedin=rubyCaseBlock
   syn keyword rubyConditional then else elsif contained containedin=rubyConditionalBlock
 

Regards,
Doug


More information about the vim-ruby-devel mailing list