VSCode Python语言扩展

吉莱斯皮

我试图创建一个VSCode扩展核糖体 .py.dna文件

基本上,.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的语法,我能够使它按我想要的方式工作,但这似乎有点过头了。

编辑:

对于好奇的,已完成的扩展,请在此处发布

Gama11

只需添加"include": "source.python"到您的patterns

{
    "name": "RibosomePython",
    "patterns": [
        {
            "include": "#dots"
        },
        {
            "include": "source.python"
        }
    ],
    "repository": {
        "dots": {
            "name": "comment.dna",
            "begin": "\\.",
            "end": "$"
        }
    },
    "scopeName": "source.python.dna"
}

此功能称为注入语法VSCode响应#2793添加了对此的支持

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TOP 榜单

热门标签

归档