Skip to content

[json] colorize string literals based on language information coming from schemas #224581

@voxpelli

Description

@voxpelli

The built in json-language-features extension provides plenty of nice features for JSON Schemas, such as markdownDescription and defaultSnippets.

I would love for it to also enable indicating that the value of a property is an embedded language.

Specifically I would love for the built in npm extension to be able to indicate that values within the "scripts" property of package.json files are shellscript values.

Would make it easier to interpret and author complex npm-scripts setup such as this:

Skärmavbild 2024-08-02 kl  14 19 11

Implementation brainstorming

The current schema that the npm extension uses is json.schemastore.org/package:

"jsonValidation": [
{
"fileMatch": "package.json",
"url": "https://json.schemastore.org/package"
},

It actually already contains something similar that's aimed at IntelliJ – "x-intellij-language-injection": "Shell Script", which IntelliJ added in JetBrains/intellij-community@2e490ce

Here's how it looks in the package.json schema:

"scriptsInstallAfter": {
  "description": "Run AFTER the package is installed.",
  "type": "string",
  "x-intellij-language-injection": "Shell Script"
},

Maybe something similar, such as "x-vscode-language-injection": "shellscript" could work? Or, considering that Shell Script is an alias of shellscript, consume x-intellij-language-injection wherever it is available?

Related discussions

Mostly stumbled upon people requesting this for yaml:

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalityhelp wantedIssues identified as good community contribution opportunitiesjsonJSON support issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions