redhat-developer / vscode-yaml

YAML support for VS Code with built-in kubernetes syntax support
MIT License
662 stars 222 forks source link

Support syntax highlight from different language for multi-line strings with a special comment #943

Open felipecrs opened 1 year ago

felipecrs commented 1 year ago

Is your enhancement related to a problem? Please describe.

I have a bunch of YAML files that embeds XML, JSON, Bash Scripts, Dockerfiles, and so on. When opening them in VS Code, such inline strings are interpreted as plain strings, which makes it a little difficult to edit.

Describe the solution you would like

To support syntax highlight of other languages for multi-line strings block that has a special comment. For example:

javascript: | # yaml-language-server: $language=javascript
  console.log('hi')
json: | # yaml-language-server: $language=json
  {
    "hello": "world"
  }

Describe alternatives you have considered

Extract the file to its own window, make the changes and then copy it back to the YAML file. Having syntax highlight directly in the YAML file would be a huge time saver :).

Additional context

It looks like this can be implemented in vscode through something like this: https://github.com/Microsoft/vscode-extension-samples/tree/main/decorator-sample

surgiie commented 9 months ago

Would be great to have this.

rgembalik commented 6 months ago

Yes, yes, yes! My use case ould probably go vastly towards .gitlab-ci.yml files which often contain bash scripts. Even if it was configurable only via .vscode/settings.json, I'd take it just to speed up pipeline development.

bdsoha commented 4 months ago

@felipecrs Any updates?

felipecrs commented 4 months ago

@bdsoha, from my side no. :)

voxpelli commented 3 months ago

Somewhat related proposal: https://github.com/microsoft/vscode/issues/224581

RedCMD commented 2 months ago

there are 2 extensions for this https://marketplace.visualstudio.com/items?itemName=ruschaaf.extended-embedded-languages https://marketplace.visualstudio.com/items?itemName=harrydowning.yaml-embedded-languages