0

我在我的 typescriptreact 文件中添加了一种格式化语言(scss),其中包含以下部分

包.json

"contributes": {
    
    "grammars": [
        {
            "scopeName": "source.wco",
            "path": "./syntaxes/wco.tmLanguage.json",
            "injectTo": ["source.tsx"],
            "embeddedLanguages": {
                "source.css": "css",
                "source.css.scss": "scss"
            }
        }
    ]
}

和 tmLanguage.json 文件:

{
    "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
    "name": "wco",
    "scopeName": "source.wco",
    "injectionSelector": "L:source",
    "patterns": [
        {
            "include": "#style"
        },
        {
            "include": "#style2"
        }

    ],
    "repository": {
        "style": {
            "begin": "<style",
            "end": "<\/style>",
            "name": "source.css.scss",
            "patterns": [
                {
                    "include": "source.css.scss"
                }
            ]
        },
        "style2": {
            "begin": "const html\\s*=\\s*`",
            "end": "`",
            "name": "source.css.scss",
            "patterns": [
                {
                    "include": "source.css.scss"
                }
            ]
        }
    }
}

整个事情按预期工作:

语法高亮效果很好

我似乎无法正常工作的唯一想法是 scss 代码的代码格式。由于 textmate 范围似乎是正确的,我不知道如何为嵌入式语言进行格式化?(使用更漂亮的)

4

0 回答 0