VS Code Extensions
C

Comment-Language-Injection

by FireDragon91245

Inline comment language injection with static TextMate grammars.

Downloads

22

Rating

— (0)

Version

0.0.2

Last updated

May 07, 2026

Inject embedded language highlighting into comments using static TextMate grammars and a language={id} tag.

Usage

Use the target language identifier immediately after the opening comment marker:

/* language=json
{
  "test": 1
}
*/

Line comments work too:

// language=json { "test": 1 }

// language=json
// {
//   "test": 1
// }

Block comments still work:

// language=json
/* language=json
{
  "test": 1
}
*/

The extension provides inline highlighting for a fixed built-in set of embedded languages:

md, json, xml, html, css, js, py, c, cpp, cmd, bash, ps1, csv, env, dot, yaml, ini, toml, ts, tex, latex, makefile

It also supports common host comment styles across many languages, including:

//, #, ;, %, ', ::, REM, /* */, <!-- -->, (* *), --[[ ]]

The grammar is static, so embedded languages outside that list are not injected.

For editors with semantic tokens, the extension keeps semantic highlighting enabled and overlays tagged comment payloads with VS Code's TextMate grammars using the active theme's token colors, so semantic highlighting does not repaint injected code as plain comments after the language server finishes loading. Editors without semantic tokens use the normal TextMate injections only.

Development

  1. Run npm install.
  2. Press F5 in VS Code to launch an Extension Development Host.
  3. Add or update logic in src.

Related extensions