如何使用扩展名将语法和配置添加到现有VSCode语言扩展名中?

时间:2018-07-13 21:42:34

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

我正在尝试通过添加区域来扩展Microsoft的AL语言。通过转到vscode扩展文件夹.vscode \ extensions \ Microsoft.al-0.14.17461并更改文件al.configuration.json和alsyntax.tmlanguage,可以手动执行此操作。

但是我想通过创建自己的VSCode扩展来做到这一点。因此,我创建了自己的扩展名,并将这些特定文件复制到其中,并添加了特定代码。幸运的是它起作用了!

但是,仅当我使用整个语法文件而不仅仅是我的特定代码时,它才起作用。

下面是al.configuration.json的代码,它是我要添加的**之间的折叠部分。

{
    **"folding": { 
        "markers": { 
        "start": "^\\s*//\\s*#region\\b", 
        "end": "^\\s*//\\s*#endregion\\b" 
        }** 
        },
    "brackets": [
        ["{", "}"],
        ["[", "]"],
        ["(", ")"],
        ["BEGIN", "END;"],
        ["begin", "end;"],
        ["Begin", "End;"]
    ],
    "autoClosingPairs": [
        { "open": "BEGIN", "close": "END;", "notIn": ["string", "comment"] },
        { "open": "begin", "close": "end;", "notIn": ["string", "comment"] },
        { "open": "Begin", "close": "End;", "notIn": ["string", "comment"] },
        { "open": "{", "close": "}" },
        { "open": "[", "close": "]" },
        { "open": "(", "close": ")" },
        { "open": "'", "close": "'", "notIn": ["string", "comment"] },
        { "open": "\"", "close": "\"", "notIn": ["string"] }
    ],
    "surroundingPairs": [
        ["'", "'"],
        ["\"", "\""]
    ],
    "wordPattern": "(\"(?:(?:\\\"\\\")|[^\\\"])*\")|(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)"
}

1 个答案:

答案 0 :(得分:3)

确定找到它,您需要添加InjectTo

"contributes": {
        "grammars": [
            {
                "scopeName": "al.extended",
                "path": "./syntax/alsyntax.extended.json",
                "injectTo": [ "source.al" ]
            }
        ],