-
-
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
Concealing range between nodes with one character using treesitter #25515
Comments
No, we would strongly prefer to let treesitter handle this. After all, that's the whole point of it. |
@clason Could you explain how do you imagine this? The whole current idea of Tree-sitter queries and captures exist around that captures points to distinct and concrete tree nodes and not to a set of some related nodes. At the same time nodes pointed by captures behaves like quick entry points into a tree where additional actions may be done over a nodes' API. Edit: To don't break the current queries API, it's possible to introduce a concept of ephemeral nodes that would behave like just containers for point ranges and wouldn't allow to use nodes API on them. But I don't think that such additional complexity and concept worth to add just for one this use case, because this makes queries understanding even more harder. |
I am referring to the linked tree-sitter issue, which should cover this? If I misunderstood something, please correct me. For this specific instance, though, I don't see why a new feature is needed; can't you just do
|
@clason That's a good idea that I hadn't thought of. However, when I tried it for some reason the I even tried giving the minus a different capture group like this (
(list_marker_minus) @minus (#set! conceal "")
(task_list_marker_checked) @conceal (#set! conceal "")
) But I still get the same behaviour: |
That could be an issue with multiple directives in a single pattern not working properly, which would be a bug that needs to be fixed. |
@mawkler As a workaround, I use something like this: ((task_list_marker_unchecked)
@text.todo.unchecked
(#offset! @text.todo.unchecked 0 -2 0 0)
(#set! conceal "✗")) ;
((task_list_marker_checked)
@text.todo.checked
(#offset! @text.todo.checked 0 -2 0 0)
(#set! conceal "✓")) ; the |
@ribru17 That works great as a workaround, thank you! |
Unless I'm misunderstanding you, I don't think this is a bug. The capture metadata for (
(list_marker_minus) @conceal (#set! foo "a")
(task_list_marker_unchecked) @conceal (#set! foo "b")
) run on a single list item would create two capture groups, each of which has a I've sometimes wondered why |
They do, in Neovim. |
Problem
I'm trying to conceal Markdown checkboxes and the minus sign in front of them with one conceal character. Here's my query:
( (list_marker_minus) (task_list_marker_unchecked) ) @checkbox (#set! conceal "")
However, only the first sibling,
list_marker_minus
gets concealed.Here's a file that I'm using as an example:
Here's what the syntax tree looks like:
I feel like this is a pretty trivial use case.
Expected behavior
This does seem to be an issue with treesitter. However, one way I see that Neovim could work around this is to add the ability to specify a start and an end to a conceal range with treesitter captures.
Then I could through some new conceal API tell Neovim that I want everything between
@conceal_start
s and@conceal_end
s to be conceald with some character, including (or excluding) the captures.What do you say?
The text was updated successfully, but these errors were encountered: