我正在尝试为核糖体 .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 的语法,我能够让它按照我想要的方式工作,但这似乎有点矫枉过正。
编辑:
对于此处发布的好奇的已完成扩展。