nvim-config

Log | Files | Refs | Submodules | README

show_languagetree.lua (522B)


      1 local M = {}
      2 local ts = vim.treesitter
      3 
      4 function ShowLangTree(langtree, indent)
      5   langtree = langtree or ts.get_parser()
      6   indent = indent or ''
      7 
      8   print(indent .. langtree:lang())
      9   for _, region in pairs(langtree:included_regions()) do
     10     if type(region[1]) == 'table' then
     11       print(indent .. '  ' .. vim.inspect(region))
     12     else
     13       print(indent .. '  ' .. vim.inspect{region[1]:range()})
     14     end
     15   end
     16   for lang,child in pairs(langtree._children) do
     17     ShowLangTree(child, indent .. '  ')
     18   end
     19 end
     20 
     21 return M