Skip to content

Add a tree-sitter query language plugin#66

Open
janrito wants to merge 1 commit into
feat/query-scm-offloadfrom
feat/query-language-plugin
Open

Add a tree-sitter query language plugin#66
janrito wants to merge 1 commit into
feat/query-scm-offloadfrom
feat/query-language-plugin

Conversation

@janrito

@janrito janrito commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Add a plugin for the tree-sitter query language itself, so rbtr indexes .scm
files.

rbtr skipped .scm files entirely — yet those are what its own plugins are now
written in (the previous PR), and what every grammar ships (tags.scm,
highlights.scm, injections.scm). With queries living in files, rbtr should
navigate them like any other source.

It's an ordinary query-path plugin, like css or json: each top-level pattern
becomes an indexed section. A pattern takes its
own outer capture where the author gave one ((function_definition …) @function → "function"), expressed in the query via an optional
@_section_name; a pattern with no label of its own — a predicate-wrapped
injection rule, or one anchored at a wrapper like (module … @variable) — is an
anonymous section. An earlier name_extractor was backed out:
that hook is for a name a query can't reach, not for inventing one.
tree-sitter-query is a required core dependency.

Indexing python.scm yields sections function, class, variable,
import; a highlights-style file yields labelled sections where a pattern
carries a capture, anonymous ones where it doesn't.

A sample covering every construct pins the labelled-vs-anonymous naming
rule, and the .scm files from the previous PR serve as real-corpus input.

Index .scm files — the tree-sitter query language rbtr's own plugins are
written in. Each top-level pattern becomes a doc_section chunk, named by its
own outer capture where the author gave one (query.scm pairs an optional
@_section_name to a direct-child capture), else a legitimately anonymous
section; nested captures stay full-text-searchable either way. No
name_extractor — the query resolves the name.

Adds the tree-sitter-query dependency and a comprehensive sample exercising
every construct. rbtr now indexes its own query files.


Update docs (rbtr-languages skill, README, ARCHITECTURE): add the query plugin to the primary-path
list and note that rbtr now indexes .scm files (including third-party
tags/highlights/injections).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant