Skip to content

javascript, typescript: Inject GLSL and WGSL syntax in comment-labeled template literals - #55341

Merged
tomhoule merged 1 commit into
zed-industries:mainfrom
foretoo:inject-glsl-wgsl-in-js-ts-strings
Jul 10, 2026
Merged

javascript, typescript: Inject GLSL and WGSL syntax in comment-labeled template literals#55341
tomhoule merged 1 commit into
zed-industries:mainfrom
foretoo:inject-glsl-wgsl-in-js-ts-strings

Conversation

@foretoo

@foretoo foretoo commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Extends the existing ECMAScript comment-label injection system to support GLSL and WGSL shader languages inside JS/TS strings and template literals.

The pattern /* language */ before a string is already used for html, sql, graphql, and css. This adds the same support for two shader languages commonly embedded as strings in WebGL/WebGPU code:

before:
Screenshot 2026-04-30 at 23 07 05

after:
Screenshot 2026-04-30 at 23 07 39

Syntax highlighting activates when the corresponding extension is installed:

  • GLSL: the built-in glsl extension
  • WGSL: the community extension wgsl-wesl-zed (language name WGSL/WESL)

Both /*glsl*/ and /* glsl */ forms are accepted (same behavior as the existing patterns).

Release Notes:

  • Added /*glsl*/ and /*wgsl*/ comment-label syntax injection for JavaScript and TypeScript template literals

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 30, 2026
@versecafe

Copy link
Copy Markdown
Contributor

What's the reason there's not a standardized optional comment syntax for injecting any arbitrary language highlights into multiline strings the same way jebtrains does, it feels odd to need to manually list every language inside each language for this to work

@foretoo

foretoo commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

@versecafe
I agree, it would be far more convenient to have a standardized approach like this. I think the difficulty lies in linking different LSPs that come as third-party extensions, along with the various regex patterns involved. For example, in my PR, the /*glsl*/ pattern maps to the glsl language name, 100% matching, but the /*wgsl*/ pattern maps to the WGSL/WESL language name defined by a third-party extension, completely different naming way. This definitely could be standardized somehow; we need a discussion on this topic.

@smitbarmase smitbarmase added area:languages/javascript JavaScript programming language support area:languages/typescript TypeScript programming language support labels May 29, 2026
@tomhoule tomhoule self-assigned this Jul 10, 2026
@zed-industries-bot

zed-industries-bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor
Warnings
⚠️
javascript, typescript: Inject GLSL and WGSL syntax in comment-labeled template literals
^

Write PR titles using sentence case.

Have feedback on this plugin? Let's hear it!

Generated by 🚫 dangerJS against cdde12f

@tomhoule
tomhoule force-pushed the inject-glsl-wgsl-in-js-ts-strings branch from 3fe8c16 to cdde12f Compare July 10, 2026 11:21

@tomhoule tomhoule left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we'll need a more principled solution at some point. In the meantime, this is a straightforward improvement, so let's merge. Thank you for the contribution!

@tomhoule
tomhoule added this pull request to the merge queue Jul 10, 2026
Merged via the queue into zed-industries:main with commit 0953838 Jul 10, 2026
34 checks passed
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…d template literals (zed-industries#55341)

Extends the existing ECMAScript comment-label injection system to
support GLSL and WGSL shader languages inside JS/TS strings and template
literals.

The pattern `/* language */` before a string is already used for `html`,
`sql`, `graphql`, and `css`. This adds the same support for two shader
languages commonly embedded as strings in WebGL/WebGPU code:

before:
<img width="460" height="300" alt="Screenshot 2026-04-30 at 23 07 05"
src="https://github.com/user-attachments/assets/8952eddc-2f53-42ea-b086-7a0b63dceb10"
/>

after:
<img width="460" height="300" alt="Screenshot 2026-04-30 at 23 07 39"
src="https://github.com/user-attachments/assets/93bf536a-9df4-438b-af7b-382efda196ca"
/>

Syntax highlighting activates when the corresponding extension is
installed:
- GLSL: the built-in `glsl` extension
- WGSL: the community extension
[`wgsl-wesl-zed`](https://github.com/lucascompython/wgsl-wesl-zed)
(language name `WGSL/WESL`)

Both `/*glsl*/` and `/* glsl */` forms are accepted (same behavior as
the existing patterns).

Release Notes:

- Added `/*glsl*/` and `/*wgsl*/` comment-label syntax injection for
JavaScript and TypeScript template literals
playdohface pushed a commit to playdohface/zed that referenced this pull request Aug 29, 2026
…d template literals (zed-industries#55341)

Extends the existing ECMAScript comment-label injection system to
support GLSL and WGSL shader languages inside JS/TS strings and template
literals.

The pattern `/* language */` before a string is already used for `html`,
`sql`, `graphql`, and `css`. This adds the same support for two shader
languages commonly embedded as strings in WebGL/WebGPU code:

before:
<img width="460" height="300" alt="Screenshot 2026-04-30 at 23 07 05"
src="https://github.com/user-attachments/assets/8952eddc-2f53-42ea-b086-7a0b63dceb10"
/>

after:
<img width="460" height="300" alt="Screenshot 2026-04-30 at 23 07 39"
src="https://github.com/user-attachments/assets/93bf536a-9df4-438b-af7b-382efda196ca"
/>

Syntax highlighting activates when the corresponding extension is
installed:
- GLSL: the built-in `glsl` extension
- WGSL: the community extension
[`wgsl-wesl-zed`](https://github.com/lucascompython/wgsl-wesl-zed)
(language name `WGSL/WESL`)

Both `/*glsl*/` and `/* glsl */` forms are accepted (same behavior as
the existing patterns).

Release Notes:

- Added `/*glsl*/` and `/*wgsl*/` comment-label syntax injection for
JavaScript and TypeScript template literals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:languages/javascript JavaScript programming language support area:languages/typescript TypeScript programming language support cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants