fix(nvim): migrate nvim-treesitter master -> main for Neovim 0.12#27
Merged
Conversation
master is frozen for Neovim 0.11 and crashes on 0.12: its query_predicates
call vim.treesitter's pre-0.12 get_node_text/get_range, throwing
"attempt to call method 'range' (a nil value)" on any injection query
(every markdown edit). main is the 0.12+ rewrite and the fix.
- plugins.lua: repin both plugins to version='main'.
- nvim-pack-lock.json: pin the main revs. vim.pack.add checks out master on a
fresh install even with version='main' (default-branch quirk of the archived
repo); the locked rev is what makes a fresh install land on main. An already
installed master checkout needs a one-time
`:lua vim.pack.update({...}, { force = true })` (see CLAUDE.md).
- treesitter.lua: rewritten for the main/native API - drop configs.setup{};
install() diffed against config.get_installed(); per-buffer
vim.treesitter.start() + indentexpr in a FileType autocmd; textobjects via
nvim-treesitter-textobjects.select/.move; incremental selection now native
0.12 (gnn/grn/grm -> van/an/in; grc dropped). Explicit language.register()
for ps1/cs/sh/javascriptreact (main drops master's ft->lang table).
- nvim/zigcc.cmd + treesitter.lua CC: main compiles via the tree-sitter CLI,
whose cc crate can't call `zig cc` directly (multi-word CC; forced msvc
triple needs the Windows SDK). The shim rewrites the triple to
x86_64-windows-gnu and forwards to zig cc - zig stays the sole compiler, no
LLVM/MSVC. Requires winget tree-sitter.tree-sitter-cli (added to packages.json).
- Docs: CLAUDE.md treesitter + offline-install decisions, nvim/README prereqs.
Verified end-to-end in an isolated sandbox: lockfile -> fresh install on main,
parsers compile via the zig shim, and markdown injection parse no longer crashes.
Addresses Codex review of the treesitter migration: - nvim/README.md: Plugins table said the treesitter plugins are pinned to `master` (now `main`); the offline-install table referenced the removed `ensure_installed` API and described the master compile path — corrected, with a note that the offline parser/org steps need rework for `main`. - treesitter.lua: apply stylua formatting (one parser/filetype per line) so the `stylua --check nvim/` CI gate passes.
Owner
Author
Codex cross-model review (read-only, second opinion)Verdict: no HIGH findings. Codex confirmed the pinned MEDIUM
LOW
Fixes pushed in |
The codex-skills (x2) and output-styles tests assert Windows junction paths and were already failing the Ubuntu Pester job on main (pre-existing, not introduced by this branch). Guard them -Skip:(-not $IsWindows), matching the existing -Module all test, so #27's Ubuntu check is green independently of the identical fix in #26. On Windows they run unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
nvim-treesitter
masteris frozen for Neovim 0.11 and crashes on 0.12: itsquery_predicates.luacallsvim.treesitter's pre-0.12get_node_text/get_range, throwingattempt to call method 'range' (a nil value)on any injection query — i.e. every markdown edit (render-markdown + the native highlighter both trigger it).checkhealthstayed green because parsers are fine; the break is in the query-predicate layer.Fix — migrate to
main(the 0.12+ rewrite)version='main'.vim.pack.addchecks out master on a fresh install even withversion='main'(a default-branch quirk of the archived repo) — the locked rev is what lands a fresh install on main. An already-installed master checkout needs a one-time:lua vim.pack.update({'nvim-treesitter','nvim-treesitter-textobjects'}, { force = true })(non-interactive; documented in CLAUDE.md).configs.setup{};install()diffed againstconfig.get_installed(); per-buffervim.treesitter.start()+indentexprin aFileTypeautocmd; textobjects vianvim-treesitter-textobjects.select/.move(sameaf/if/ac/ic,]m [m ]] [[); incremental selection now native 0.12 (gnn/grn/grm→van/an/in;grcdropped). Explicitlanguage.register()forps1/cs/sh/javascriptreact.treesitter.luaCC:maincompiles via thetree-sitterCLI, whosecccrate can't callzig ccdirectly (multi-wordCC; forced msvc triple needs the Windows SDK). The shim rewrites the triple tox86_64-windows-gnuand forwards tozig cc— zig stays the sole compiler, no LLVM/MSVC. Addstree-sitter.tree-sitter-clitowinget/packages.json.Verification (isolated sandbox)
Lockfile → fresh
vim.pack.addlands on main (install=function); parsers compile via the zig shim; and the original crash path —vim.treesitter.get_parser():parse(true)(injections) on a markdown buffer — returns ok, no error.vaf/]m/gnnacross lua/cs/ps1/markdown/org). The offline installer's parser step is master-specific and flagged as needing rework (out of scope).