fix: bump tree-sitter to 0.25.0#5977
Conversation
`lua-match` is specific to tree-sitter in Neovim. Currently these query predicates are ignored so will highlight much more than they should.
Bump tree-sitter to v0.25.0 and fix breaking change where `Query.captures` has been moved to `QueryCursor.captures`. NB: tree-sitter dropped support for Python 3.9 back in v0.24.0, so syntax highlighting in Textual will now require Python >=3.10. Fixes Textualize#5976
Update Python versions for syntax dependencies and tests in CI, as tree-sitter no longer supports Python 3.9.
|
I think this [EDIT: Looking closer, it doesn't look like Textual ever actually used the range arguments in this method. textual/src/textual/document/_syntax_aware_document.py Lines 85 to 91 in c9439ff |
Remove the `name` argument from `Language` initialization, as this was removed back in tree-sitter v0.22.0.
Fix the handling of the optional point range in `query_syntax_tree`, where the range arguments were removed from `Query.captures` back in tree-sitter v0.23.0. It doesn't look like Textual ever actually used these range arguments, but perhaps they were included to allow future improvements or to be used by other developers.
|
For reference here's the latest snapshot report from CI: https://github.com/Textualize/textual/actions/runs/16452663173/artifacts/3590409485 The failed snapshots look fine for the most part (and actually fixed a few bugs), but unfortunately there seems to be some quirks as mentioned above. |
|
I think I'm finally starting to understand the issues with the highlighting. Consider this Python code: print("Hello world")
x = range(10)The tree-sitter query captures (on this branch) look something like this.1 Notice that After removing the print function: x = range(10)Notice how the order of the captures has changed, where now The textual/src/textual/widgets/_text_area.py Lines 665 to 673 in c9439ff When the textual/src/textual/widgets/_text_area.py Lines 1296 to 1304 in c9439ff Footnotes
|
Update the text area snapshots due to syntax highlighting changes after bumping tree-sitter to 0.25.0.
|
I've updated the snapshots and marked this as ready for review. Since it turns out the syntax highlighting is already broken, I think better to prioritise fixing the tree-sitter crash and revisit these issues later. Bumping tree-sitter actually fixes some issues with incorrect highlighting. Note I still need to update the CHANGELOG if this is approved. This might be considered a breaking change since the syntax extras would now require Python >=3.10, |
|
Thanks for putting in the leg work on this one. Will get this in the new release (out soon). |
|
Thanks, Tom |
|
No problem. Sorry I didn't manage to get back to the CHANGELOG before this was merged - is it worth adding something now (and maybe also the release notes)? |





Bump tree-sitter to v0.25.0 and fix breaking change where
Query.captureshas been moved toQueryCursor.captures.NB: tree-sitter dropped support for Python 3.9 back in v0.24.0, so syntax highlighting in Textual will now require Python >=3.10.
Fixes #5976
Please review the following checklist.