tree-sitter: ignore matches in inner scopes#139
Merged
Conversation
Previously, placing the cursor on line 1 would highlight every elif and else in the whole block of code. % would jump to line 4, then % from there would cycle between lines 2, 4 and 6. 1 if noice: 2 if yeah: 3 pass 4 elif no: 5 pass 6 else: 7 pass 8 elif blah: 9 pass 10 else: 11 pass With the change, which I think the code had contemplated given there was already an unused `M.containing_scope(node, bufnr, info.key)` call, % will only move between ifs and elses that are in the same `@scope.if_`, and not to any inner scopes. Hence the example will have two mutually exclusive %-cycles: [1, 8, 10] and [2, 4, 6].
Contributor
Author
|
The nightly build fails because nvim-treesitter (#1000) updated all their highlight grammars to work with the breaking-ABI-change TS release 0.19, but the neovim nightly build hasn't been updated since it merged the embedded TS -> 0.19.3 update. So just run again whenever they bump it. |
Contributor
Author
|
Ah, turns out they bumped nightly very shortly after I posted that. |
Owner
|
Thank you for the contribution and interest in the tree-sitter integration! You're totally correct on all points. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, in the example below, placing the cursor on line 1 would highlight every elif and else in the whole block of code. % would jump to line 4, then % from there would cycle between lines 2, 4 and 6.
With the change, which I think the code had contemplated given there was already an unused
M.containing_scope(node, bufnr, info.key)call, % will only move between ifs and elses that are in the same@scope.if_, and not to any inner scopes. Hence the example will have two mutually exclusive %-cycles: [1, 8, 10] and [2, 4, 6].