This repository has been archived by the owner on Jan 2, 2023. It is now read-only.
generated from nvim-treesitter/module-template
-
Notifications
You must be signed in to change notification settings - Fork 67
Highlight only current sub-tree? #110
Comments
The feature would be nice to have, I can't take a look rn - probably next week. It doesn't appear(???) costly |
I managed to hack something together. vokoscreen-2022-04-20_00-11-35.mp4The code is quite a mess, but it works. I will have to test it with other languages and clean it up properly. It's a first step. |
This feature is useful, any progress on this? |
Right, I have been shoving this one under the rug. Here is work-in-progress pull request: #131 I don't know enough about Tree-sitter do it properly. Is there more in terms of resources other than the Tree-sitter website and the Neovim documentation? Something that walks me through the baby steps first and explains what all the terms mean. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
As a user I sometimes find it too noisy when the entire buffer is highlighted. I would like if it was possible to only highlight the current sub-tree of the buffer, i.e. the delimiters of the current node, the delimited of all its descendants and the delimiter of all its ancestors. Take the following s-expression as an example
Now suppose the cursor is on the
r
ofsqrt
(or anywhere else inside that node). The highlighting should look as follows, where the square brackets denote highlighted parentheses:All s-expressions inside
sqrt
are highlighted, but the sibling(- b)
and uncle(* 2 a)
are not. Since the highlighting can change whenever the cursor moves this would require re-computing the highlight groups on every cursor movement. I have hacked something together, but it only sort of works. My understanding of Tree-sitter is still too limited.The idea was to get the range of the parent of the query result and check whether the cursor is within that range. Obviously this won't work for descendants of the current node. I would need somehow to get the cursor node and then check whether the query node is inside it.
My hack does not work in HTML, but that might be because I am using the extended mode.
What's your opinion? Should we have such a feature? Would it be too costly? Advice on how to implement it?
The text was updated successfully, but these errors were encountered: