Closed benelan closed 2 months ago
actually this is expected
because in the keys
function you require the telescope module which loads the plugin
I don't know how it's possible that this was different before because one would imagine that the keys function has to be executed at startup to be able to create the mappings to lazyload
the best way to fix this would be to just not do that check for builtin because there it no way how it wouldn't be available if telescope wouldn't be rewritten
Gotcha, thanks for the context. FWIW, that was a reductive example for repro purposes, my real use case is:
keys = function()
local has_builtin, builtin = pcall(require, "telescope.builtin")
if not has_builtin then return {} end
-- when a count N is given to a telescope mapping called through the following
-- function, the search is started in the Nth parent directory
local function telescope_cwd(picker, args)
builtin[picker](
vim.tbl_extend("error", args or {}, { cwd = ("../"):rep(vim.v.count) .. "." })
)
end
return {
{
"<C-p>",
function() telescope_cwd("find_files", { hidden = true }) end,
desc = "Find files (telescope)",
},
...
}
},
well that will still load telescope on startup but I think you could just inline the require"telescope.builtin"
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.1 Build type: Release LuaJIT 2.1.1713484068
Operating system/version
Pop_OS! 22.04
Describe the bug
Before
v11.13.4
a plugin was lazy loadable when settingkeys
to a function that requires the plugin's module. Not sure if this is new, expected behavior, but now the plugin is loaded on start.Steps To Reproduce
:Lazy
and notice telescope is loaded onstart
lazy.nvim
plugin spec and repeat step 2. Notice telescope has not loaded.Expected Behavior
Plugins that require their module in the
keys
function spec are lazy loadable.Repro