Closed tbeseda closed 1 month ago
This thing is one of 2 things that is holding me back from switching to zed. This and custom icons in the file explorer 😅 It'd be awesome to see sublanguage support in a finite future as it's quite a part of a modern frontend, whether we like it or not.
Considering we already have language highlighting in markdown it feels like it shouldn't be that hard to implement for other languages, no?
https://github.com/tree-sitter/tree-sitter-javascript/issues/163 suggests that the javascript tree sitter syntax already supports this? somehow? as long as you have html installed?
this is so needed! js has had tagged template literals since es6 and has grown an ecosystem of libraries that use them. it looks like python could be next.
Perhaps this feature should be added as an extension (see vscode lit-html) but it's definitely needed! super useful!
Actually it looks like the language injection feature itself is already present. What is missing right now is the interface for extensions to extend existing language queries. I guess the implementation itself will be somewhat straightforward if we have consensus on the interface design.
This feature was added with release 0.149.3 Thanks a lot Zed team! ❤️
Added syntax highlighting for tagged template literals in javascript, typescript and tsx languages for css, html, js, json, sql, ts, yaml and yml (#15984; thanks RobinMalfait).
@mrnugget Would you prefer to have the feature I mentioned above tracked as a separate issue?
You mean adding an extensions API to change the queries? Yeah, I think a separate issue for that is good.
This is rad. I am seeing the nested languages in ECMAScript now:
Thanks, team!
I'm seeing highlighting for html but not sql, is there something extra I need to configure first?
Have you installed the SQL extension?
Hey nice! thank you!
Check for existing issues
Language
Langs in a JS tagged template literal: HTML, CSS, JS
Tree Sitter parser link
No response
Language server link
No response
Misc notes
I'm unsure, but I believe this would need to be a separate JS parser :/
Tree Sitter doc: http://tree-sitter.github.io/tree-sitter/using-parsers#multi-language-documents
Comparison screenshot
Here, the JS parser sees the
html
method name and invokes (or has its own?) HTML parser for the tagged template literal. And then the HTML parser even uses a CSS parser when encountering a<style>
tag.VS Code
Zed