From ebfdb94d96f23b2953b69b0991985bf44691f747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Fri, 16 Aug 2019 13:54:40 -0700 Subject: util.pluginloader: Added a new path to the variable local_names --- util/pluginloader.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util/pluginloader.lua') diff --git a/util/pluginloader.lua b/util/pluginloader.lua index 9ab8f245..af0428c4 100644 --- a/util/pluginloader.lua +++ b/util/pluginloader.lua @@ -36,12 +36,13 @@ end local function load_resource(plugin, resource) resource = resource or "mod_"..plugin..".lua"; - + local lua_version = _VERSION:match(" (.+)$"); local names = { "mod_"..plugin..dir_sep..plugin..dir_sep..resource; -- mod_hello/hello/mod_hello.lua "mod_"..plugin..dir_sep..resource; -- mod_hello/mod_hello.lua plugin..dir_sep..resource; -- hello/mod_hello.lua resource; -- mod_hello.lua + "share"..dir_sep.."lua"..dir_sep..lua_version..dir_sep.."mod_"..plugin..dir_sep..resource; }; return load_file(names); -- cgit v1.2.3 From b0616dd198c00f823dd982a80781787d98166cbe Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 5 Oct 2020 20:56:03 +0200 Subject: util.pluginloader: Extract Lua version once It's not going to change while the module is loaded. --- util/pluginloader.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/pluginloader.lua') diff --git a/util/pluginloader.lua b/util/pluginloader.lua index af0428c4..1cebe436 100644 --- a/util/pluginloader.lua +++ b/util/pluginloader.lua @@ -8,6 +8,7 @@ -- luacheck: ignore 113/CFG_PLUGINDIR local dir_sep, path_sep = package.config:match("^(%S+)%s(%S+)"); +local lua_version = _VERSION:match(" (.+)$"); local plugin_dir = {}; for path in (CFG_PLUGINDIR or "./plugins/"):gsub("[/\\]", dir_sep):gmatch("[^"..path_sep.."]+") do path = path..dir_sep; -- add path separator to path end @@ -36,7 +37,6 @@ end local function load_resource(plugin, resource) resource = resource or "mod_"..plugin..".lua"; - local lua_version = _VERSION:match(" (.+)$"); local names = { "mod_"..plugin..dir_sep..plugin..dir_sep..resource; -- mod_hello/hello/mod_hello.lua "mod_"..plugin..dir_sep..resource; -- mod_hello/mod_hello.lua -- cgit v1.2.3 From 19549a6976ecd52f9ab080bf02f7aee357441087 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 5 Oct 2020 20:56:53 +0200 Subject: util.pluginloader: Look for top level mod_something.lua in luarocks-style tree --- util/pluginloader.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'util/pluginloader.lua') diff --git a/util/pluginloader.lua b/util/pluginloader.lua index 1cebe436..5af5084d 100644 --- a/util/pluginloader.lua +++ b/util/pluginloader.lua @@ -42,6 +42,7 @@ local function load_resource(plugin, resource) "mod_"..plugin..dir_sep..resource; -- mod_hello/mod_hello.lua plugin..dir_sep..resource; -- hello/mod_hello.lua resource; -- mod_hello.lua + "share"..dir_sep.."lua"..dir_sep..lua_version..dir_sep..resource; "share"..dir_sep.."lua"..dir_sep..lua_version..dir_sep.."mod_"..plugin..dir_sep..resource; }; -- cgit v1.2.3 From 0113f59de04e2ac926e392e6295936e854534883 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 5 Oct 2020 20:58:37 +0200 Subject: util.pluginloader: Look for module libs in mod_plugin/lib.lua Luarocks can't be told to install something as foo.lib.lua AFAIK, so instead let's try mod_bar/foo.lua --- util/pluginloader.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util/pluginloader.lua') diff --git a/util/pluginloader.lua b/util/pluginloader.lua index 5af5084d..8e37ffc4 100644 --- a/util/pluginloader.lua +++ b/util/pluginloader.lua @@ -60,6 +60,9 @@ end local function load_code_ext(plugin, resource, extension, env) local content, err = load_resource(plugin, resource.."."..extension); + if not content and extension == "lib.lua" then + content, err = load_resource(plugin, resource..".lua"); + end if not content then content, err = load_resource(resource, resource.."."..extension); if not content then -- cgit v1.2.3