vscode 新语言配置不改变语法颜色
vscode new language configuration not changing syntax colors
我正在尝试为 CPU12 汇编语言的 Visual Studio 代码中的语法高亮创建一种新语言。当我在新的 .asm 文件中使用新语言时,编辑器知道注释字符是(当我键入 ctrl-k ctrl-c 时它会在一行中添加一个分号),但文本是白色的而不是默认注释颜色绿色。我需要指定使用默认的 vscode 主题吗?如果有,在哪里?
package.json
{
"name": "cpu12",
"displayName": "cpu12",
"description": "cpu12",
"version": "0.0.1",
"publisher": "https://github.com/me",
"engines": {
"vscode": "^1.15.0"
},
"categories": [
"Languages"
],
"contributes": {
"languages": [{
"id": "cpu12",
"aliases": ["CPU12", "cpu12"],
"extensions": [".asm",".inc"],
"configuration": "./language-configuration.json"
}],
"grammars": [{
"language": "cpu12",
"scopeName": "source.cpu12",
"path": "./syntaxes/cpu12.tmLanguage.json"
}]
}
}
语言-configuration.json
{
"comments": {
// symbol used for single line comment. Remove this entry if your language does not support line comments
"lineComment": ";"
},
// symbols used as brackets
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
// symbols that that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}
(我的./syntaxes/cpu12.tmLanguage.json
是空的。)
问题实际上是因为 ./syntaxes/cpu12.tmLanguage.json
是空的。您需要在 .json 文件中指定如何为行注释着色:
./syntaxes/cpu12.tmLanguage.json
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "cpu12",
"scopeName": "source.cpu12",
"patterns": [
{
"comment": "Line Comments -- Asterisk only works at beginning of line",
"match": "((;|^\*).*$)",
"captures": {
"1" :{
"name": "comment.line.cpu12"
}
}
}
]
}
我正在尝试为 CPU12 汇编语言的 Visual Studio 代码中的语法高亮创建一种新语言。当我在新的 .asm 文件中使用新语言时,编辑器知道注释字符是(当我键入 ctrl-k ctrl-c 时它会在一行中添加一个分号),但文本是白色的而不是默认注释颜色绿色。我需要指定使用默认的 vscode 主题吗?如果有,在哪里?
package.json
{
"name": "cpu12",
"displayName": "cpu12",
"description": "cpu12",
"version": "0.0.1",
"publisher": "https://github.com/me",
"engines": {
"vscode": "^1.15.0"
},
"categories": [
"Languages"
],
"contributes": {
"languages": [{
"id": "cpu12",
"aliases": ["CPU12", "cpu12"],
"extensions": [".asm",".inc"],
"configuration": "./language-configuration.json"
}],
"grammars": [{
"language": "cpu12",
"scopeName": "source.cpu12",
"path": "./syntaxes/cpu12.tmLanguage.json"
}]
}
}
语言-configuration.json
{
"comments": {
// symbol used for single line comment. Remove this entry if your language does not support line comments
"lineComment": ";"
},
// symbols used as brackets
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
// symbols that that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}
(我的./syntaxes/cpu12.tmLanguage.json
是空的。)
问题实际上是因为 ./syntaxes/cpu12.tmLanguage.json
是空的。您需要在 .json 文件中指定如何为行注释着色:
./syntaxes/cpu12.tmLanguage.json
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "cpu12",
"scopeName": "source.cpu12",
"patterns": [
{
"comment": "Line Comments -- Asterisk only works at beginning of line",
"match": "((;|^\*).*$)",
"captures": {
"1" :{
"name": "comment.line.cpu12"
}
}
}
]
}