From 2e1a6ad5d1accf37e07dd9a8f376d4d45cb0d0dd Mon Sep 17 00:00:00 2001 From: liquidev Date: Wed, 3 Mar 2021 12:20:22 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20#30=20=E2=80=93=20user=20plugins=20take?= =?UTF-8?q?=20priority=20over=20built-in=20plugins=20(#73)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit user plugins should take priority over stock plugins --- data/core/init.lua | 15 +++++++++------ data/core/start.lua | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/data/core/init.lua b/data/core/init.lua index 2d986ba5..686211c5 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -535,16 +535,19 @@ end function core.load_plugins() local no_errors = true - for _, root_dir in ipairs {DATADIR, USERDIR} do + for _, root_dir in ipairs {USERDIR, DATADIR} do local files = system.list_dir(root_dir .. "/plugins") - for _, filename in ipairs(files or {}) do - local basename = filename:gsub(".lua$", "") - if config[basename] ~= false then + for _, plugin_path in ipairs(files or {}) do + local basename = common.basename(plugin_path) + if system.get_file_info(plugin_path).type == "file" then + basename = basename:match("(.-)%.lua$") + end + if basename ~= nil and config[basename] ~= false then local modname = "plugins." .. basename local ok = core.try(require, modname) -- Normally a log line is added for each loaded plugin which is a -- good thing. Unfortunately we load the user module before the plugins - -- so all the messages here can fill the log screen and hide an evential + -- so all the messages here can fill the log screen and hide an eventual -- user module's error. -- if ok then core.log_quiet("Loaded plugin %q", modname) end if not ok then @@ -760,7 +763,7 @@ function core.step() local did_keymap = false local mouse_moved = false local mouse = { x = 0, y = 0, dx = 0, dy = 0 } - + for type, a,b,c,d in system.poll_event do if type == "mousemoved" then diff --git a/data/core/start.lua b/data/core/start.lua index 62de2041..aece9943 100644 --- a/data/core/start.lua +++ b/data/core/start.lua @@ -10,8 +10,8 @@ local prefix = EXEDIR:match("^(.+)[/\\]bin$") DATADIR = prefix and (prefix .. '/share/lite-xl') or (EXEDIR .. '/data') USERDIR = HOME and (HOME .. '/.config/lite-xl') or (EXEDIR .. '/user') -package.path = package.path .. ';' .. USERDIR .. '/?.lua' -package.path = package.path .. ';' .. USERDIR .. '/?/init.lua' package.path = DATADIR .. '/?.lua;' .. package.path package.path = DATADIR .. '/?/init.lua;' .. package.path +package.path = USERDIR .. '/?.lua;' .. package.path +package.path = USERDIR .. '/?/init.lua;' .. package.path