|
| 1 | +local M = {} |
| 2 | + |
| 3 | +local wezterm = require("wezterm") |
| 4 | +local act = wezterm.action |
| 5 | + |
| 6 | +---@param config unknown |
| 7 | +---@param opts { leader: { key: string, mods: string? }? } |
| 8 | +function M.apply_to_config(config, opts) |
| 9 | + local leader = opts.leader or { key = "b", mods = "CTRL" } |
| 10 | + |
| 11 | + config.leader = leader |
| 12 | + |
| 13 | + local keys = { |
| 14 | + { key = leader.key, mods = "LEADER|" .. leader.mods, action = act.SendKey(leader) }, |
| 15 | + |
| 16 | + -- Tabs |
| 17 | + { key = "c", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") }, |
| 18 | + { key = "&", mods = "LEADER", action = act.CloseCurrentTab({ confirm = true }) }, |
| 19 | + { key = "p", mods = "LEADER", action = act.ActivateTabRelative(-1) }, |
| 20 | + { key = "n", mods = "LEADER", action = act.ActivateTabRelative(1) }, |
| 21 | + { key = "l", mods = "LEADER", action = act.ActivateLastTab }, |
| 22 | + |
| 23 | + -- Panes |
| 24 | + { key = "%", mods = "LEADER", action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) }, |
| 25 | + { key = "\"", mods = "LEADER", action = act.SplitVertical({ domain = "CurrentPaneDomain" }) }, |
| 26 | + { key = "{", mods = "LEADER", action = act.RotatePanes("CounterClockwise") }, |
| 27 | + { key = "}", mods = "LEADER", action = act.RotatePanes("Clockwise") }, |
| 28 | + { key = "LeftArrow", mods = "LEADER", action = act.ActivatePaneDirection("Left") }, |
| 29 | + { key = "DownArrow", mods = "LEADER", action = act.ActivatePaneDirection("Down") }, |
| 30 | + { key = "UpArrow", mods = "LEADER", action = act.ActivatePaneDirection("Up") }, |
| 31 | + { key = "RightArrow", mods = "LEADER", action = act.ActivatePaneDirection("Right") }, |
| 32 | + { key = "q", mods = "LEADER", action = act.PaneSelect({ mode = "Activate" }) }, |
| 33 | + { key = "z", mods = "LEADER", action = act.TogglePaneZoomState }, |
| 34 | + { key = "LeftArrow", mods = "LEADER|CTRL", action = act.AdjustPaneSize({ "Left", 5 }) }, |
| 35 | + { key = "DownArrow", mods = "LEADER|CTRL", action = act.AdjustPaneSize({ "Down", 5 }) }, |
| 36 | + { key = "UpArrow", mods = "LEADER|CTRL", action = act.AdjustPaneSize({ "Up", 5 }) }, |
| 37 | + { key = "RightArrow", mods = "LEADER|CTRL", action = act.AdjustPaneSize({ "Right", 5 }) }, |
| 38 | + { key = "x", mods = "LEADER", action = act.CloseCurrentPane({ confirm = true }) }, |
| 39 | + |
| 40 | + -- Copy Mode |
| 41 | + { key = "[", mods = "LEADER", action = act.ActivateCopyMode }, |
| 42 | + } |
| 43 | + |
| 44 | + for i = 1, 9 do |
| 45 | + table.insert(keys, { key = tostring(i), mods = "LEADER", action = act.ActivateTab(i - 1) }) |
| 46 | + end |
| 47 | + |
| 48 | + if not config.keys then |
| 49 | + config.keys = {} |
| 50 | + end |
| 51 | + for _, key in ipairs(keys) do |
| 52 | + table.insert(config.keys, key) |
| 53 | + end |
| 54 | +end |
| 55 | + |
| 56 | +return M |
0 commit comments