Closed sarmong closed 8 months ago
It does relate to the parser. The inline nodes are special, they work kind of like the script
node in html, where the contents are parsed as javascript. In this grammar, the content of the inline
nodes in the top level grammar are parsed as "inline markdown". This means, that there is one tree for every inline node, and the tsnode
in your code is the root node of that tree.
I'm not sure what the most efficient way to get the "parent" is in neovim, i.e. the node that the "inline tree" is attached to. I guess if you have access to the top level markdown tree (let's call it tree
) you could do
tree:named_node_for_range(node:range())
Thanks, this worked, though I am also not sure how efficient this is.
However, what is the reason for having separate trees? I don't think I understand.
Markdown does not have a syntax that's nice to parse, wince it's optimized for being readable to humans instead. That's why it's suggested to parse it in two passes. With tree sitter that's not really possible, but the double tree structure is my way of working around it.
Closing this as the problem seems to be solved.
Describe the bug
When I am trying to get a parent of node with type
inline
I getnil
. I am using neovim methodtsnode:parent()
. It works for all nodes butinline
ones.I am not sure though if the bug relates to this parser.
Code example
Expected behavior
When you get a parent node of an inline element (text
test list
andTest Heading
) you getparagraph
andatx_heading
nodes respectivelyActual behavior
You get
nil