Repository navigation
Let extensions add injection/highlight queries to existing languages #65789
slyannah
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Body
What are you proposing?
A way for extensions to add injection and/or highlight queries to an existing language such as Markdown, without having to replace that language.
The motivating case is Hugo shortcodes in Markdown content files:
{{< video_file >}}
{{< video_file id="20252026" >}}
Why does this matter?
These lines show as plain text in Zed, and I couldn't find a supported way to highlight them:
{{<or{{%, so it isn't a fallback.The same limitation affects other Markdown-adjacent syntax:
{% %}tagsAre there any examples or context?
VS Code extensions handle this with a TextMate injection grammar layered on top of Markdown. For example, the "Hugo Shortcode Syntax Highlighting" extension highlights
{{< >}}and{{% %}}without replacing the Markdown language.Possible approach
Allow an extension to contribute additional
injections.scmand/orhighlights.scmqueries to an existing language, so they are layered on top of the built-in ones.I understand tree-sitter queries can't match a sub-range of a text node, so this may need to pair with a small injected grammar or a lightweight pattern-based injection. I'm open to whatever fits Zed's design.
[N.B.: Generated with Claude AI assistance]
All reactions