wezterm: update bindings

This commit is contained in:
Gabriel Arazas 2023-07-06 19:48:58 +08:00
parent 32333798f6
commit c8e281b29d

View File

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