Treetop 的 Vim 缩进文件(Ruby 解析器)

发布于 2024-08-07 20:47:28 字数 133 浏览 4 评论 0原文

有人见过 Ruby 解析器/生成器 treetop 的 vim 缩进文件吗?我找到了一个 vim 语法高亮文件,但还没有看到缩进。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

孤独患者 2024-08-14 20:47:28

看起来这相当简单 - 我只需创建一个文件

~/.vim/indent/treetop.vim

并制作其唯一内容

runtime! indent/ruby.vim

,然后它似乎就支持我需要的所有内容。我认为它只是没有加载 Ruby 的缩进文件!

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!

不…忘初心 2024-08-14 20:47:28

我不久前在 Vim 或 Emacs 上搜索过这个,但找不到任何东西,所以我开始写我的
Emacs 自己的模式。自从我几乎停止使用 TT 以来,它从来没有得到任何结果,但如果我的记忆
不会失败,你只需要解析类似的内容:

grammar Name
  includes # something like "include Something"

  rule rule_name
    tokens_or_rules {
      inner_method {
      }
    }
    <MyModule>
  end
end

阅读后可能不会太难
这个

PS:请记住,这个语法与 RSpec 使用的语法非常相似,RSpec 是自然的 Ruby,所以也许您可以通过阅读它获得一些帮助。

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.

温柔嚣张 2024-08-14 20:47:28

我不确定是否有直接的 ruby​​ 实现,但是 vim Rails 插件< /a> 很好地处理缩进。

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文