user plugins should take priority over stock plugins
This commit is contained in:
parent
8883685eea
commit
2e1a6ad5d1
|
@ -535,16 +535,19 @@ end
|
||||||
|
|
||||||
function core.load_plugins()
|
function core.load_plugins()
|
||||||
local no_errors = true
|
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")
|
local files = system.list_dir(root_dir .. "/plugins")
|
||||||
for _, filename in ipairs(files or {}) do
|
for _, plugin_path in ipairs(files or {}) do
|
||||||
local basename = filename:gsub(".lua$", "")
|
local basename = common.basename(plugin_path)
|
||||||
if config[basename] ~= false then
|
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 modname = "plugins." .. basename
|
||||||
local ok = core.try(require, modname)
|
local ok = core.try(require, modname)
|
||||||
-- Normally a log line is added for each loaded plugin which is a
|
-- Normally a log line is added for each loaded plugin which is a
|
||||||
-- good thing. Unfortunately we load the user module before the plugins
|
-- 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.
|
-- user module's error.
|
||||||
-- if ok then core.log_quiet("Loaded plugin %q", modname) end
|
-- if ok then core.log_quiet("Loaded plugin %q", modname) end
|
||||||
if not ok then
|
if not ok then
|
||||||
|
|
|
@ -10,8 +10,8 @@ local prefix = EXEDIR:match("^(.+)[/\\]bin$")
|
||||||
DATADIR = prefix and (prefix .. '/share/lite-xl') or (EXEDIR .. '/data')
|
DATADIR = prefix and (prefix .. '/share/lite-xl') or (EXEDIR .. '/data')
|
||||||
USERDIR = HOME and (HOME .. '/.config/lite-xl') or (EXEDIR .. '/user')
|
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 .. '/?.lua;' .. package.path
|
||||||
package.path = DATADIR .. '/?/init.lua;' .. package.path
|
package.path = DATADIR .. '/?/init.lua;' .. package.path
|
||||||
|
package.path = USERDIR .. '/?.lua;' .. package.path
|
||||||
|
package.path = USERDIR .. '/?/init.lua;' .. package.path
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue