How can I extend existing tmLanguage Colorizer/ Syntax highlighter?

时间:2016-04-15 15:18:01

标签: sublimetext2 syntax-highlighting visual-studio-code tmlanguage

I'm trying to extend https://github.com/dzannotti/vscode-babel/blob/master/syntaxes/Babel%20Language.json but all my attempts just result in a complete override, leaving the text blank. I'd rather not be a jerk and just copy the code into my highlighter.

I want to extend the colorizer and just add my patterns ontop of it.

Here's my current attempt:

   <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
       <key>fileTypes</key>
       <array>
          <string>js</string>
       </array>
       <key>name</key>
       <string>Handlebars (Ember.js)</string>
       <key>patterns</key>
       <array>
          <dict>
             <key>actions</key>
             <string>actions</string>
             <key>match</key>
             <string>actions</string>
             <key>name</key>
             <string>keyword</string>
          </dict>
          <dict>
         <key>include</key>
         <string>text.javascript.basic</string>
      </dict>

   </array>
   <key>scopeName</key>
   <string>source.js.jsx</string>

I was trying to do what's in this thread but it doesn't work

1 个答案:

答案 0 :(得分:0)

您应该至少查看Babel JavaScript语法定义以查看其基本范围。在这种情况下,它是source.js.jsx,而不是text.javascript.basic。编程语言通常使用source范围,而文本和标记语言(Markdown,HTML,XML等)使用text。如果您要开发语法定义,我强烈建议您使用ScopeAlways和/或ScopeHunter插件来确定当前光标位置处的活动范围。