visual-studio-code - VSCode 扩展 : embed standard language in mine

标签 visual-studio-code vscode-extensions

我需要在我的语言扩展中嵌入标准语言(例如 JavaScript )。这意味着我想看到自动完成、语法高亮等,如 file.js .我可以这样做吗(如何)?

感谢您提供任何示例!

最佳答案

您可以继续 abc-lang示例在 Embedded Languages附加语法指南 syntaxes/abc.tmLanguage.json :

{
    "scopeName": "source.abc",
    "patterns": [ { "include": "#expression" } ],
    "repository": {
        "expression": {
            "patterns": [
                { "include": "#letter" },
                { "include": "#paren-expression" },
                { "include": "#code" }
            ]
        },
        "letter": {
            "match": "a|b|c",
            "name": "keyword.letter"
        },
        "paren-expression": {
            "begin": "\\(",
            "end": "\\)",
            "beginCaptures": {
                "0": { "name": "punctuation.paren.open" }
            },
            "endCaptures": {
                "0": { "name": "punctuation.paren.close" }
            },
            "name": "expression.group",
            "patterns": [ { "include": "#expression" } ]
        },
        "code": {
            "begin": "```js",
            "end": "```",
            "beginCaptures": {
                "0": { "name": "punctuation.code.open" }
            },
            "endCaptures": {
                "0": { "name": "punctuation.code.close" }
            },
            "name": "meta.embedded.block.javascript",
            "patterns": [ { "include": "source.js" } ]
        }
    }
}

Matt 评论的固定链接是 https://github.com/microsoft/vscode/blob/5712574281bb096a2dd4ceda7e266d507f775b45/extensions/html/syntaxes/html.tmLanguage.json#L1936

关于visual-studio-code - VSCode 扩展 : embed standard language in mine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48984683/

相关文章:

vscode-extensions - 在 VS Code 上通过 ftp-simple 扩展上传时,如何为 "overwrite"做快捷方式

c - VSCode 扩展自动生成 C 文档字符串?

visual-studio-code - 如何在 vscode 语言服务器实现的 onDidChangeTextDocument 中获取整个文档文本?

c# - 多个并行 VSCode 调试器

ssh - 通过Mobaxterm的VSCode无法移动,调整大小或最大化

ios - Flutter 运行 - 无法构建 iOS 应用程序 - 命令 PhaseScriptExecution 失败,退出代码非零

visual-studio-code - Prettier 无法在我的 vscode 上运行。我已将其安装在我的 vscode 上并执行所有重要设置

docker - vscode devcontainers - 为什么构建两个图像?

python - 没有名为 'numpy' : Visual Studio Code 的模块

visual-studio-code - 如何显示Visual Studio Code中安装的扩展?