Roy*_*lak 5 css textmate syntax-highlighting highlighting
我正在尝试在Textmate中扩展一些CSS突出显示.我的方法是这样的......
{
....
patterns = (
{ include = 'source.css'; },
{
name = 'support.function';
match = '\..*\);';
},
);
}
Run Code Online (Sandbox Code Playgroud)
问题是"include ='source.css';".如果我删除该行.我的自定义匹配器命中并应用预期的突出显示.但后来我失去了我想要的所有预定义的CSS突出显示.
我很困惑如何覆盖我所包含的现有css突出显示.想法?
我有类似的问题。我用头撞了它,然后 TextMate IRC 频道中的某人纠正了我:由于某种原因(我忘记了),你需要重新包含你的语言语法。
我的模式部分现在看起来像
patterns = (
{ include = 'source.ruby'; },
{ include = '$self'; },
);
Run Code Online (Sandbox Code Playgroud)
为了向这个示例添加更多信息,这里是我正在创建的包的语言语法(在我感兴趣的文件部分,所有内容都在 meta.rails.model 范围内。也许你没有你的 CSS 包。
patterns = (
{ name = 'meta.rails.model';
comment = "Uses lookahead to match classes that (may) inherit from ActiveRecord::Base; includes 'source.ruby' to avoid infinite recursion";
begin = '(^\s*)(?=class\s+.+ActiveRecord::Base)';
end = '^\1(?=end)\b';
patterns = (
{ include = 'source.ruby'; },
{ include = '$self'; },
);
},
{ name = 'source.ruby.rails.aasm.event';
match = '(aasm_event\W*:\w+)';
captures = { 1 = { name = 'keyword.other.context.ruby.rails.aasm.event'; }; };
},
{ include = 'source.ruby.rails'; },
);
Run Code Online (Sandbox Code Playgroud)
}
但是您会看到 $self 声明将其他模式引入到 meta.rails.model 模式中(我认为这就是为什么这很重要)。