From 67bb0cfa79bc7eea5103ce9a00fc6176077c135b Mon Sep 17 00:00:00 2001 From: futsuuu Date: Sat, 20 Jul 2024 14:46:27 +0900 Subject: fix(loader): follow the style of the error message for built-in loaders start the error message with '\n\t' instead of '\n' surround the module name by single quotes --- runtime/lua/vim/loader.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/lua/vim/loader.lua') diff --git a/runtime/lua/vim/loader.lua b/runtime/lua/vim/loader.lua index ea77a22416..2a881d1602 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 @@ -222,7 +222,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 -- cgit From 47e6b2233feffc6e9d94f6086fb904eb5688fa25 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 23 Sep 2024 06:05:58 -0700 Subject: fix(vim.fs): dirname() returns "." on mingw/msys2 #30480 Problem: `vim.fs.dirname([[C:\User\XXX\AppData\Local]])` returns "." on mingw/msys2. Solution: - Check for "mingw" when deciding `iswin`. - Use `has("win32")` where possible, it works in "fast" contexts since b02eeb6a7281df0561a021d7ae595c84be9a01be. --- runtime/lua/vim/loader.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'runtime/lua/vim/loader.lua') diff --git a/runtime/lua/vim/loader.lua b/runtime/lua/vim/loader.lua index 2a881d1602..0211e8d4a1 100644 --- a/runtime/lua/vim/loader.lua +++ b/runtime/lua/vim/loader.lua @@ -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 -- cgit From b45c50f3140e7ece593f2126840900f5cc3d39ea Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 4 Oct 2024 02:13:31 -0700 Subject: docs: render `@since` versions, 0 means experimental #30649 An implication of this current approach is that `NVIM_API_LEVEL` should be bumped when a new Lua function is added. TODO(future): add a lint check which requires `@since` on all new functions. ref #25416 --- runtime/lua/vim/loader.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'runtime/lua/vim/loader.lua') diff --git a/runtime/lua/vim/loader.lua b/runtime/lua/vim/loader.lua index 0211e8d4a1..e86d33bf53 100644 --- a/runtime/lua/vim/loader.lua +++ b/runtime/lua/vim/loader.lua @@ -289,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[] @@ -377,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 @@ -398,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 @@ -421,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 -- cgit