BJury
BJury

Reputation: 2604

Embedding C# Language in an Visual Studio Code Extension

I am trying to embed c# syntax highlighting in a VSC Extension.

My tmLanguange.json is as follows

{
    "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
    "name": "CS Asm",
    "patterns": [
        {
            "include":"#csasm"
        }
    ],
    "repository": {
        "csasm" :{
            "patterns": [{
                "name" : "meta.embedded.block.bmasm",
                "begin": "@{",
                "end": "}",
                "patterns" : [{
                    "include" : "source.csharp"
                }]
            }]
        }
    },
    "scopeName": "source.csasm"
}

However this doesn't produce any highlighting within VSC. If I change source.csharp to something else it does work.

Normal .cs files are highlighted properly, so I assume there is a 'csharp' extension loaded to provide the syntax rules.

Is there something special about C#?

Upvotes: 1

Views: 197

Answers (1)

Lex Li
Lex Li

Reputation: 63133

Because Microsoft defines source.cs not source.csharp,

https://github.com/microsoft/vscode/blob/main/extensions/csharp/package.json#L33

Upvotes: 2

Related Questions