You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.
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
(/ (+ (- b)
(sqrt (- (* b b)
(*4 a c))))
(*2 a))
Now suppose the cursor is on the r of sqrt (or anywhere else inside that node). The highlighting should look as follows, where the square brackets denote highlighted parentheses:
[/ [+ (- b)
[sqrt [- [* b b)
[* 4 a c]]]]
(*2 a)]
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.
-- Inside the `for _, node, _ in ...` loop:localy, x, Y, X=node:parent():range()
ify<=randr<=Yandx<=candc<=Xthen-- Do the highlightingend
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:
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 freeto 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: