66 lines
1.4 KiB
Lua
66 lines
1.4 KiB
Lua
local settings = require("lua.lib.settings")
|
|
require("lua.lib.globals")
|
|
local utils = require("lua.lib.utils")
|
|
local events = require("lua.lib.events")
|
|
local bind = require("lua.lib.bind")
|
|
|
|
local M = {}
|
|
local plugins = {}
|
|
|
|
local function is_plugin_exists(name)
|
|
return utils.is_file_exists(HYPR .. "/lua/plugins/" .. name .. ".lua")
|
|
end
|
|
|
|
local function load_plugin(name)
|
|
if not is_plugin_exists(name) then
|
|
return {}
|
|
end
|
|
local default_plug = require("lua.plugins." .. name)
|
|
|
|
local user_plugname = "lua.user.plugins." .. name
|
|
local plug = utils.extend_config(default_plug, user_plugname)
|
|
|
|
return plug
|
|
end
|
|
|
|
print("loading plugins...")
|
|
|
|
for name, enabled in pairs(settings.plugins) do
|
|
print("plugin ".. name .." enabled is "..tostring(enabled))
|
|
if enabled then
|
|
local plug = load_plugin(name)
|
|
print("plugin " .. name .. " loaded.")
|
|
table.insert(plugins, {
|
|
name = name,
|
|
config = plug,
|
|
})
|
|
end
|
|
end
|
|
|
|
M.autostart = {}
|
|
M.binds = {}
|
|
M.confs = {}
|
|
|
|
local function collect_plugins_prop(plugin, prop)
|
|
if plugin[prop] then
|
|
M[prop] = utils.list_extend(M[prop], plugin[prop])
|
|
end
|
|
end
|
|
|
|
for _, item in ipairs(plugins) do
|
|
local plugin = item.config
|
|
collect_plugins_prop(plugin, "autostart")
|
|
collect_plugins_prop(plugin, "binds")
|
|
collect_plugins_prop(plugin, "confs")
|
|
end
|
|
|
|
function M.load()
|
|
events.map("hyprland.start", M.autostart)
|
|
|
|
bind.map(M.binds)
|
|
|
|
hl.config(M.confs)
|
|
end
|
|
|
|
return M
|