26

I'm currently using Neovim 6.0. And I also use the following neovim-config : https://github.com/rafi/vim-config.
After installation, I created a python program to test and a problem encountered which are as follows:

treesitter/highlighter: Error executing lua: ...im/0.6.0/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 5622 ~ pdb~ ⮡ Snippet [VSnip] st

romainl
  • 186,200
  • 21
  • 280
  • 313
Mitchell
  • 421
  • 2
  • 5
  • 6

6 Answers6

97

I had a similar issue. I ran :TSUpdate in Neovim to update Treesitter plugin and the error message disapear after relaunching.

31

I just solved it using :TSInstall vim.

Actually, run :checkhealth and the error in there would help in figuring out what is missing.

Aman Dogra
  • 491
  • 5
  • 4
  • I can confirm this worked for me! By running `:checkhealth` I was able to see the `vim` parser was not installed for Treesitter – oxfist Dec 31 '22 at 01:53
  • 1
    Thank you! I was really scratching my head on this one. – Colin Feb 15 '23 at 17:13
14

Remember, in treesitter 'c', 'help', 'lua', and 'vim' are part of the core functionality of Neovim. But that means if you are seeing this error, a sure fire way to make sure they are all installed is to run:

:TSInstall c help lua vim
stoddart
  • 140
  • 2
  • 7
5

For me helped adding cmake to ensure_installed in the treesitter config section of .config/nvim/init.lua:

-- [[ Configure Treesitter ]]
-- See `:help nvim-treesitter`
require('nvim-treesitter.configs').setup {
  -- Add languages to be installed here that you want installed for treesitter
  ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'typescript', 'help', 'cmake' },

Configuration was based on https://github.com/nvim-lua/kickstart.nvim

shafee
  • 15,566
  • 3
  • 19
  • 47
0

What worked for me is similar to that answered by Oleksiy, except add vim to the ensure_installed table instead of cmake

Sarvjot
  • 33
  • 7
  • Why do you think that in your case that change was needed? What effect does it have? How does that help? What might be the difference between your evnvironment and that one? Is a solution for your environment really also a solution for the question at the top of this page and its environment? – Yunnosch May 11 '23 at 16:56
0

You can also experience similar treesitter errors when installing nvim via snap. See here. In my case, I used the snap package because the latest neovim version on Ubuntu was significantly out of date.

If this is your case, you can install the latest version of neovim using the PPA repo.

  1. First, remove the snap package:
sudo snap remove nvim
  1. Next, install nvim from the PPA repo to get the latest version:
sudo add-apt-repository ppa:neovim-ppa/unstable
sudo apt-get update
sudo apt-get install neovim

Note: This installs the latest, "unstable" version of neovim, which could have bugs. You could use the "stable" PPA, but it is also out of date.

See also here for other ways of installing neovim without using the native Ubuntu package manager.

Jered
  • 96
  • 3