feat: init plugins support
This commit is contained in:
@@ -15,4 +15,5 @@ require("lua.conf.layerrules").load()
|
|||||||
|
|
||||||
require("lua.binds").load()
|
require("lua.binds").load()
|
||||||
require("lua.modules").load()
|
require("lua.modules").load()
|
||||||
|
require("lua.plugins").load()
|
||||||
require("lua.animations").load()
|
require("lua.animations").load()
|
||||||
|
|||||||
@@ -43,4 +43,9 @@ settings["modules"] = {
|
|||||||
rofi = true,
|
rofi = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---@type table<string, boolean>
|
||||||
|
settings["plugins"] = {
|
||||||
|
hyprexpo = false
|
||||||
|
}
|
||||||
|
|
||||||
return require("lua.lib.utils").extend_config(settings, "lua.user.settings")
|
return require("lua.lib.utils").extend_config(settings, "lua.user.settings")
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
local bind = require("lua.lib.bind")
|
||||||
|
local colorscheme = require("lua.conf.colorscheme")
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.autostart = {
|
||||||
|
function ()
|
||||||
|
hl.exec_cmd("hyprctl plugin load /usr/lib/hyprland-plugins/hyprexpo.so")
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
M.confs = {
|
||||||
|
plugin = {
|
||||||
|
hyprexpo = {
|
||||||
|
columns = 3,
|
||||||
|
gap_size = 5,
|
||||||
|
gap_size_outer = 0,
|
||||||
|
bg_col = colorscheme.background,
|
||||||
|
workspace_method = "center current",
|
||||||
|
skip_empty = false,
|
||||||
|
max_workspace = 0,
|
||||||
|
show_workspace_numbers = false,
|
||||||
|
workspace_number_color = colorscheme.foreground,
|
||||||
|
window_icon_enable = false,
|
||||||
|
window_icon_position = "bottom-right",
|
||||||
|
window_icon_size = 32,
|
||||||
|
label_enable = false,
|
||||||
|
label_text_mode = "id",
|
||||||
|
label_token_map = "",
|
||||||
|
selection_label_enable = false,
|
||||||
|
selection_label_token_map = "a,s,d,f,g,q,w,e,r,t,z,x,c,v,b",
|
||||||
|
gesture_distance = 300,
|
||||||
|
cancel_key = "escape",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
M.binds = {
|
||||||
|
{
|
||||||
|
keys = bind.with_leader("F3"),
|
||||||
|
dispatcher = function()
|
||||||
|
hl.plugin.hyprexpo.expo("toggle")
|
||||||
|
end,
|
||||||
|
desc = "Toggle hyprexpo"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
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
|
||||||
Reference in New Issue
Block a user