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.
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.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 {
}
}
<MyModule>
end
end
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.
It seems like it's fairly easy - I just create a file
~/.vim/indent/treetop.vim
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!
I copied the one from this guy: http://code.google.com/p/dot-files/source/browse/trunk/.vim/syntax/treetop.vim?spec=svn149&r=149
Works beautifully.