如何扩展现有的tmLanguage

如何扩展现有的tmLanguage

本文介绍了如何扩展现有的tmLanguage Colorizer/语法荧光笔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试扩展 https://github.com/dzannotti/vscode-babel/blob/master/syntaxes/Babel%20Language.json ,但我的所有尝试只会导致完全覆盖,而使文本空白.我不想混蛋,只需将代码复制到荧光笔中即可.

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.

这是我目前的尝试:

   <?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

推荐答案

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

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.

这篇关于如何扩展现有的tmLanguage Colorizer/语法荧光笔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 20:07