diff --git a/wezterm/config/keys.lua b/wezterm/config/keys.lua index 61ee8d9..c4feae7 100644 --- a/wezterm/config/keys.lua +++ b/wezterm/config/keys.lua @@ -1,6 +1,7 @@ local wezterm = require("wezterm") local base = require("config/base") local events = require("config/events") +local act = wezterm.action local keymod = base.keymod local module = {} @@ -19,68 +20,78 @@ function module.apply_to_config(config) action = { SelectTextAtMouseCursor = "SemanticZone" }, mods = keymod, }, + + { + event = { Down = { streak = 1, button = "Left" } }, + action = act.ExtendSelectionToMouseCursor "Word", + mods = keymod, + }, } -- It also makes use of key tables which is defined after. config.keys = { -- Clipboard - { key = "c", mods = keymod, action = wezterm.action({ CopyTo = "Clipboard" }) }, - { key = "v", mods = keymod, action = wezterm.action({ PasteFrom = "Clipboard" }) }, + { key = "c", mods = keymod, action = act.CopyTo "Clipboard" }, + { key = "v", mods = keymod, action = act.PasteFrom "Clipboard" }, -- Font resize. - { key = "+", mods = keymod, action = "IncreaseFontSize" }, - { key = "_", mods = keymod, action = "DecreaseFontSize" }, - { key = ")", mods = keymod, action = "ResetFontSize" }, + { key = "+", mods = keymod, action = act.IncreaseFontSize }, + { key = "_", mods = keymod, action = act.DecreaseFontSize }, + { key = ")", mods = keymod, action = act.ResetFontSize }, -- Scrollback - { key = "j", mods = keymod, action = wezterm.action({ ScrollByPage = 1 }) }, - { key = "k", mods = keymod, action = wezterm.action({ ScrollByPage = -1 }) }, - { key = "j", mods = "CTRL|ALT", action = wezterm.action({ ScrollToPrompt = 1 }) }, - { key = "k", mods = "CTRL|ALT", action = wezterm.action({ ScrollToPrompt = -1 }) }, + { key = "j", mods = keymod, action = act.ScrollByPage(1) }, + { key = "k", mods = keymod, action = act.ScrollByPage(-1) }, + { key = "j", mods = "CTRL|ALT", action = act.ScrollToPrompt(1) }, + { key = "k", mods = "CTRL|ALT", action = act.ScrollToPrompt(-1) }, + { key = "G", mods = keymod, action = act.ScrollToBottom }, + { key = "g", mods = "CTRL|ALT", action = act.ScrollToTop }, -- Pane navigation. { key = "p", mods = "LEADER", - action = wezterm.action.ActivateKeyTable({ + action = act.ActivateKeyTable { name = "pane_navigation", timeout_milliseconds = 1000, replace_current = true, one_shot = true, - }), + }, }, + { key = "r", mods = "LEADER", - action = wezterm.action({ - ActivateKeyTable = { name = "resize_pane", replace_current = true, one_shot = false }, - }), + action = act.ActivateKeyTable { + name = "resize_pane", + replace_current = true, + one_shot = false, + }, }, - { key = "h", mods = keymod, action = wezterm.action({ ActivatePaneDirection = "Left" }) }, - { key = "l", mods = keymod, action = wezterm.action({ ActivatePaneDirection = "Right" }) }, - { key = "LeftArrow", mods = keymod, action = wezterm.action({ ActivatePaneDirection = "Left" }) }, - { key = "DownArrow", mods = keymod, action = wezterm.action({ ActivatePaneDirection = "Down" }) }, - { key = "UpArrow", mods = keymod, action = wezterm.action({ ActivatePaneDirection = "Up" }) }, - { key = "RightArrow", mods = keymod, action = wezterm.action({ ActivatePaneDirection = "Right" }) }, + + { key = "h", mods = keymod, action = act.ActivatePaneDirection("Left") }, + { key = "l", mods = keymod, action = act.ActivatePaneDirection("Right") }, + { key = "LeftArrow", mods = keymod, action = act.ActivatePaneDirection("Left") }, + { key = "DownArrow", mods = keymod, action = act.ActivatePaneDirection("Down") }, + { key = "UpArrow", mods = keymod, action = act.ActivatePaneDirection("Up") }, + { key = "RightArrow", mods = keymod, action = act.ActivatePaneDirection("Right") }, -- More pane-related niceties. - { key = "f", mods = "LEADER", action = "TogglePaneZoomState" }, - { key = "f", mods = keymod, action = "TogglePaneZoomState" }, - { key = "n", mods = "LEADER", action = wezterm.action({ SplitHorizontal = { domain = "CurrentPaneDomain" } }) }, - { key = "n", mods = keymod, action = wezterm.action({ SplitHorizontal = { domain = "CurrentPaneDomain" } }) }, - { key = "d", mods = keymod, action = wezterm.action({ CloseCurrentPane = { confirm = false } }) }, + { key = "f", mods = "LEADER", action = act.TogglePaneZoomState }, + { key = "f", mods = keymod, action = act.TogglePaneZoomState }, + { key = "n", mods = "LEADER", action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) }, + { key = "n", mods = keymod, action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) }, + { key = "d", mods = keymod, action = act.CloseCurrentPane({ confirm = false }) }, -- Tab navigation { key = "t", mods = "LEADER", - action = wezterm.action({ - ActivateKeyTable = { - name = "tab_navigation", - timeout_milliseconds = 1000, - replace_current = true, - one_shot = true, - }, + action = act.ActivateKeyTable({ + name = "tab_navigation", + timeout_milliseconds = 1000, + replace_current = true, + one_shot = true, }), }, @@ -88,94 +99,96 @@ function module.apply_to_config(config) { key = "h", mods = "LEADER", - action = wezterm.action({ - ActivateKeyTable = { name = "hints", timeout_milliseconds = 1000, replace_current = true, one_shot = true }, + action = act.ActivateKeyTable({ + name = "hints", + timeout_milliseconds = 1000, + replace_current = true, + one_shot = true }), }, - { key = "r", mods = keymod, action = "ReloadConfiguration" }, - { key = "t", mods = keymod, action = wezterm.action.ShowDebugOverlay }, + { key = "r", mods = keymod, action = act.ReloadConfiguration }, + { key = "t", mods = keymod, action = act.ShowDebugOverlay }, -- Selection - { key = "Space", mods = "LEADER", action = "QuickSelect" }, - { key = "a", mods = keymod, action = "QuickSelect" }, - { key = "s", mods = keymod, action = wezterm.action({ Search = { CaseSensitiveString = "" } }) }, + { key = "Space", mods = "LEADER", action = act.QuickSelect }, + { key = "a", mods = keymod, action = act.QuickSelect }, + { key = "s", mods = keymod, action = act.Search { CaseSensitiveString = "" } }, } config.key_tables = { hints = { - { key = "g", action = wezterm.action({ Search = { Regex = "[0-9a-f]{6,}" } }) }, + { key = "g", action = act.Search { Regex = "[0-9a-f]{6,}" } }, { key = "h", - action = wezterm.action({ - QuickSelectArgs = { - patterns = { - "[0-9a-f]{7,40}", -- SHA1 hashes, usually used for Git. - "[0-9a-f]{7,64}", -- SHA256 hashes, used often for getting hashes for Guix packaging. - "sha256-[[:alpha:][:digit:]-=+/?]{44}", -- SHA256 hashes in Base64, used often in getting hashes for Nix packaging. - "[[:alpha:][:digit:]-=+/?]{44,64}", - }, + action = act.QuickSelectArgs { + patterns = { + "[0-9a-f]{7,40}", -- SHA1 hashes, usually used for Git. + "[0-9a-f]{7,64}", -- SHA256 hashes, used often for getting hashes for Guix packaging. + "sha256-[[:alpha:][:digit:]-=+/?]{44}", -- SHA256 hashes in Base64, used often in getting hashes for Nix packaging. + "[[:alpha:][:digit:]-=+/?]{44,64}", }, - }), + }, }, -- Basically the equivalent of `kitty hints word`. { key = "w", - action = wezterm.action({ - QuickSelectArgs = { - patterns = { - "\\S+", - }, + action = act.QuickSelectArgs { + patterns = { + "\\S+", }, - }), + }, }, -- The equivalent to `kitty hints line`. { key = "l", - action = wezterm.action({ - QuickSelectArgs = { - patterns = { - ".+", - }, + action = act.QuickSelectArgs { + patterns = { + ".+", }, - }), + }, }, - { key = "p", action = wezterm.action({ Search = { Regex = "legacyPackages[[:alpha:][:digit:]]+" } }) }, + { + key = "p", + action = act.Search { + Regex = "legacyPackages[[:alpha:][:digit:]]+" + }, + }, - { key = "Space", action = "QuickSelect" }, - { key = "s", action = "QuickSelect" }, - { key = "f", action = wezterm.action({ Search = { CaseSensitiveString = "" } }) }, + { key = "Space", action = act.QuickSelect }, + { key = "s", action = act.QuickSelect }, + { key = "f", action = act.Search { CaseSensitiveString = "" } }, }, pane_navigation = { - { key = "d", action = wezterm.action({ CloseCurrentPane = { confirm = false } }) }, - { key = "h", action = wezterm.action({ ActivatePaneDirection = "Left" }) }, - { key = "j", action = wezterm.action({ ActivatePaneDirection = "Down" }) }, - { key = "k", action = wezterm.action({ ActivatePaneDirection = "Up" }) }, - { key = "l", action = wezterm.action({ ActivatePaneDirection = "Right" }) }, - { key = "n", action = wezterm.action({ SplitHorizontal = { domain = "CurrentPaneDomain" } }) }, + { key = "d", action = act.CloseCurrentPane { confirm = false } }, + { key = "h", action = act.ActivatePaneDirection("Left") }, + { key = "j", action = act.ActivatePaneDirection("Down") }, + { key = "k", action = act.ActivatePaneDirection("Up") }, + { key = "l", action = act.ActivatePaneDirection("Right") }, + { key = "n", action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) }, }, tab_navigation = { - { key = "d", action = wezterm.action({ CloseCurrentTab = { confirm = false } }) }, - { key = "h", action = wezterm.action({ ActivateTabRelative = -1 }) }, - { key = "j", action = wezterm.action({ ActivateTab = -1 }) }, - { key = "k", action = wezterm.action({ ActivateTab = 0 }) }, - { key = "l", action = wezterm.action({ ActivateTabRelative = 1 }) }, - { key = "n", action = wezterm.action({ SpawnTab = "CurrentPaneDomain" }) }, + { key = "d", action = act.CloseCurrentTab({ confirm = false }) }, + { key = "h", action = act.ActivateTabRelative(-1) }, + { key = "j", action = act.ActivateTab(-1) }, + { key = "k", action = act.ActivateTab(0) }, + { key = "l", action = act.ActivateTabRelative(1) }, + { key = "n", action = act.SpawnTab("CurrentPaneDomain") }, }, resize_pane = { - { key = "h", action = wezterm.action({ AdjustPaneSize = { "Left", 1 } }) }, - { key = "j", action = wezterm.action({ AdjustPaneSize = { "Down", 1 } }) }, - { key = "k", action = wezterm.action({ AdjustPaneSize = { "Up", 1 } }) }, - { key = "l", action = wezterm.action({ AdjustPaneSize = { "Right", 1 } }) }, - { key = "q", action = "PopKeyTable" }, - { key = "Escape", action = "PopKeyTable" }, - { key = "Enter", action = "PopKeyTable" }, + { key = "h", action = act.AdjustPaneSize({ "Left", 1 }) }, + { key = "j", action = act.AdjustPaneSize({ "Down", 1 }) }, + { key = "k", action = act.AdjustPaneSize({ "Up", 1 }) }, + { key = "l", action = act.AdjustPaneSize({ "Right", 1 }) }, + { key = "q", action = act.PopKeyTable }, + { key = "Escape", action = act.PopKeyTable }, + { key = "Enter", action = act.PopKeyTable }, }, } return config