microsoft / vscode-custom-data

Documentation and sample for using VS Code custom data format
MIT License
196 stars 75 forks source link

[Feature] Add `contentType` property to attributes #70

Open pcbowers opened 1 year ago

pcbowers commented 1 year ago

Currently, an attribute can take the following schema (this is an example that illustrates all the possible items that can be included in an attribute):

{
    "name": "onclick",
    "description": {
        "kind": "markdown",
        "value": "# Hello World"
    },
    "valueSet": "x",
    "values": [{
        "name": "test",
        "description": "test test test",
        "references": [{
            "name": "example",
            "url": "https://example.com"
        }]
    }],
    "references": [{
        "name": "example",
        "url": "https://example.com"
    }]
}

There currently is no way to suggest that an attribute may contain something other than a string. For instance, the above attribute, onclick, takes a JavaScript expression. Thus, the attribute should format its contents as JavaScript, not as plaintext.

Since onclick is a supported attribute, JavaScript syntax highlighting within it is already supported:

image

It would be great if we could extend this to custom attributes using a new property such as 'contentType' that would allow one to opt in to different content types. For instance, Alpine.js has a custom attribute called @click that would be styled as plain text when using custom data, but should be styled as JavaScript.