fix(ide): restore tree-sitter query sync - #178
Open
samim-reza wants to merge 1 commit into
Open
Conversation
`tools/syncqueries` copies `pkg/tree-sitter-zx/queries/` to the Zed and Neovim query directories and to the docs site, but it had drifted from the tree in two ways: - The SQL injection patterns were only ever added to `ide/zed/languages/zx/injections.scm` (and an older variant to the Neovim copy), never to the canonical `pkg/` source. Running the tool would have deleted SQL highlighting from Zed and Neovim, and consumers that read queries straight from the grammar package - nvim-treesitter, `hx --grammar fetch` - never had them at all. - The docs-site destination still pointed at `site/pages/docs`, which moved to `site/app/pages/reference`. The tool created an empty `site/pages/docs/` and left the file the site actually embeds untouched. Promote the Zed version of the injections to the canonical source, point the site destination at the current path, and re-run the tool so every copy matches. `tools/syncqueries` is now a no-op on a clean tree.
There was a problem hiding this comment.
Pull request overview
Restores pkg/tree-sitter-zx/queries/ as the canonical source of truth for tree-sitter queries by aligning injection patterns across consumers and fixing the docs-site copy destination in tools/syncqueries.
Changes:
- Update
tools/syncqueriesto copyhighlights.scmto the new docs-site directory (site/app/pages/reference). - Promote SQL injection query patterns into the canonical
pkg/tree-sitter-zx/queries/injections.scm. - Sync Neovim’s
ide/neovim/queries/zx/injections.scmto the updated canonical injection patterns.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/syncqueries | Fix docs-site destination path for highlights.scm sync. |
| pkg/tree-sitter-zx/queries/injections.scm | Add canonical SQL injection patterns for db.* and zx.db.*. |
| ide/neovim/queries/zx/injections.scm | Update Neovim injections to match the canonical SQL injection patterns. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+45
to
49
| # Copy highlights.scm to the docs site | ||
| echo "Copying highlights.scm to the docs site..." | ||
| rm -f "$SITE_PAGES_DIR/highlights.scm" | ||
| cp "$SOURCE_DIR/highlights.scm" "$SITE_PAGES_DIR/highlights.scm" | ||
| echo " Copied: highlights.scm" |
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.
Summary
tools/syncqueries— the script that copiespkg/tree-sitter-zx/queries/out to the Zed and Neovim query directories and to the docs site — had drifted from the tree. Running it today would have deleted SQL highlighting from the Zed and Neovim extensions, and its docs-site destination pointed at a directory that no longer exists.This makes the canonical
pkg/queries the real source of truth again. After this changebash tools/syncqueriesis a no-op on a clean tree.Problem
1. SQL injections only ever existed in the editor copies.
ide/zed/languages/zx/injections.scmgained SQL injection patterns fordb.query(...)/zx.db.run(...)(most recently in e7d30cffix(ide): improve SQL injection pattern), and the Neovim copy carries an older variant of them. The canonicalpkg/tree-sitter-zx/queries/injections.scmwas never updated and still only has the comment injection:Two consequences:
tools/syncqueriesdoesrm -fthencpper file, so running it would have overwritten both editor copies with the pattern-less canonical version, silently dropping SQL highlighting.install_info,hx --grammar fetch, the npmqueries/*files listed inpkg/tree-sitter-zx/package.json— never had the SQL injections at all.2. The docs-site destination was stale.
SITE_PAGES_DIRstill pointed atsite/pages/docs. That path was moved tosite/app/pages/referencein 4d9dc45refactor: make docsite it's own module, andsite/app/pages/reference/util.zigis what actually does@embedFile("./highlights.scm"). Because the scriptmkdir -ps its destinations, running it created an emptysite/pages/docs/and left the file the site really embeds untouched.Root Cause
Edits went into the generated copies instead of the source, and a directory rename was not reflected in the tool. Nothing verifies that the copies match, so both went unnoticed.
Solution
pkg/tree-sitter-zx/queries/injections.scm.SITE_PAGES_DIRatsite/app/pages/reference.tools/syncqueries, which bringside/neovim/queries/zx/injections.scmup to the improved patterns. Zed and the site copy are already byte-identical to the new source, so they are untouched.No behaviour is removed anywhere — Neovim gains the newer patterns, and the grammar package plus its downstream consumers gain the SQL injections for the first time.
Testing
bash tools/syncqueriesthengit status— the only file it rewrites is the stale Neoviminjections.scm; a second run leaves the tree clean, so the tool is now idempotent and no straysite/pages/directory is created.The new canonical
injections.scmwas checked against the real grammar (pkg/tree-sitter-zx/src/parser.c, ABI 15) with a smallts_query_new+ts_query_cursorharness built on the vendored tree-sitter runtime:on a sample containing
db.query("SELECT ..."),zx.db.run("DELETE ...")and a multiline-string query — so the patterns compile and actually match.zig buildandzig build testwith Zig0.17.0-dev.1465+8b2d0ce21(the version pinned in CI):591 pass, 0 fail, 11 skipped, unchanged frommain.Related Issue
Related to #136 (
feat: ide support) — keeps the Zed/Neovim integrations tracked there in sync with the grammar package.