fix: adapt to Neovim 0.12 match node lists#40
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a resolve_node helper function in plugin/hmts.lua to handle changes in Neovim 0.12, where captured matches are returned as a list of nodes instead of a single node. The review feedback suggests a more robust way to distinguish a list of nodes from a single TSNode by using Neovim's built-in list detection APIs (vim.islist or vim.tbl_islist) instead of checking for the absence of a parent field.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Neovim 0.12 removed the `all = false` mode for query predicates and
directives, so the `match` table passed to handlers now always maps a
capture to a *list* of nodes (`TSNode[]`) instead of a single `TSNode`.
`hmts_path_handler` and `hmts_inject_handler` still treated the value as
a single node, so `match[predicate[2]]:parent()` raised:
attempt to call method 'parent' (a nil value)
whenever a nix file was opened, breaking highlighting for all buffers.
Add a `resolve_node` helper that unwraps the list to its node (with a nil
guard) and use it at both call sites. Backwards compatible: on older
Neovim the value is still a single node and is returned as-is.
Signed-off-by: Matteo Bigoi <bigo@crisidev.org>
107c278 to
30f3622
Compare
Problem
On Neovim 0.12, opening any nix file throws for every buffer and breaks highlighting:
.../hmts.nvim/plugin/hmts.lua:127: attempt to call method 'parent' (a nil value)Cause
Neovim 0.12 removed the
all = falsemode for query predicates/directives. Thematchtable passed to handlers now always maps a capture to a list of nodes (TSNode[]) instead of a singleTSNode.hmts_path_handlerandhmts_inject_handlerstill index it as a single node, somatch[predicate[2]]:parent()runs against a plain list table andparentis nil.Fix
Add
resolve_nodehelper that unwraps the list to its node (with a nil guard) and use it at both handler call sites. Backwards compatible, on older Neovim the value is still a single node and is returned unchanged.Tested on Neovim 0.12.2.