2010-06-29 146 views
5

我試圖在Textmate中擴展一些CSS突出顯示。我的方法就是這樣...Textmate語法突出顯示,從另一種語言擴展突出顯示

{ 
    .... 
    patterns = (
     { include = 'source.css'; }, 
     { 
      name = 'support.function'; 
      match = '\..*\);'; 
     }, 
    ); 
} 

問題是「include ='source.css';」。如果我刪除該行。我的自定義匹配器擊中並應用預期的突出顯示。但是,然後我失去了所有預先定義的CSS,突出顯示了我想要的。

我很疑惑我如何覆蓋現有的CSS突出顯示,我包括。想法?

回答

4

我有類似的問題。我猛撞我的頭,然後TextMate IRC頻道中的某個人給我直線:由於某種原因(我忘記了),您需要重新包含您的語言文法。

我的圖案部分,現在看起來像

patterns = (
{ include = 'source.ruby'; }, 
{ include = '$self'; }, 
); 

要更多信息添加到這個例子,這裏是我的包是創造語言語法(在我感興趣的是該文件的一部分,一切都在範圍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'; }, 
); 

}

但是你會發現$ self聲明會將其他模式引入meta.rails.model模式(我認爲這很重要)。

+1

完美的,正是我所期待的。 – 2010-07-06 15:01:12