Skip to content

Commit cfe347f

Browse files
committed
fix(tooling): guard package.searchpath for non-LuaJIT nvim builds
module_path called package.searchpath unconditionally; it is a Lua 5.2 extension LuaJIT ships (this config's runtime) but a PUC-Lua 5.1 nvim build lacks it, where the bare call would hard-error during module resolution. Guard it so resolution degrades to vim.loader.find (nvim core, always present). Zero behavior change on LuaJIT; verified module_path still resolves normally and no longer crashes when package.searchpath is absent.
1 parent b73eac3 commit cfe347f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lua/modules/utils/tools.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ function M.module_path(module)
103103
if module_path_cache[module] then
104104
return module_path_cache[module]
105105
end
106-
local path = package.searchpath(module, package.path)
106+
-- package.searchpath is a Lua 5.2 extension LuaJIT ships (our runtime), but a
107+
-- PUC-Lua 5.1 nvim build lacks it; guard so module resolution degrades to
108+
-- vim.loader.find (nvim core, always present) instead of hard-erroring there.
109+
local path = package.searchpath and package.searchpath(module, package.path) or nil
107110
if not path then
108111
-- vim.loader.find covers foo.lua and foo/init.lua without an rtp glob.
109112
local found = vim.loader.find(module)[1]

0 commit comments

Comments
 (0)