VSCode多语言扩展无法加载第二语言的语法

时间:2019-09-08 21:30:38

标签: visual-studio-code grammar vscode-extensions

我正在构建VSCode扩展,以添加对多种语言的支持。我已经完成了第一个,现在正在研究第二个。但是,即使Visual Studio可以识别,打开第二个文件时也不会加载第二种语言的语法。

我尝试删除我制作的第一种语言,但是第二种语言仍然拒绝加载。

package.json:

"contributes": {
        "languages": [
            {
                "id": "ti-basic",
                "aliases": [
                    "Ti-BASIC",
                    "ti-basic"
                ],
                "extensions": [
                    ".tibasic"
                ],
                "configuration": "./tibasic-language-configuration.json"
            },
            {
                "id": "ez80-asm",
                "aliases": [
                    "ez80-Assembler"
                ],
                "extensions": [
                    ".asm",
                    ".ez80",
                    ".inc"
                ],
                "configuration": "./ez80-language-configuration.json"
            }
        ],
        "grammars": [
            {
                "language": "ti-basic",
                "scopeName": "source.tibasic",
                "path": "./syntaxes/ti-basic.tmLanguage.json"
            },
            {
                "language": "ez80-asm",
                "scopeName": "source.asm",
                "path": "./syntaxes/ez80-asm.tmLanguage.json"
            }
        ]
    }

/syntaxes/ez80-asm.tmLanguage.json:

{
    "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
    "name": "ez80-Assembler",
    "patterns": [
        {
            "include": "#comments"
        },
        {
            "include": "#constants"
        },
        {
            "include": "#supports"
        }
    ],
    "repository": {
        "comments": {
            "patterns": [{
                "name": "comment.line.semicolon.ez80-asm",
                "match": "^;"
            },
            {
                "name": "comment.block.ez80-asm",
                "begin": "#comment",
                "end": "#endcomment"
            }]
        },
        "constants": {
            "patterns": [{
                "name": "constant.numeric.ez80-asm",
                "match": "(\\d)|($[0-9A-Fa-f]|(%[0-1])"
            }]
        },
        "supports": {
            "patterns": [{
                "name": "support.function.ez80-asm",
                "match": "adc|add|and|bit|call|ccf|cp|cpd|cpdr|cpi|cpir|cpl|daa|dec|di|djnz|ei|ex|exx|halt|im|inc|jp|jr|ld|ldd|lddr|ldi|ldir|lea|mlt|neg|nop|or|pea|pop|push|res|ret|reti|retn|rl|rla|rlc|rlca|rld|rr|rra|rrc|rrca|rrd|rsmix|rst|sbc|scf|set|sla|slp|sra|srl|stmix|sub|tst|xor|in|in0|ind|ind2|ind2r|indm|indmr|indr|indrx|ini|ini2|ini2r|inim|inimr|inir|inirx|otdm|otdmr|otdrx|otim|otimr|otirx|out|out0|outd|outd2|outd2r|outdr|outi|outi2|outi2r|outir|tstio"
            },
            {
                "name": "support.variable.ez80-asm",
                "match": "a|af|b|bc|c|d|de|e|h|hl|i|ix|iy|l|r|hx|hy|ixh|ixl|sll|iyh|iyl|lx|l"
            }]
        }
    },
    "scopeName": "source.asm"
}

每当我加载具有匹配文件类型的文件时,VSCode就会识别出我的语言存在: example 1 注意右下角的ez80-Assembler。 但是,如果我使用范围检查器查看范围: example 2

错误可能是我忽略的很小的东西。帮助找到它非常感谢。

1 个答案:

答案 0 :(得分:0)

错误是我的错。我的某处括号不完整。如果您遇到这种情况,请按ctrl-shift-i打开调试菜单并检查错误。