Textmate在哪里可以找到它的语法检查规则?

发布于 2024-10-06 11:29:27 字数 291 浏览 4 评论 0原文

Ruby 1.9.2,Rails 3+ 应用程序。

我在 lambda 块中设置默认值:

scope :order_by, lambda { |field, dir='ASC'|
...

TextMate 告诉我每次保存时此语法都无效。更烦人的是,它把我带到了有问题的行,当我在文件的较低位置工作时,这是一个麻烦,它会把我跳到那里。

自然地,Ruby 会运行文件 a-ok。

在哪里可以找到语法规则以便更改它们?或者以某种方式通过 Ruby 传递它?

Ruby 1.9.2, Rails 3+ app.

I'm setting a default in a lambda block:

scope :order_by, lambda { |field, dir='ASC'|
...

TextMate is telling that this syntax is invalid every time I save. Even more annoyingly, it takes me to the line in question, which is a hassle when I'm working lower in the file and it jumps me up there.

Naturally, Ruby runs the file a-ok.

Where can I find the syntax rules so I can change them? Or is it passing it through Ruby somehow?

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

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

发布评论

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

评论(3

当爱已成负担 2024-10-13 11:29:27

查看 Bundle Editor(在 Bundles 菜单下)——您的案例中的 Ruby 或 Ruby on Rails 捆绑包。捆绑包定义命令(例如“验证语法”)、片段、宏、语法等。

Have a look at the Bundle Editor (under the Bundles menu) — the Ruby or Ruby on Rails bundles in your case. Bundles define commands (such as 'Validate Syntax'), snippets, macros, grammars, etc.

抚你发端 2024-10-13 11:29:27

Ruby Bundle 中的“Validate and Save.tmCommand”文件中也有这一行:
result = #{compiler_ruby} -wc "$TM_FILEPATH" 2>&1

-w 打开警告。
删除“w”对我来说很有效:

result = #{compiler_ruby} -c "$TM_FILEPATH" 2>&1

在更改任何捆绑包后,在 textmate 中,您需要运行:
捆绑 ->捆绑包编辑器 ->重新加载捆绑

包可以在这里找到捆绑包:
〜/库/应用程序支持/TextMate/Bundles

There is also this line in the Ruby Bundle inside the file 'Validate and Save.tmCommand':
result = #{compiler_ruby} -wc "$TM_FILEPATH" 2>&1

the -w turns on warnings.
Removing the 'w' did the trick for me:

result = #{compiler_ruby} -c "$TM_FILEPATH" 2>&1

And after changing any of the bundles, In textmate you need to run:
Bundles -> Bundle Editor -> Reload Bundles

P.S. bundles can be found here:
~/Library/Application Support/TextMate/Bundles

有木有妳兜一样 2024-10-13 11:29:27

我可以通过更改 Ruby > 来解决这个问题验证并保存命令

#!/usr/bin/env ruby

require ENV['TM_SUPPORT_PATH'] + '/lib/textmate'

#compiler_ruby = `which rbx`.strip
#if compiler_ruby.length == 0
  compiler_ruby = ENV['TM_RUBY'] || `which ruby`.strip
#end

result = `#{compiler_ruby} -wc "$TM_FILEPATH" 2>&1`

scopes = ENV['TM_SCOPE'].split
if scopes.include? 'source.ruby.rspec.cucumber.steps'
  result.gsub!(/^.+warning: ambiguous first argument; put parentheses or even spaces$/, '')
end

if result =~ /:(\d+):/
  print result
  TextMate.go_to :line => $1
end

注释掉 5、6 和 8 会强制命令每次使用 TM_RUBY - 确保您在“首选项”>“选项”中设置了此命令。高级> Shell 变量

希望有帮助吗?

I was able to fix this by changing the Ruby > Validate and Save command

#!/usr/bin/env ruby

require ENV['TM_SUPPORT_PATH'] + '/lib/textmate'

#compiler_ruby = `which rbx`.strip
#if compiler_ruby.length == 0
  compiler_ruby = ENV['TM_RUBY'] || `which ruby`.strip
#end

result = `#{compiler_ruby} -wc "$TM_FILEPATH" 2>&1`

scopes = ENV['TM_SCOPE'].split
if scopes.include? 'source.ruby.rspec.cucumber.steps'
  result.gsub!(/^.+warning: ambiguous first argument; put parentheses or even spaces$/, '')
end

if result =~ /:(\d+):/
  print result
  TextMate.go_to :line => $1
end

Commenting out 5,6, and 8 forces the command to use TM_RUBY each time - make sure you have this set in Preferences > Advanced > Shell Variables

Hope that helps?

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