Reputation: 31
I had my lazy.lua
file in .config/nvim/lua/{name}/
directory and then to structure my config I moved it to .config/nvim/lua
. After that I got some errors basically about nil values in some lazy files.
All these errors originate from
require('lazy').setup('plugins')
These errors will disappear once I move lazy.lua
back to .config/nvim/lua/{name}/ directory
.
I obviously updated all the imports in init.lua
file. I also tried re-installing lazy by sudo rm ~/.local/share/nvim/lazy ~/.local/state/nvim/lazy -rf
, also deleted lazy-lock.json
file but nothing works except moving lazy.lua
to .config/nvim/lua/{name}/
directory. I even updated neovim to latest version.
Here is my lazy.lua
file:
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
print('installing lazy...')
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
print('lazy installed')
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup('plugins')
Here are the errors:-
In Older version 0.9.4
ERROR Failed to run healthcheck for "lazy" plugin. Exception: function health#check, line 25 Vim(eval):E5108: Error executing lua ...al/share/nvim/lazy/lazy.nvim/lua/lazy/manage/process.lua:52: attempt to index upvalue 'uv' (a >nil value) stack traceback: .local/share/nvim/lazy/lazy.nvim/lua/lazy/manage/process.lua:52: in function 'spawn' .local/share/nvim/lazy/lazy.nvim/lua/lazy/manage/process.lua:234: in function 'exec' .local/share/nvim/lazy/lazy.nvim/lua/lazy/health.lua:40: in function 'have' .local/share/nvim/lazy/lazy.nvim/lua/lazy/health.lua:72: in function 'check' [string "luaeval()"]:1: in main chunk
In Latest version 0.11.0
lazy.nvim {lazy.nvim} version 11.14.1 OK {git} version 2.34.1 OK no existing packages found by other package managers
- OK packer_compiled.lua not found ERROR No plugins loaded. Did you forget to run require("lazy"). setup()?
Luarocks ERROR Failed to run healthcheck for "lazy" plugin. Exception: .local/share/nvim/lazy/lazy.nvim/lua/lazy/health.lua:132: attempt to index field 'rocks' (a nil value)
Upvotes: 3
Views: 1083
Reputation: 3660
Firstly, the "rocks" check health error is likely because you don't have LuaRocks installed on your system. LuaRocks is a requirement for lazy.nvim
so that it can install rockspecs. You can either install it, or disable its use in lazy.nvim
by uncommenting the line rocks = { enabled = false },
below.
Secondly, by moving lazy.lua
from ~/.config/nvim/lua/config
to ~/.config/nvim/lua
, you've inadvertently created a name clash between your lazy.lua
file and the lazy module ~/.local/share/nvim/lazy
.
The solution is to rename ~/.config/nvim/lua/lazy.lua
to something other than lazy.lua
, or put it in some {name}
directory like you've done prior. Renaming the file to something simple and read-able like lazy-config.lua
will suffice.
More concretely, assuming you want the following structured setup, you need the three things listed below.
~/.config/nvim
├── init.lua
└── lua
├── lazy-config.lua
└── plugins
├── spec1.lua
├── **
└── spec2.lua
~/.config/nvim/init.lua
file exists, and calls the following function:require("lazy-config")
~/.config/nvim/lua
directory exists, and within that directory, there is the lazy-config.lua
file which contains at least the following code:-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins" },
},
-- Configure any other settings here. See the documentation (https://lazy.folke.io/configuration) for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = true },
-- disable luarocks if it is not available on system
-- rocks = { enabled = false },
})
~/.config/nvim/plugins
exists, where each file within that directory contains the specifications of a plugin you want to install, returned via a table. For example, to install lualine, you'd create a lualine.lua
file within ~/.config/nvim/plugins
that contains the following:return { -- Status line for Neovim
"nvim-lualine/lualine.nvim",
opts = {
options = {
icons_enabled = false,
component_separators = "|",
section_separators = "",
},
sections = {
lualine_x = {
"encoding",
"filetype",
},
lualine_c = {
{ "filename", path = 3 },
},
},
},
}
Read more about lazy.nvim
installation here.
Upvotes: 1