local bind = require("lua.lib.bind") local utils = require("lua.lib.utils") local M = {} local function maximize_active_window() local actions = { scrolling = hl.dsp.layout("colresize 1.0"), } local fallback = hl.dsp.window.fullscreen({ mode = "maximized" }) return bind.layout_dispatcher(actions, fallback) end M.binds = { { keys = bind.with_leader("Q"), dispatcher = hl.dsp.window.close(), desc = "Close the window", }, { keys = bind.with_leader("SHIFT + Q"), dispatcher = hl.dsp.window.kill(), desc = "Kill the window", }, { keys = bind.with_leader("F"), dispatcher = hl.dsp.window.fullscreen({}), desc = "Toggle fullscreen the window", }, { keys = bind.with_leader("SHIFT + F"), dispatcher = maximize_active_window(), desc = "Toggle maximize the window", }, { keys = bind.with_leader("CTRL + SHIFT + F"), dispatcher = hl.dsp.window.fullscreen_state({ internal = 0, client = 2, action = "toggle" }), desc = "Toggle fake the window it's fullscreened", }, { keys = bind.with_leader("T"), dispatcher = hl.dsp.window.float(), desc = "Toggle float the window", }, { keys = bind.with_leader("R"), dispatcher = bind.layout_dispatcher({ dwindle = hl.dsp.layout("rotatesplit"), }, hl.dsp.no_op()), desc = "Toggle split", }, { keys = bind.with_leader("CTRL + R"), dispatcher = bind.layout_dispatcher({ dwindle = hl.dsp.layout("swapsplit"), master = hl.dsp.layout("swapnext"), }, hl.dsp.no_op()), }, } for key, dir in pairs({ H = "left", L = "right", K = "up", J = "down", }) do table.insert(M.binds, { keys = bind.with_leader("SHIFT+" .. key), dispatcher = hl.dsp.window.move({ direction = string.sub(dir, 1, 1) }), desc = "Move window " .. dir, }) table.insert(M.binds, { keys = bind.with_leader(key), dispatcher = hl.dsp.focus({ direction = string.sub(dir, 1, 1) }), desc = "Move window " .. dir, }) table.insert(M.binds, { keys = bind.with_leader("CTRL + " .. key), dispatcher = hl.dsp.window.move({ direction = string.sub(dir, 1, 1), group_aware = true }), desc = "Move window " .. dir .. " with group_aware", }) end M.binds = utils.list_extend(M.binds, { { keys = bind.with_leader("SHIFT + left"), dispatcher = hl.dsp.window.resize({ x = -100, y = 0, relative = true }), desc = "Resize window x-100", }, { keys = bind.with_leader("SHIFT + right"), dispatcher = hl.dsp.window.resize({ x = 100, y = 0, relative = true }), desc = "Resize window x+100", }, { keys = bind.with_leader("SHIFT + up"), dispatcher = hl.dsp.window.resize({ x = 0, y = -100, relative = true }), desc = "Resize window y-100", }, { keys = bind.with_leader("SHIFT + down"), dispatcher = hl.dsp.window.resize({ x = 0, y = 100, relative = true }), desc = "Resize window y+100", }, }) M.binds = utils.list_extend(M.binds, { { keys = bind.with_leader("mouse:272"), dispatcher = hl.dsp.window.drag(), desc = "Drag window", }, { keys = bind.with_leader("mouse:273"), dispatcher = hl.dsp.window.resize(), desc = "Resize window", }, }) M.binds = utils.list_extend(M.binds, { { keys = bind.with_leader("G"), dispatcher = hl.dsp.group.toggle(), desc = "Toggle a group", }, { keys = bind.with_leader("CTRL + Tab"), dispatcher = hl.dsp.group.next(), desc = "Switch to next window in group", }, { keys = bind.with_leader("CTRL + SHIFT + Tab"), dispatcher = hl.dsp.group.prev(), desc = "Switch to previous window in group", }, }) return M