Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #30 – user plugins take priority over built-in plugins #73

Merged
merged 4 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions data/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -535,16 +535,18 @@ end

function core.load_plugins()
local no_errors = true
for _, root_dir in ipairs {DATADIR, USERDIR} do
local loaded = {}
liquidev marked this conversation as resolved.
Show resolved Hide resolved
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$", "")
liquidev marked this conversation as resolved.
Show resolved Hide resolved
if config[basename] ~= false then
if config[basename] ~= false and not loaded[basename] then
local modname = "plugins." .. basename
local ok = core.try(require, modname)
loaded[basename] = ok
-- 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
Expand Down Expand Up @@ -760,7 +762,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
Expand Down
4 changes: 2 additions & 2 deletions data/core/start.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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