How can I extend existing tmLanguage Colorizer/ Syntax highlighter?

别说谁变了你拦得住时间么 提交于 2019-12-12 02:54:16

问题


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:


You should probably at least look at the Babel JavaScript syntax definition to see what its base scope is. In this case it's source.js.jsx, not text.javascript.basic. Programming languages generally use the source scope, while text and markup languages (Markdown, HTML, XML, etc.) use text. If you're going to be developing syntax definitions, I highly recommend using the ScopeAlways and/or ScopeHunter plugins for determining the scopes active at the current cursor location.



来源:https://stackoverflow.com/questions/36650970/how-can-i-extend-existing-tmlanguage-colorizer-syntax-highlighter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!