String interpolation highlighting (was Re: rubyFunction, rubyClass, and rubyModule no longer highlighted)
Tim Pope
vim-ruby-devel at tpope.info
Mon Feb 26 13:59:04 EST 2007
On Mon, Feb 26, 2007 at 05:44:56PM +0100, Nikolai Weibull wrote:
> On 2/26/07, Tim Pope <vim-ruby-devel at tpope.info> 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.
>
> Uh, oh. It sounds as if we're going overboard here. Sorry, no ideas,
> just complaints. Still, it's going to be very hard to match every
> weird part of the Ruby grammar, so optimizing for the common cases
> makes things a lot easier. I'm sure there's code out there that
> actually contains the line "#{if true then 1 end}", but I don't see
> why we should try so damn hard to match it beyond matching the
> delimiters. If you're silly enough to put a lot of junk in your
> string interpolations, then syntax highlighting isn't really going to
> help you much.
Agreed, regarding strings. However, I thing my second example,
3.times { if true then 1 end }
is a bit more reasonable. A fix for this would probably fix the
string interpolation for free.
Cheers,
Tim
More information about the vim-ruby-devel
mailing list