Add Svelte and Vue single-file component support#59
Open
janrito wants to merge 1 commit into
Open
Conversation
Add the SFC plugin, which delegates each block (template, script, and style) to its embedded language through injection, with svelte and vue samples and a multi-language markdown sample. Assert that every registered language ships a committed sample.
This was referenced Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Svelte and Vue single-file component support.
An SFC packs several languages into one file —
<template>,<script>,<style>— and was previously indexed as opaque text, so a component's scriptdefinitions were unsearchable. The plugin uses the engine's injection
mechanism to delegate the
<script>and<style>blocks to their embeddedlanguage (JS/TS, CSS/SCSS) at real line numbers, and emits the template markup
as a searchable host chunk; one plugin covers both Svelte and Vue since their
block node shapes are identical. Svelte uses the standalone
tree-sitter-sveltegrammar; Vue has no standalone Python binding so it comesfrom
tree-sitter-language-pack, which is hermetic — grammars are compiledinto the wheel, no runtime download. Because that package hands back a ready
Language, this adds agrammar_factoryregistration hook (the usualLanguage(entry())path double-wraps and fails).It also fixes a delegation bug surfaced by SFCs: the pipeline overwrote every
chunk's language with the host file's, which broke edge resolution for
delegated chunks (a
<script>TS import to a sibling.tsno longerresolved); the host language is now filled in only when the chunker left it
blank. Finally, it adds the invariant that every registered language ships a
committed sample, so no future plugin lands untested.
Pinned by svelte/vue sample snapshots (including a cross-block script-import
edge) and the multi-language markdown sample.
Stacked PRs (merge bottom → top): #54 · #55 · #56 · #57 · #58 · #59 · #60