If a plugin has a build function that requires itself, when it is first installed it is not configured until after the build function has finished running - not when it is required.
Steps To Reproduce
On first nvim -u repro.lua, the plugin is installed and the following is printed:
build start
build end
config
Reopening nvim -u repro.lua and running ":Lazy build drop.nvim", the following is printed
build start
config
build end
Expected Behavior
Plugin is configured when required during build, even during first install.
Repro
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
-- do not remove the colorscheme!
"folke/tokyonight.nvim",
-- add any other pugins here
-- this could be any plugin, using drop.nvim as an example
{
"folke/drop.nvim",
lazy = true,
opts = {},
build = function()
vim.print("build start")
require("drop") -- plugin should be configured here
vim.print("build end")
end,
config = function(_, opts)
vim.print("config")
require("drop").setup(opts)
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
-- add anything else here
vim.opt.termguicolors = true
-- do not remove the colorscheme!
vim.cmd([[colorscheme tokyonight]])
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.11.0-dev+1107-g000129201 Build type: RelWithDebInfo LuaJIT 2.1.1720049189
Operating system/version
Fedora 41
Describe the bug
If a plugin has a
build
function thatrequire
s itself, when it is first installed it is not configured until after the build function has finished running - not when it isrequired
.Steps To Reproduce
On first
nvim -u repro.lua
, the plugin is installed and the following is printed:Reopening
nvim -u repro.lua
and running ":Lazy build drop.nvim", the following is printedExpected Behavior
Plugin is configured when
require
d during build, even during first install.Repro