aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/loader.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
commit9be89f131f87608f224f0ee06d199fcd09d32176 (patch)
tree11022dcfa9e08cb4ac5581b16734196128688d48 /runtime/lua/vim/loader.lua
parentff7ed8f586589d620a806c3758fac4a47a8e7e15 (diff)
parent88085c2e80a7e3ac29aabb6b5420377eed99b8b6 (diff)
downloadrneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.gz
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.bz2
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'runtime/lua/vim/loader.lua')
-rw-r--r--runtime/lua/vim/loader.lua20
1 files changed, 14 insertions, 6 deletions
diff --git a/runtime/lua/vim/loader.lua b/runtime/lua/vim/loader.lua
index ea77a22416..e86d33bf53 100644
--- a/runtime/lua/vim/loader.lua
+++ b/runtime/lua/vim/loader.lua
@@ -200,7 +200,7 @@ function Loader.loader(modname)
return chunk or error(err)
end
Loader._hashes = nil
- return '\ncache_loader: module ' .. modname .. ' not found'
+ return ("\n\tcache_loader: module '%s' not found"):format(modname)
end
--- The `package.loaders` loader for libs
@@ -208,8 +208,7 @@ end
---@return string|function
---@private
function Loader.loader_lib(modname)
- local sysname = uv.os_uname().sysname:lower() or ''
- local is_win = sysname:find('win', 1, true) and not sysname:find('darwin', 1, true)
+ local is_win = vim.fn.has('win32') == 1
local ret = M.find(modname, { patterns = is_win and { '.dll' } or { '.so' } })[1]
if ret then
-- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is
@@ -222,7 +221,7 @@ function Loader.loader_lib(modname)
local chunk, err = package.loadlib(ret.modpath, 'luaopen_' .. funcname:gsub('%.', '_'))
return chunk or error(err)
end
- return '\ncache_loader_lib: module ' .. modname .. ' not found'
+ return ("\n\tcache_loader_lib: module '%s' not found"):format(modname)
end
--- `loadfile` using the cache
@@ -290,6 +289,9 @@ function Loader.load(modpath, opts)
end
--- Finds Lua modules for the given module name.
+---
+--- @since 0
+---
---@param modname string Module name, or `"*"` to find the top-level modules instead
---@param opts? vim.loader.find.Opts Options for finding a module:
---@return vim.loader.ModuleInfo[]
@@ -378,8 +380,10 @@ function M.find(modname, opts)
return results
end
---- Resets the cache for the path, or all the paths
---- if path is nil.
+--- Resets the cache for the path, or all the paths if path is nil.
+---
+--- @since 0
+---
---@param path string? path to reset
function M.reset(path)
if path then
@@ -399,6 +403,8 @@ end
--- * adds the Lua loader using the byte-compilation cache
--- * adds the libs loader
--- * removes the default Nvim loader
+---
+--- @since 0
function M.enable()
if M.enabled then
return
@@ -422,6 +428,8 @@ end
--- Disables the experimental Lua module loader:
--- * removes the loaders
--- * adds the default Nvim loader
+---
+--- @since 0
function M.disable()
if not M.enabled then
return