tmlanguage关键字类型是否有任何标准? [英] Are there any standards for tmlanguage keyword types?

查看:94
本文介绍了tmlanguage关键字类型是否有任何标准?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.tmlanguage 文件通过定义键值对列表来工作.正则表达式是键,语法类型是值.这是通过以下XML方式完成的:

 < key> match</key>< string> [0-9]</string><键>名称</键>< string> constant.numeric</string> 

我的主要问题是:如果要由Sublime之类的文本编辑器使用该文件,是否存在一个可以代替 constant.numeric 的值的列表?

解决方案

有关基本介绍,请查看.安装并激活后,只需放置光标,状态栏中就会显示适用于该特定位置的示波器.这在设计配色方案时特别有用,因为您可以轻松查看哪些选择器将突出显示感兴趣的语言功能.

如果您有兴趣,此处使用的配色方案为 Neon ,我设计的目的是使尽可能多的语言看起来尽可能好,涵盖尽可能多的范围.随意浏览它,以了解如何突出显示不同的语言元素;这也可以帮助您设计 .tmLanguage 与其他语言一致.

希望所有这些对您有帮助,祝您好运!

.tmlanguage files work by defining a list of key value pairs. Regular expressions are the keys and the type of syntax is the value. This is done in the following XML-ish manner:

<key>match</key>
<string>[0-9]</string>
<key>name</key>
<string>constant.numeric</string>

My main question is: Is there a list of values that could go in place of constant.numeric if the file is to be used by a text editor like Sublime?

解决方案

For a basic introduction, check out the Language Grammars section of the TextMate Manual. The Naming Conventions section describes some of the base scopes, like comment, keyword, meta, storage, etc. These classes can then be subclassed to give as much detail as possible - for example, constant.numeric.integer.long.hexadecimal.python. However, it is very important to note that these are not hard-and-fast rules - just suggestions. This will become obvious as you scan through different language definitions and see, for example, all the different ways that functions are scoped - meta.function-call, support.function.name, meta.function-call punctuation.definition.parameters, etc.

The best way to learn about scopes is to examine existing .tmLanguage files, and to look through the source of different languages and see what scopes are assigned where. The XML format is very difficult to casually browse through, so I use the excellent PackageDev plugin to translate the XML to YAML. It is then much easier to scan and see what scopes are described by what regexes:

Another way to learn is to see how different language constructs are scoped, and for that I highly recommend using ScopeAlways. Once installed and activated, just place your cursor and the scope(s) that apply to that particular position are shown in the status bar. This is particularly useful when designing color schemes, as you can easily see which selectors will highlight a language feature of interest.

If you're interested, the color scheme used here is Neon, which I designed to make as many languages as possible look as good as possible, covering as many scopes as possible. Feel free to look through it to see how the different language elements are highlighted; this could also help you in designing your .tmLanguage to be consistent with other languages.

I hope all this helps, good luck!

这篇关于tmlanguage关键字类型是否有任何标准?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆