-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Treesitter: ts_match_limit
of 256 is not always enough
#26325
Comments
Cross-posted with #26563 I once also had a similar need, although not significantly as I settled down with a different approach & workaround. The problem is that very long text with many TS nodes may not be fully captured with a correct query. An example -- I was trying to fold "luadocs", a maximally consecutive group of comment lines to workaround the current issue where Custom query file (lua/folds.scm)
On a example file (1) with ts_match_limit 256: ![]()
I know the above custom query implementation is kind of The downside is performance impact: it's slow. The |
Is this tree-sitter-grammars/tree-sitter-yaml#9 perhaps related? |
Probably not, because the bug you show is more like a parser fails to parse a very long document correctly. This issue is about query (which should work on a "valid" syntax tree upon successful parsing), so I don't think it's related. |
Problem
I have run into a problem with highlighting in
InspectTree
caused byts_match_limit
being "only" 256.The bug shows up when I highlight the tree based on the nesting level and the branch contains a large subtree.
I tried to build with no change to the code other than
in
neovim/src/nvim/lua/treesitter.c
and that fixes the issue:Note: This is mainly a problem in the languages that build a tree all within some top level node. E.g. the pictures are from the
README.md
of neovim, where the whole tree is inside a top levelsection
.(Thank you @lucario387 for helping me figure out what causes the bug.)
Steps to reproduce
I think this is already a known issue, see:
I can include exact steps of reproduction if you want? But I already narrowed down the exact line of code causing this above, so I don't think it should be necessary?
Expected behavior
I can see in the discussion in #22055 that
ts_match_limit
is set relatively low for performance reasons, so I am not sure if simply raising the limit again is a good solution.In #22055 it was mentioned that it might be better to set a timeout for the query itself and raise the limit, so maybe that is the best solution?
Either way I am mainly creating this issue to have an open issue about finding a solution to this, since #22055 is closed.
Neovim version (nvim -v)
NVIM v0.10.0-dev-1721+g01b91deec-Homebrew
Vim (not Nvim) behaves the same?
N/A
Operating system/version
macOS 14.1.1
Terminal name/version
wezterm 20231030-074559-75909682
$TERM environment variable
wezterm
Installation
tested repo and homebrew
The text was updated successfully, but these errors were encountered: