feat(treesitter): show which nodes are missing in InspectTree

Now `:InspectTree` will show missing nodes as e.g. `(MISSING identifier)`
or `(MISSING ";")` rather than just `(identifier)` or `";"`. This is
doable because the `MISSING` keyword is now valid query syntax.

Co-authored-by: Christian Clason <c.clason@uni-graz.at>
This commit is contained in:
Riley Bruins
2025-02-04 09:25:03 -08:00
committed by Christian Clason
parent d769c340b9
commit 09f9f0a946
3 changed files with 64 additions and 1 deletions

View File

@ -224,9 +224,12 @@ function TSTreeView:draw(bufnr)
local text ---@type string
if item.node:named() then
text = string.format('(%s', item.node:type())
text = string.format('(%s%s', item.node:missing() and 'MISSING ' or '', item.node:type())
else
text = string.format('%q', item.node:type()):gsub('\n', 'n')
if item.node:missing() then
text = string.format('(MISSING %s)', text)
end
end
if item.field then
text = string.format('%s: %s', item.field, text)