Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlights broken after update with query: invalid structure #3092

Open
clason opened this issue Jun 29, 2022 · 0 comments
Open

Highlights broken after update with query: invalid structure #3092

clason opened this issue Jun 29, 2022 · 0 comments
Labels
highlights Issues or PRs about highlighting queries invalid This doesn't seem right

Comments

@clason
Copy link
Contributor

clason commented Jun 29, 2022

Note: this is a pinned issue as target for non-bug reports due to outdated parsers or queries

What happens

After updating, highlights are broken for some or all languages with an error message like

treesitter/highlighter: error executing lua: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:172: query: invalid node type at position 765

Why this happens

After an update to nvim-treesitter or a related plugin, you have updated queries but not the corresponding parser (or vice versa), but queries are only compatible with specific parser versions, leading to errors if they no longer match.

What can I do

First, make sure that nvim-treesitter is updated to the latest commit and run :TSUpdate manually.

If the error persists, remove nvim-treesitter completely and reinstall it together with all parsers.

If the error still persists, run :checkhealth and note down the languages for which you see errors (an x in the list of languages, and explicitly listed below that). For each language (hereafter denoted by <lang>), repeat the following steps

  1. :TSInstall! <lang> and restart Neovim; if the error persists, continue.
  2. Run the following commands and note down the output:
:echo nvim_get_runtime_file('*/<lang>.so', v:true)
:echo nvim_get_runtime_file('queries/<lang>/*.scm', v:true)
  1. If either of these lists contain a directory that is not a subdirectory of nvim-treesitter, remove that directory (and, if it is another plugin, report the issue at the corresponding repository).

UPDATE Since 0.8.0, Neovim bundles parsers and queries for c, lua, vim, and help. If you use nvim-treesitter, you must make sure these parsers are installed via nvim-treesitter so that both parser and queries (which are always installed) are taken from nvim-treesitter. (It's important for this that your nvim-treesitter plugin directory comes before both /usr/local/share/nvim/* and /usr/lib/nvim in your runtimepath.)

@clason clason added invalid This doesn't seem right highlights Issues or PRs about highlighting queries labels Jun 29, 2022
@nvim-treesitter nvim-treesitter locked as resolved and limited conversation to collaborators Jun 29, 2022
@clason clason pinned this issue Jun 29, 2022
@clason clason unpinned this issue May 6, 2023
@clason clason pinned this issue Aug 16, 2023
@clason clason changed the title Highlights broken after update with query: invalid node type Highlights broken after update with query: invalid structure Aug 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
highlights Issues or PRs about highlighting queries invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant