Tree Sitter: Implement the offset! and make-range! query directives.
Review Request #15217 — Created Aug. 5, 2026 and submitted
Our predicate handler rejected any query match using a predicate or
directive it did not implement. nvim-treesitter's queries use the
nvim-only#offset!and#make-range!directives, so every pattern
containing one silently never matched. This change implements both.
offset!stores its range deltas in the query's pattern settings,
matching nvim's semantics of adding each delta to the corresponding
(row, column) range component. Injection handling in highlight.py now
applies those deltas when building injected-language ranges, recomputing
byte offsets from the adjusted points. This fixes injection patterns
that were previously rejected outright in the vendored injections.scm
files of ~19 languages, such as markdown's YAML frontmatter injection
and quote-trimming injections for template strings.
make-range!defines a named range spanning two captures. Nothing in
Review Board consumes those synthetic ranges, so the handler just stops
the match from being rejected.This also allows the upcoming interesting_lines.scm queries for fennel,
fish, and zig to keep their directives instead of having them stripped
at vendor time.
- Added unit tests for the directive handlers and for the range
adjustment math. - Added an end-to-end test verifying that markdown YAML frontmatter is
highlighted as YAML, with the fence lines excluded from the injected
region. - Ran unit tests.