Files
Hyprdots/lua/lib/bind.lua
T
2026-05-28 01:31:30 -04:00

42 lines
657 B
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
local function 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.leader_key(keys, dispatcher, desc, opts)
return bind.key(with_leader(keys), dispatcher, desc, opts)
end
return bind