- Build tree-sitter-svelte in one cc command (prebuilt parser.c, no tree-sitter CLI). - sgconfig.svelte.yml: registers .svelte + injects JS/TS into <script> blocks so the existing TS/JS rule packs apply there; rules-svelte/ adds template rules (on:, slot). Proven on fixtures/svelte/Messy.svelte; default sgconfig.yml unaffected. - Record sha256 for all 5 platform ast-grep binaries so first-run fetch is verifiable everywhere (binaries stay gitignored — no repo bloat). - Retire non-working svelte .example stubs; runes migration stays model-driven. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
29 lines
1.0 KiB
YAML
29 lines
1.0 KiB
YAML
# Svelte-enabled ast-grep config — OPT-IN.
|
|
#
|
|
# Use this instead of sgconfig.yml ONLY when the Svelte grammar is built at
|
|
# grammars/svelte.so (.dylib/.dll). Build (one-time, ~1s, needs a C compiler):
|
|
# git clone --depth 1 https://github.com/tree-sitter-grammars/tree-sitter-svelte /tmp/tss
|
|
# cc -shared -fPIC -O2 -I /tmp/tss/src /tmp/tss/src/parser.c /tmp/tss/src/scanner.c \
|
|
# -o grammars/svelte.so
|
|
# Then scan Svelte files with: ast-grep scan -c sgconfig.svelte.yml <paths>
|
|
#
|
|
# This loads the normal rule packs PLUS rules-svelte/, registers .svelte, and injects
|
|
# JS/TS into <script> blocks so the existing typescript/javascript rules apply there too.
|
|
ruleDirs:
|
|
- rules
|
|
- rules-svelte
|
|
|
|
customLanguages:
|
|
svelte:
|
|
libraryPath: ./grammars/svelte.so
|
|
extensions: [svelte]
|
|
expandoChar: _
|
|
|
|
languageInjections:
|
|
- hostLanguage: svelte
|
|
rule: { pattern: '<script lang="ts">$CONTENT</script>' }
|
|
injected: typescript
|
|
- hostLanguage: svelte
|
|
rule: { pattern: "<script>$CONTENT</script>" }
|
|
injected: javascript
|