bug: regression when using directory of plugin specs
Did you check docs and existing issues?
- [X] I have read all the lazy.nvim docs
- [X] I have updated the plugin to the latest version before submitting this issue
- [X] I have searched the existing issues of lazy.nvim
- [X] I have searched the existing issues of plugins related to this issue
Neovim version (nvim -v)
NVIM v0.10.1
Operating system/version
Arch Linux
Describe the bug
After commit https://github.com/folke/lazy.nvim/commit/c02268ac6e6aab92249d020d75efc588bd9d24fa, when launching neovim I get the following error messages:
Error detected while processing /home/user/.dot/nvim/init.lua:
Invalid spec module: `plugins`
Expected a `table` of specs, but a `nil` was returned instead
I've been using the plugin spec directory as per https://lazy.folke.io/usage/structuring for quite some time now and my skeleton looks like this:
├── init.lua
├── lazy-lock.json
├── lua
│  ├── keymaps.lua
│  ├── options.lua
│  ├── plugins.lua
│  ├── plugins
│  │  ├── colors.lua
│  │  ├── completion.lua
│  │  ├── dap.lua
│  │  ├── editing.lua
│  │  ├── git.lua
│  │  ├── init.lua
│  │  ├── lisp.lua
...
with init.lua being this:
local modules = {
"options",
"plugins",
"keymaps",
}
for _, m in ipairs(modules) do
require(m)
end
lua/plugins.lua being this:
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("plugins")
lua/plugins/init.lua being this:
return {}
and every other lua file in the lua/plugins directory returns a regular plugin spec
Steps To Reproduce
- Create structure described above
- Update lazy.nvim to commit c02268ac6e6aab92249d020d75efc588bd9d24fa or later
Expected Behavior
To not show the error messages described above
Repro
No response
this is not a regression but a problem with your config which just didn't matter until then
the problem here is that the modules lua/plugins.lua and lua/plugins/init.lua are exactly the same for lua (e.g. u access themrequire"plugins"). You should just rename lua/plugins.lua to something else (or move it's code to init.lua)
Problem solved by solving the aforementioned ambiguity.
I removed lua/plugins/init.lua and changed the lua/plugins.lua to this:
if vim.g.lazy_did_setup then
return {}
end
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("plugins")