문제

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.

도움이 되었습니까?

해결책

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 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.

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top