Skip to content

RedCMD/JSON-Embedded-Languages

Repository files navigation

JSON Embedded Languages

Syntax Highlighting for embedded languages within JSON and JSONC files.
It does so by overriding the default JSON and JSONC languages and assigning a scopeName to each object with the form .meta.objectkey..
Then using multiple injection grammars that target those scopeNames and inject specific languages into it.

Features

  • ShellScript within "scripts" for package.json (JSON)
    Example package.json/scripts

  • when-clause-contexts within "when" for package.json (JSON) & keybindings.json (JSONC)
    Example package.json/when

  • JSON escaped JavaScript Regular Expressions within "wordPattern", "folding", "onEnterRules" & "indentationRules" for language-configuration.json (JSONC) and "regexp", "beginsPattern" & "endsPattern" for package.json (JSON), tasks.json & workspace.code-workspace (JSONC)
    Example language-configuration.json

  • Snippets, Regex and Markdown within "defaultSnippets", "patternProperties", "pattern" and "markdownDescription" for .schema.json (JSON)
    Recommend the Snippets Snippets extension
    Example schema.json

  • Glob patterns within "activationEvents", "files", "workspaces", "jsonValidation", "filenamePattern", "filenamePatterns" & "fileMatch" for package.json Example package.json/filenamePatterns

Supported Files

JSON

  • package.json
  • schema.json
  • colorize-results.json
  • color-theme.json

JSONC

  • language-configuration.json
  • keybindings.json
  • settings.json
  • launch.json
  • tasks.json
  • tsconfig.json
  • workspace.code-workspace

Known Issues

This extension targets every JSON and JSONC file, not just package.json.
There will be false positives and false negatives.
Please report any issues you come across.

VSCode TextMate injections are rather slow.
It may take longer for documents to fully syntax highlight.
The "injectionSelector" for regexp is well over 10,000 characters long.

For more information

TODO:

  • Support command arguments inside "args"
  • Support Markdown Links inside "contents" under "viewsWelcome"
  • Improve performance

Contributors 2

  •  
  •