tokenColors结构:
"tokenColors": [
{
"name": "Comment",
"scope": [
"comment",
"keyword.control",
"keyword.operator",
...
],
"setting": {
"color": "#000000"
}
}
]
scope:
vscode官网使用TextMate语法作为主要的标记引擎,vscode官网没有太详细的说明,我在sublime文档中找到了比较详细直白的说明:
https://www.sublimetext.com/docs/3/scope_naming.html
,sublime也是支持TextMate语言语法的,TextMate文档:https://macromates.com/manual/en/language_grammars#naming_conventions
,文档中说明了TextMate语法的命名约定,配置项多且复杂,系统的使用方法还在研究中,这里列出一些目前我开发中用到的作用域表示含义
comment
- comment.line:一行注释
- double-slash:
//
- double-dash:
--
- number-sign:
#
- percentage:
%
- double-slash:
- comment.block:多行注释:
/*...*/
和<!--...-->
- documentation:嵌入式文档
constant:各种形式的常数
- constant.numeric:数字
- constant.character.escape:转义字符如
\n
和\x20
- constant.language:
true/false/null
- constant.language.null:
null
- constant.language.boolean.true:
true
- constant.language.boolean.false:
false
- constant.other.placeholder:格式化占位符
- constant.other:其他常量,如css中的颜色
entity
- entity.name.namespace:命名空间,包和模块
- entity.name.constant:常数
- entity.name.label:类似goto的构造的标签
- entity.name.class.ford-decl:在C和c++中使用
- entity.other.inherited-class:列为继承的类或已实现的接口/特征的类
- entity.name
- entity.name.function:函数名称
- entity.name.type:注释中的
{boolean}
- entity.name.tag:标签名颜色
- entity.name.section:标记语言(如
markdown
)的标题名称
- entity.other
- entity.other.inherited-class:超类/基类名称
- entity.other.attribute-name:标签的属性名称
id/class
- entity.other.attribute-name.id.css:如
#box
- entity.other.attribute-name.class.css:如
.box
invalid:无效的
- invalid.illegal:非法使用
- invalid.deprecated:使用已启用的API函数或使用具有严格HTML的样式
keyword
控制关键字(if、try、end、while
)
- keyword.control
- keyword.control.conditional
- keyword.control.import
运算符通常都是符号,根据运算符的类型引用特定的变体
- keyword.operator
- keyword.operator.assignment
- keyword.operator.arithmetic
- keyword.operator.bitwise
- keyword.operator.logical:
=
包含标点符号的关键字(@
)
- punctuation.definition.keyword
操作者是一个字(and or not
)
- keyword.operator.word
所有其余的非运营商关键字都属于other
- keyword.other:css单位
px
- keyword.other.unit.px.css
- keyword.other.unit.fr.css
- keyword.other.unit.s.css
- keyword.other.unit.percentage.css
markup
标记作用域用于内容,而不是代码(包括Markdown和Textile等语法)
- markup.underline:带下划线
- link:带下划线的链接
- markup.bold:粗体
- markup.heading:标题
- marker.italic:斜体
- marker.list:列表
- numbered:编号
- unnumbered:未编号
- marker.quote:引号
- marker.raw:逐字记录的文本
- markup.raw.inline
- markup.raw.block
- marker.other:其他
- markup.inserted:插入
- markup.deleted:删除
- markup.fenced_code.block.markdown:代码块
meta
元作用域用于范围更大的代码或标记部分,通常包含多个更具体的范围
数据结构的完整内容
- meta.function-call:函数名称(包括完整路径)和所有参数
- meta.block:用{}描述的代码段使用以下范围,在{}内的字符使用另外的punctuation范围
- punctuation.section.block.begin
- punctuation.section.block.end
- meta.braces:
()
和[]
- meta.brace.square.js:
[]
- meta.tag:HTML和xml标签
- meta.path:完整的标识符
- meta.paragraph:标记语言的段落
- meta.object-literal.key.js:对象里的属性名
- meta.structure.dictionary.json:json文件的
{}
的高亮
punctuation.
- punctuation.separator:
,
和:
- punctuation.terminator:
;
和其他语句终止符 - punctuation.separator.continuation:行继续字符
- punctuation.accessor:
.
- punctuation.section:css类的
{}
- punctuation.definition.template-expression:插值表达式
$
符 - punctuation.definition.binding-pattern:对象展开运算符
- punctuation.definition.parameters:函数的
()
- punctuation.definition.block:
@ {}
- punctuation.definition.tag:同meta.tag,权重更高,.vue中meta.tag不会改变template标签颜色,punctuation能改变
- punctuation.definition.list:markdown中列表的序号
- punctuation.definition.dictionary:json文件的
{}
,权重更高 - punctuation.definition.array:json文件的
[]
,权重更高 - punctuation.support:json文件属性名的
""
source
应用于整个源代码文件
- source
storage
- storage.type:
const
、function
、=>
的颜色 - storage.type.function:
function
、=>
的颜色 - storage.modifier:影响变量,函数或数据结构的存储的关键字如
const
string
- string.quoted:带引号的字符串
- single:
''
- double:
""
- triple:三引号
- other:其他
- single:
- unquoted:未加引号
- interpolated:被评估的字符串:
$()
- regexp:正则表达式
- other:其他
- punctuation.definition.string:字符串引号颜色
字符串的整体以及所有的标点,前缀,后缀和插值:
- meta.string
插值表达式的标点 - punctuation.section.interpolation.begin
- punctuation.section.interpolation.end
- source.language-suffix.embedded:在标点之间的插值表达式
support.
- support.function:如
log
- support.class:如
console
- support.type:
module.export
- support.constant:css参数
- support.variable:框架提供的变量
- support.other:其他内容
- support.type.property-name:css属性颜色
text
- text.html:html
- text.xml:xml
- text.html.markdown:markdown文本颜色
variable
- variable.other:声明的变量
- variable.language:
this
、super
等 - variable.parameter:函数参数
- variable.other.constant:
const
声明的不可变变量的颜色 - variable.other.readwrite:
let
、var
声明的变量的颜色 - variable.other.member:类或其他数据结构的字段,属性,成员
- variable.other.object:
document
- variable.other.object.property:调用对象属性方法
- variable.function:函数和方法名称的作用域,但仅限于调用时
- punctuation.definition.variable:作为变量名称一部分的符号如
$
- variable.annotation:作为数值一部分的标识符中的最终标签
- punctuation.definition.annotation:用于描述注释的前导符号