microsoft / azure-devops-extension-sample

Sample web extension for Azure DevOps
MIT License
233 stars 153 forks source link

CodeEditorContribution syntax highlighting not working #128

Open mmeester opened 1 year ago

mmeester commented 1 year ago

I'm trying to get the CodeEditorContribution sample to work to have syntax highlighted in repos, but whatever I try it's not working and my code looks like being plain text all the time

jincao1 commented 1 month ago

Did you ever manage to get this working?

jincao1 commented 1 month ago

This seems to be how you declare the syntax highlighting now I think. You don't even need to do any typescript but would need to convert the Monaco syntax into the contribution properties... Would be good if these examples were kept up to date and is functional...

From this repo: https://github.com/SuperNowyNick/az-devops-bpmn-tools/blob/913a2cfb6a0680c4e1537c461a98ed34a8a17107/vss-extension.json

{
    "id": "bpmn-language",
    "type": "ms.vss-features.code-editor-language",
    "description": "Add BPMN syntax highlighting",
    "targets": ["ms.vss-features.editor"],
    "properties": {
        "extensions": [".bpmn"],
        "mimetypes": ["application/bpmn+xml"],
        "language": {
            "displayName": "BPMN",
            "defaultToken": "",
            "tokenPostfix": ".bpmn",
            "ignoreCase": true,
            "tokenizer": {
                "root": [
                    ["<\\?xml", "metatag", "@xmlInfo"],
                    ["<!--", "comment", "@comment"],
                    [
                        "(<)(\\w+)",
                        [
                            "delimiter",
                            { "token": "tag", "next": "@bpmn" }
                        ]
                    ],
                    [
                        "(<\\/)(\\w+)(:)(\\w+)",
                        ["delimiter", "tag", "delimiter", "type"]
                    ],
                    ["</", "delimiter"],
                    ["\\/>", "delimiter"],
                    ["[^<]+"]
                ],
                "xmlInfo": [
                    [">", "metatag", "@pop"],
                    ["[^>]+", "metatag.content"]
                ],
                "comment": [
                    ["-->", "comment", "@pop"],
                    ["[^-]+", "comment.content"],
                    [".", "comment.content"]
                ],
                "bpmn": [
                    ["(:)(\\w+)", ["delimiter", "type"]],
                    ["\"([^\"]*)\"", "attribute.value"],
                    ["'([^\"]*)'", "attribute.value"],
                    ["([\\w\\-]+)(=)", ["attribute.name", "delimiter"]],
                    ["\\/?>", "delimiter", "@pop"]
                ]
            }
        }
    }
}

Managed to get it to work doing this syntax.