3

I get an error message from treesitter config every time opening a file in neovim and the syntax highlighting does not work.

After going through the neovim API doc i tried the following test command:

:lua vim.api.nvim_create_augroup("MyGroup", {clear = false})

Throws the error:

E5108: Error executing lua [string ":lua"]:1: attempt to call field 'nvim_create_augroup' (a nil value)
stack traceback:
        [string ":lua"]:1: in main chunk

The full error message is

Error detected while processing /home/strife/.local/share/nvim/plugged/nvim-treesitter/plugin/nvim-treesitter.lua:
E5113: Error while calling lua chunk: .../plugged/nvim-treesitter/lua/nvim-treesitter/configs.lua:104: attempt to call field 'nvim_create_augroup' (a
nil value)
stack traceback:
        .../plugged/nvim-treesitter/lua/nvim-treesitter/configs.lua:104: in function 'enable_mod_conf_autocmd'
        .../plugged/nvim-treesitter/lua/nvim-treesitter/configs.lua:449: in function 'define_modules'
        .../plugged/nvim-treesitter/lua/nvim-treesitter/configs.lua:524: in function 'init'
        ...are/nvim/plugged/nvim-treesitter/lua/nvim-treesitter.lua:17: in function 'setup'
        .../nvim/plugged/nvim-treesitter/plugin/nvim-treesitter.lua:9: in main chunk
MonkyPython
  • 33
  • 1
  • 5

1 Answers1

6

The error means nvim_create_augroup is not a valid member of vim.api, so it's returning nil, which can't be called. That is to say, the function doesn't exist.

I skimmed the repo for neovim and nvim_create_augroup seems to be a pretty new feature. The earliest mention of it I found with a quick search was this commit: https://github.com/neovim/neovim/commit/0f613482b389ad259dd53d893907b024a115352e

You should check your version of neovim and make sure it's up to date, at least 0.7.0.

rosemash
  • 274
  • 1
  • 7
  • 1
    Yeah that seemed to be the issue! I was using an LTS ubuntu it seems the neovim on the repo was 0.6.1. Just installed the latest stable and it works great!. Thanks a lot! – MonkyPython Jun 13 '22 at 10:46
  • I am on version 0.7.0 but getting the exact same error message when launching Neovim, but it seems like the plugin is working when checking :checkhealth nvim-treesitter. Any ideas? – ma22om Aug 31 '22 at 16:23