简体   繁体   中英

Treesitter config not working with neovim api. Throws error "attempt to call field 'nvim_create_augroup' (a nil value)"?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM