diff --git a/runtime/lua/vim/treesitter/playground.lua b/runtime/lua/vim/treesitter/playground.lua index 1b0d76b52c..efe882204e 100644 --- a/runtime/lua/vim/treesitter/playground.lua +++ b/runtime/lua/vim/treesitter/playground.lua @@ -102,16 +102,18 @@ function TSPlayground:new(bufnr, lang) -- the root in the child tree to the {injections} table. local root = parser:parse()[1]:root() local injections = {} ---@type table - parser:for_each_tree(function(tree, ltree) - local r = tree:root() - local node = root:named_descendant_for_range(r:range()) - if node then - injections[node:id()] = { - lang = ltree:lang(), - root = r, - } - end - end) + for _, child in pairs(parser:children()) do + child:for_each_tree(function(tree, ltree) + local r = tree:root() + local node = root:named_descendant_for_range(r:range()) + if node then + injections[node:id()] = { + lang = ltree:lang(), + root = r, + } + end + end) + end local nodes = traverse(root, 0, parser:lang(), injections, {})