Microsoft/vscode

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

Open

#224 581 ouverte le 2 août 2024

Voir sur GitHub
 (10 commentaires) (34 réactions) (1 assigné)TypeScript (10 221 forks)batch import
feature-requesthelp wantedjson

Métriques du dépôt

Stars
 (74 848 stars)
Métriques de merge PR
 (Merge moyen 11h 43m) (1 000 PRs mergées en 30 j)

Description

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:

https://github.com/microsoft/vscode/blob/444d7a4b35745ed7733c700a8008f55cd659eb1d/extensions/npm/package.json#L314-L318

It actually already contains something similar that's aimed at IntelliJ – "x-intellij-language-injection": "Shell Script", which IntelliJ added in https://github.com/JetBrains/intellij-community/commit/2e490cee9ea05967ebaa5084ae42fe58ffc5800a

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:

Guide contributeur