Microsoft/vscode

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

Open

#224,581 创建于 2024年8月2日

在 GitHub 查看
 (10 评论) (34 反应) (1 负责人)TypeScript (10,221 fork)batch import
feature-requesthelp wantedjson

仓库指标

Star
 (74,848 star)
PR 合并指标
 (平均合并 11小时 43分钟) (30 天内合并 1,000 个 PR)

描述

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:

贡献者指南