Open musjj opened 1 year ago
If you're using :InspectTree
, you need to toggle anonymous nodes:
(section) ; [1:1 - 2:0]
(paragraph) ; [1:1 - 2:0]
(inline) ; [1:1 - 24]
(uri_autolink) ; [1:1 - 24]
"<" ; [1:1 - 1]
":" ; [1:7 - 7]
"/" ; [1:8 - 8]
"/" ; [1:9 - 9]
"." ; [1:13 - 13]
"." ; [1:20 - 20]
">" ; [1:24 - 24]
so you can just match them literally.
Hmm, is there a way to match literal characters in treesitter queries? I tried:
(uri_autolink
[
"<"
">"
] @conceal
(#set! conceal ""))
But it's giving me errors.
they're not children of uri_autolink
, so you'd have to write a more complicated query using anchors
I tried to use match?
, but it doesn't really help because it will still apply @conceal
to the whole node. Is there really a way to apply it partially? I also tried offset!
, but I don't think you can capture the individual delimiters this way.
Yes, you need to capture the anonymous nodes themselves. You might need two individual queries, one for <
and one for >
. (#offset!
could help with that).
Of course, you could also make a PR adding uri_autolink_delimiter
nodes to the grammar.
I think implementing a uri_autolink_delimiter
would be quite complex, so I recommend sticking with the #offset!
plan. If I see correctly though offset doesn't quite do what you want so the best way to go is probably to [write your own directive](https://neovim.io/doc/user/treesitter.html#vim.treesitter.query.add_directive()).
There's also #gsub!
for more complex transformations. (Not cheap, though!)
I want to make a query to conceal the delimiters for
uri_autolink
(the angle brackets in<https://www.google.com>
), but the delimiters are not exposed in the tree.For example for emphasis markers, you have this tree:
Can we have something similar for
uri_autolink
?