Switch to tree-sitter-htmlx-svelte grammar#72
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @themixednuts on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
- Add explicit SCSS, SASS, and LESS injection rules before CSS fallback - Prevent CSS fallback from overriding preprocessor injections when lang attribute is present - Add inline style attribute CSS injection - Remove attribute_name captures from injection queries to preserve highlight colors
|
Downloaded Zed yesterday, worked on it today, was kind of planning to go back to VSCode or one of its forks because of the poor Svelte highlighting, but this fixed it. Get on with merging it and updating the svelte extension quickly please |
I think its fair to give them time. I'm new on the scene relatively. The stuff I have is pretty much fresh implementation. Along with all the recent dependency issues going on, I would give them some slack on the vetting timeframes :) Let me know of any issues in the mean time, I want this to be as best implemented as possible! |
Summary
Replaces the tree-sitter grammar with tree-sitter-htmlx-svelte, which provides language injection into all template expressions.
The previous grammar parsed template expressions (
{foo},{@const x = 1},{@render children()},{#each items as item}, etc.) as opaque raw text with no language injection — meaning no syntax highlighting inside curly braces in the markup. This grammar injects JavaScript or TypeScript (based on<script lang="ts">) into every expression context, so template code gets full highlighting.What's new
{expressions}, block conditions, each bindings/keys, await patterns, and shorthand attributes get JS/TS syntax highlighting@attachsupport — the new Svelte 5 directive is fully parsed and highlighted{#snippet foo(bar, baz)}parameters are injected as JS/TS, not raw text{#snippet foo<T>(bar: T)}generics are injected as TypeScript{...rest}content is handled via JS injection, so...gets proper operator highlightingstyle="..."attribute values are injected as CSS for property highlighting//line comments and/* */block comments inside element tags are parsed and highlightedUpdated queries
highlights.scmandinjections.scmrewritten for the new node structureif,each,await,key,snippet,render,attach,const,html,debug) captured as@keyword.controlCloses #71
Closes #36
Closes #65
Closes #58
Old:

New:
