-
Notifications
You must be signed in to change notification settings - Fork 6
feat: remove make-range, support quantified captures
#44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modernizes TreeSitter query files by removing deprecated make-range! directives and adopting quantified captures, a feature supported in newer versions of nvim-treesitter-textobjects (as referenced in PR #612). The changes simplify query patterns by using native TreeSitter quantifiers (+, *) instead of manually constructing ranges.
Key changes:
- Replaced
make-range!directive patterns with quantified capture syntax (+and*quantifiers) - Simplified query patterns by directly capturing node sequences instead of defining start/end ranges
- Updated example file by removing cell separator comments
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| res/queries/python/textobjects/cellcontent.scm | Converted from make-range! to quantified captures using (_)+ and _+ patterns for matching cell content |
| res/queries/python/textobjects/cell.scm | Converted from make-range! to quantified captures, including restructured patterns for cells between separators |
| example/main.ju.py | Removed Jupyter cell separator comments and content, simplifying the example file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ( | ||
| (comment) @_cellseparator @cell | ||
| (_)* @_cellcontent @cell | ||
| . | ||
| (#match-cell-content? @_cellcontent) | ||
| (#match-percent-separator? @_cellseparator) | ||
| ) |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the "cell between two separator" pattern, this pattern applies #match-cell-content? to @_cellcontent which uses the * quantifier and could match zero nodes. The predicate should likely be applied to @cell or the pattern needs adjustment to ensure content nodes exist. Also, the extra parentheses grouping on lines 35-41 is inconsistent with other patterns in the file and may not be necessary.
| @@ -1,52 +1,44 @@ | |||
|
|
|||
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file now starts with an unnecessary blank line. For consistency with other query files in the codebase, this blank line should be removed.
| (_) @_nonseparator @_start @_end | ||
| . | ||
| (_)* @_nonseparator @_end | ||
| _+ @cellcontent |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent wildcard quantifier syntax: This pattern uses _+ while other patterns in the file use (_)+. In TreeSitter query syntax, _ is a wildcard that matches any single node, and quantifiers should be applied to parenthesized expressions. The correct syntax should be (_)+ to match one or more nodes of any type, consistent with lines 7 and 26.
| . | ||
| (_) @_nonseparator @_start @_end | ||
| (_)* @_nonseparator @_end | ||
| _+ @cellcontent |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent wildcard quantifier syntax: This pattern uses _+ while other patterns in the file use (_)+. In TreeSitter query syntax, _ is a wildcard that matches any single node, and quantifiers should be applied to parenthesized expressions. The correct syntax should be (_)+ to match one or more nodes of any type, consistent with lines 7 and 26.
| (_) @_nonseparator @_start @_end | ||
| . | ||
| (_)* @_nonseparator @_end | ||
| _+ @cell |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent wildcard quantifier syntax: This pattern uses _+ while line 8 uses (_)+. In TreeSitter query syntax, _ is a wildcard that matches any single node, and quantifiers should be applied to parenthesized expressions. The correct syntax should be (_)+ to match one or more nodes of any type, consistent with line 8.
| _+ @cell | |
| (_)+ @cell |
| (comment) @_cellseparator @cell | ||
| (_)* @_cellcontent @cell | ||
| (comment) @_cellseparator | ||
| (#match-cell-content? @_cellcontent) | ||
| (#match-percent-separator? @_cellseparator) |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation in this query pattern is inconsistent with the rest of the file. Lines 25-29 use 4 spaces of indentation, while other patterns in the file (lines 6-11, 14-21, 34-42) use 2 spaces. This should be adjusted to 2 spaces for consistency.
| (comment) @_cellseparator @cell | |
| (_)* @_cellcontent @cell | |
| (comment) @_cellseparator | |
| (#match-cell-content? @_cellcontent) | |
| (#match-percent-separator? @_cellseparator) | |
| (comment) @_cellseparator @cell | |
| (_)* @_cellcontent @cell | |
| (comment) @_cellseparator | |
| (#match-cell-content? @_cellcontent) | |
| (#match-percent-separator? @_cellseparator) |
| (comment) @_cellseparator @cell | ||
| (_)* @_cellcontent @cell | ||
| (comment) @_cellseparator | ||
| (#match-cell-content? @_cellcontent) | ||
| (#match-percent-separator? @_cellseparator) |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pattern change appears to alter the semantic meaning. Previously, this pattern matched the separator followed by content nodes, creating a range from the separator to the last content node. Now, it captures both the separator and content nodes together as @cell. However, the predicate #match-cell-content? is still applied to @_cellcontent instead of @cell, which may not work as intended since @_cellcontent uses the * quantifier and could match zero nodes. Consider whether the predicate should be applied to @cell or if the pattern needs adjustment.
1da9da5 to
69fd30e
Compare
69fd30e to
4a7d262
Compare
Fix #43