Failed to run 'config' for nvim-treesitter
Before Reporting an Issue
-
I have read the kickstart.nvim README.md.
-
I have read the appropriate plugin's documentation.
-
I have searched that this issue has not been reported before.
-
[ X ] By checking this, I confirm that the above steps are completed. I understand leaving this unchecked will result in this report being closed immediately.
Describe the bug
..local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:387: module 'nvim-treesitter.configs' not found: no field package preload[' nvim-treesitter.configs'] cache_loader: module 'nvim-treesitter.configs' not found cache_loader_lib: module 'nvim-treesitter.configs' not found no file './nvim-treesitter/configs.lua' no file '/usr/local/share/luajit-2.1/nvim-treesitter/configs.lua' no file '/usr/local/share/lua/5.1/nvim-treesitter/configs.lua' no file '/usr/local/share/lua/5.1/nvim-treesitter/configs/init.lua' no file './nvim-treesitter/configs.so' no file '/usr/local/lib/lua/5.1/nvim-treesitter/configs.so' no file '/usr/local/lib/lua/5.1/loadall.so' no file './nvim-treesitter.so' no file '/usr/local/lib/lua/5.1/nvim-treesitter.so' no file /usr/local/lib/lua/5.1/loadall.so'
stacktrace:
- .config/nvim/lua/lazy-plugins.lua:15
- .config/nvim/init.lua:106
To Reproduce
- This occurs the first time you run nvim and each time thereafter. In my research I think there was an update to tree sitter and syntax has changed in the way that it is initialized but I could never figure it out.
Desktop
- OS: macOS Tahoe 26.2
- Terminal: Apple's system terminal
Neovim Version
NVIM v0.11.5
Build type: Release
LuaJIT 2.1.1765228720
take a look at #1657
Duplicate of #1732
Just change the following line in your ~/.config/nvim/init.lua file.
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
to
main = 'nvim-treesitter.config', -- Sets main module to use for opts
This helped me solve this issue.
It would be fixed by changing in ~/.config/nvim/init.lua
main = 'nvim-treesitter.configs'
To
main = 'nvim-treesitter'
The problem is that nvim-treesitter has finally switched to the main branch as default which is a complete incompatible rewrite here: https://github.com/nvim-treesitter/nvim-treesitter/commit/d3218d988f72ed34414959c9ccd802d393432d6e
This repo has a configuration for the now legacy master branch of nvim-treesitter.
You can either change your config to adapt tot he main branch or just specify that you want to use the master branch by adding:
{
'nvim-treesitter/nvim-treesitter',
branch = 'master',
...
At least for me, this is the most efficient and effective solution. The previous methods (like changing .configs to .config) only suppress the error messages, but Treesitter doesn't actually function properly. For the fastest fix that actually works, just add branch = 'master'
The problem is that nvim-treesitter has finally switched to the
mainbranch as default which is a complete incompatible rewrite here: nvim-treesitter/nvim-treesitter@d3218d9This repo has a configuration for the now legacy
masterbranch of nvim-treesitter.You can either change your config to adapt tot he
mainbranch or just specify that you want to use themasterbranch by adding:{ 'nvim-treesitter/nvim-treesitter', branch = 'master', ...
the problem seems to be kickstart.nvim using older ways to setup treesitter, the treesitter repo has received major updates due to which the entire configuration method has changed, I personally use this setup(it works with lazy.nvim):
return {
"nvim-treesitter/nvim-treesitter",
lazy = false,
build = ":TSUpdate",
config = function()
require('nvim-treesitter').install({
'c', 'lua', 'javascript', 'typescript', 'python', 'go', 'java', 'vim', 'vimdoc'
})
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'c', 'lua', 'javascript', 'typescript', 'python', 'go', 'java' },
callback = function() vim.treesitter.start() end,
})
end
}
Hope this helps out anyone having problem with treesitter in general.
It would be fixed by changing in
~/.config/nvim/init.luamain = 'nvim-treesitter.configs'
To
main = 'nvim-treesitter'
Thank you.
This has been fixed in the recent changes. Thanks for the help :)