Closed
Fix PHP treesitter query error "Invalid node type php_end_tag" on every cursor move#450
Conversation
Co-authored-by: andymass <[email protected]>
Co-authored-by: andymass <[email protected]>
Copilot
AI
changed the title
[WIP] Fix error 'Invalid node type php_end_tag' in Nvim treesitter
Fix PHP treesitter query error "Invalid node type php_end_tag" on every cursor move
Sep 5, 2026
andymass
reviewed
Sep 5, 2026
| -- languages whose matchup query failed to parse (e.g. because the | ||
| -- installed parser does not define a node type used by the query); we | ||
| -- remember this so we don't try (and error) again on every cursor move | ||
| local broken_langs = {} ---@type table<string, boolean> |
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.
Nvim + treesitter users editing PHP files saw a repeated error on every cursor move because the matchup query referenced a tree-sitter node type not present in their installed grammar.
Root cause
after/queries/php/matchup.scmmatched PHP's closing tag via a named(php_end_tag)node. That node only exists in the very latest upstreamtree-sitter-phpgrammar; the revision currently locked bynvim-treesitter(what most users actually have installed) still represents?>as an anonymous token. Query compilation fails hard on unknown node types, so every match computation errored out.Changes
"?>" @close.phpinstead of(php_end_tag) @close.php, matching the anonymous token used by the currently-shipped grammar (and matching nvim-treesitter's ownhighlights.scm).pcallininternal.lua, caching failures per-language so a mismatch logs a single warning and disables treesitter matching for that language instead of erroring on every cursor move.test/new/test-treesitter/example.phpplus additions totest.vimcovering PHP tag matching and if/else matching.tree-sitter-phpparser pinned to the same revisionnvim-treesitterlocks, so the new PHP test runs in CI.