Files
2026-06-12 17:12:25 -04:00

72 lines
1.2 KiB
Lua

local bind = {}
bind.leader = "SUPER"
local function merge(...)
local out = {}
for _, t in ipairs({ ... }) do
if t ~= nil then
for k, v in pairs(t) do
out[k] = v
end
end
end
return out
end
function bind.with_leader(keys)
if keys == nil or keys == "" then
return bind.leader
end
return bind.leader .. " + " .. keys
end
function bind.key(keys, dispatcher, desc, opts)
local flags = merge(opts)
if desc ~= nil then
flags.description = desc
end
return hl.bind(keys, dispatcher, flags)
end
function bind.set(table)
local keys = table.keys
local dispatcher = table.dispatcher
local desc = ""
local opts = {}
if table.desc ~= nil and table.desc ~= "" then
desc = table.desc
end
if table.opts ~= nil then
opts = table.opts
end
bind.key(keys, dispatcher, desc, opts)
end
function bind.map(table)
for _, item in pairs(table) do
bind.set(item)
end
end
function bind.layout_dispatcher(actions, fallback)
return function()
local ws = hl.get_active_special_workspace() or hl.get_active_workspace()
if not ws then
return
end
local action = actions[ws.tiled_layout] or fallback
if action then
hl.dispatch(action)
end
end
end
return bind