VSCode Python 语言扩展
VSCode Python Language Extension
我正在尝试为 Ribosome .py.dna
个文件创建 VSCode 扩展
基本上,.py.dna
与 python 相同,除了以 .
开头的行应该有注释语法突出显示。
到目前为止,这就是我的 tmLanguage.json
:
{
"name": "RibosomePython",
"patterns": [
{
"include": "#dots"
}
],
"repository": {
"dots": {
"name": "comment.dna",
"begin": "\.",
"end": "$"
}
},
"scopeName": "source.python.dna"
}
这有效,因为以 .
开头的行具有 python 注释语法突出显示。但现在我不确定如何告诉 VSCode 让真正的 Python 语法突出显示其他所有内容。我该怎么做?
我的 package.json
看起来像:
{
"name": "ribosome-dna",
"displayName": "Ribosome DNA",
"description": "Ribosome DNA Syntax Highlighting",
"version": "0.0.1",
"publisher": "rpgillespie",
"engines": {
"vscode": "^1.17.0"
},
"categories": [
"Languages"
],
"contributes": {
"languages": [{
"id": "dna",
"aliases": ["DNA"],
"extensions": [".py.dna"],
"configuration": "./language-configuration.json"
}],
"grammars": [
{
"language": "dna",
"scopeName": "source.python.dna",
"path": "./syntaxes/dna.tmLanguage.json"
}
]
}
}
请注意,我能够通过复制和修改 python 的语法使其按照我想要的方式工作,但这似乎有点过分了。
编辑:
出于好奇,已完成的扩展已发布 here。
只需将 "include": "source.python"
添加到您的 patterns
:
{
"name": "RibosomePython",
"patterns": [
{
"include": "#dots"
},
{
"include": "source.python"
}
],
"repository": {
"dots": {
"name": "comment.dna",
"begin": "\.",
"end": "$"
}
},
"scopeName": "source.python.dna"
}
此功能称为 injection grammar. VSCode added support for this in response to #2793。
我正在尝试为 Ribosome .py.dna
个文件创建 VSCode 扩展
基本上,.py.dna
与 python 相同,除了以 .
开头的行应该有注释语法突出显示。
到目前为止,这就是我的 tmLanguage.json
:
{
"name": "RibosomePython",
"patterns": [
{
"include": "#dots"
}
],
"repository": {
"dots": {
"name": "comment.dna",
"begin": "\.",
"end": "$"
}
},
"scopeName": "source.python.dna"
}
这有效,因为以 .
开头的行具有 python 注释语法突出显示。但现在我不确定如何告诉 VSCode 让真正的 Python 语法突出显示其他所有内容。我该怎么做?
我的 package.json
看起来像:
{
"name": "ribosome-dna",
"displayName": "Ribosome DNA",
"description": "Ribosome DNA Syntax Highlighting",
"version": "0.0.1",
"publisher": "rpgillespie",
"engines": {
"vscode": "^1.17.0"
},
"categories": [
"Languages"
],
"contributes": {
"languages": [{
"id": "dna",
"aliases": ["DNA"],
"extensions": [".py.dna"],
"configuration": "./language-configuration.json"
}],
"grammars": [
{
"language": "dna",
"scopeName": "source.python.dna",
"path": "./syntaxes/dna.tmLanguage.json"
}
]
}
}
请注意,我能够通过复制和修改 python 的语法使其按照我想要的方式工作,但这似乎有点过分了。
编辑:
出于好奇,已完成的扩展已发布 here。
只需将 "include": "source.python"
添加到您的 patterns
:
{
"name": "RibosomePython",
"patterns": [
{
"include": "#dots"
},
{
"include": "source.python"
}
],
"repository": {
"dots": {
"name": "comment.dna",
"begin": "\.",
"end": "$"
}
},
"scopeName": "source.python.dna"
}
此功能称为 injection grammar. VSCode added support for this in response to #2793。