4

I am trying to extend the AL language from Microsoft by adding regions. I can do this manually by going to the vscode extension folder .vscode\extensions\Microsoft.al-0.14.17461 and changing the file al.configuration.json and alsyntax.tmlanguage.

But I want to do this by creating my own VSCode extension. So I created my own extension and copied those specific files to it + adding my specific code. And luckily it worked!

However it only works if I use the entire syntax files and not just with my specific code..

Below is the code of the al.configuration.json, its the folding part between ** that I want to add.

{
    **"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]+)"
}
Gama11
  • 31,714
  • 9
  • 78
  • 100
BartP
  • 91
  • 4
  • ok found it, you need to add injectTo: "contributes": { "grammars": [ { "scopeName": "al.extended", "path": "./syntax/alsyntax.extended.json", "injectTo": [ "source.al" ] } ], – BartP Jul 13 '18 at 22:22

1 Answers1

5

ok found it, you need to add InjectTo

"contributes": {
        "grammars": [
            {
                "scopeName": "al.extended",
                "path": "./syntax/alsyntax.extended.json",
                "injectTo": [ "source.al" ]
            }
        ],
BartP
  • 91
  • 4
  • Can you explain your answer a bit? I'm having trouble getting wordPattern and folding to work in an extension (my first) and not sure if it has anything to do with this. Is source.al part of the existing language or your extension? – aamarks Jun 07 '19 at 21:35
  • Well I guess this answers my question about inject https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#injection-grammars – aamarks Jun 08 '19 at 07:13