Vim indenting file for Treetop (Ruby parser)

Has anyone seen a vim indent file for treetop, the Ruby parser/generator? I've found a vim syntax highlighting file, but haven't seen one for indentation.

13.10.2009 20:25:12

I'm not sure if there's a straight ruby implementation, but the vim rails plugin handles indentation quite well.

You could always just edit this so that it supports ruby files that aren't within a rails project. Check it out.

16.10.2009 21:34:55

I searched for this a while ago for Vim or Emacs and couldn't find anything so I started writing my own mode for Emacs. It never got to anything since I pretty much stopped using TT but if my memory doesn't fail you only have to parse something like:

grammar Name
  includes # something like "include Something"

  rule rule_name
    tokens_or_rules {
      inner_method {

Which might not be too hard after reading this.

PS: Keep in mind that this grammar is really similar to the one used by RSpec which is natural Ruby so maybe you could get some help by reading that.

23.10.2009 00:27:29

It seems like it's fairly easy - I just create a file


and make its sole contents

runtime! indent/ruby.vim

and it seems to then support all I need. I think it just wasn't loading Ruby's indentation file!

23.10.2009 00:33:41
Treetop files aren't Ruby though. They bear a strong resemblance, but that's all. Are you sure that using Ruby's indent file won't cause any problems?
Bob Aman 25.10.2009 18:22:09
it seems to work pretty well so far. parts like do / end seem to be picked up correctly.
Peter 27.10.2009 00:43:14
5.08.2010 15:31:16