Highlights broken after update with `query: invalid structure`
clason opened this issue · comments
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
:TSInstall! <lang>
and restart Neovim; if the error persists, continue.- 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)
- 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.9.0, Neovim bundles parsers and queries for c
, lua
, vim
, vimdoc
, and markdown
. 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
.)