Load each language's tree-sitter query from a .scm file#65
Open
janrito wants to merge 1 commit into
Open
Conversation
Each plugin now lives in languages/<lang>/ (plugin.py plus its .scm file(s)), loaded at import via a small load_query helper instead of inline Python string literals. SQL's DDL becomes a static sql.scm, js/ts compose shared .scm fragments, and html's semantic-tag query resolves to a static file. Extraction output is unchanged: no snapshot diff, no language_plugin_version bumps. Docs (rbtr-languages skill, README, ARCHITECTURE) gain a "Where queries live" note.
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.
Every language plugin carried its tree-sitter query as a triple-quoted Python
string; this moves each query into a standalone
.scmfile loaded at runtime.The house rule is to never embed another language as a string literal, and
queries were the last violation of it — a
_QUERY = """…"""per plugin, theSQL and HTML ones generated from a Python verb table and an f-string.
An inline query is invisible to tree-sitter tooling and can't itself be
indexed.
A
load_query(__package__, name)helper reads each query from a.scmbesideits plugin. Assembly stays in Python where a query is built from parts, since
the query language has no
#include: js/ts concatenate shared fragments with+, and SQL's DDL verbs collapse into[...]alternations in one staticsql.scm, retiring the generated table. (Templating was rejected — it wouldleave the
.scmfiles non-static and unparseable.)uvships them as packagedata with no config change.
Each plugin's module and its
.scmnow sit together in alanguages/<lang>/directory — co-location, not the separate in-progress split into installable
rbtr-lang-*packages.No behaviour change: each
.scmholds the same query text as the inlinestring it replaces, and SQL's rewrite into alternations matches the same
statements.