fix(treesitter): display fields for anonymous nodes in :InspectTree

(cherry picked from commit 9217e0d671)
This commit is contained in:
Riley Bruins
2024-07-04 10:09:19 -07:00
committed by Christian Clason
parent 5cad641848
commit ab2d243fd0
2 changed files with 12 additions and 9 deletions

View File

@@ -220,14 +220,13 @@ function TSTreeView:draw(bufnr)
local text ---@type string
if item.node:named() then
if item.field then
text = string.format('%s: (%s', item.field, item.node:type())
else
text = string.format('(%s', item.node:type())
end
text = string.format('(%s', item.node:type())
else
text = string.format('%q', item.node:type()):gsub('\n', 'n')
end
if item.field then
text = string.format('%s: %s', item.field, text)
end
local next = self:get(i + 1)
if not next or next.depth <= item.depth then