Skip to content

fix: adapt to Neovim 0.12 match node lists#40

Open
crisidev wants to merge 1 commit into
calops:mainfrom
crisidev:fix/nvim-012-node-lists
Open

fix: adapt to Neovim 0.12 match node lists#40
crisidev wants to merge 1 commit into
calops:mainfrom
crisidev:fix/nvim-012-node-lists

Conversation

@crisidev

Copy link
Copy Markdown

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 = false mode for query predicates/directives. 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 index it as a single node, so match[predicate[2]]:parent() runs against a plain list table and parent is nil.

Fix

Add resolve_node helper 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread plugin/hmts.lua
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>
@crisidev
crisidev force-pushed the fix/nvim-012-node-lists branch from 107c278 to 30f3622 Compare July 14, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant