Compare commits

..

No commits in common. "d6e648595ab06320b0b574f3a57b3dc2e3064ce0" and "f7de9e3c058266a909b5323c82b51cf35f53089c" have entirely different histories.

2 changed files with 93 additions and 118 deletions

View file

@ -4,6 +4,9 @@ local wezterm = require("wezterm")
-- Log warnings or generate errors if we define an invalid configuration option
local config = wezterm.config_builder()
-- Install plugins
local smart_splits = wezterm.plugin.require("https://github.com/mrjones2014/smart-splits.nvim")
--
-- General configuration options.
--
@ -89,103 +92,124 @@ config.leader = { key = "a", mods = "ALT", timeout_milliseconds = 2000 }
-- General keymaps
config.keys = {
--
-- Enter key table modes
-- Tab management
--
{ -- Enter tab management mode
{ -- Spawn new tab
key = "t",
mods = "LEADER",
action = wezterm.action.ActivateKeyTable({
name = "tab_mode",
one_shot = true,
}),
action = wezterm.action.SpawnTab("CurrentPaneDomain"),
},
{ -- Enter pane management mode
key = "p",
mods = "LEADER",
action = wezterm.action.ActivateKeyTable({
name = "pane_mode",
one_shot = true,
}),
},
--
-- Navigation
--
{ -- Focus previous tab
key = "LeftArrow",
key = "Home",
mods = "ALT",
action = wezterm.action.ActivateTabRelative(-1),
},
{ -- Focus next tab
key = "RightArrow",
key = "End",
mods = "ALT",
action = wezterm.action.ActivateTabRelative(1),
},
{ -- Quit/close tab
key = "Q",
mods = "LEADER",
action = wezterm.action.CloseCurrentTab({ confirm = false }),
},
{ -- Rename current tab
key = ",",
mods = "LEADER",
action = wezterm.action_callback(function(window, pane)
local success, stdout, stderr = wezterm.run_child_process({
"dmenu",
"-fn",
"Fisa Code-10",
"-p",
"Tab name:",
})
if success and stdout then
local name = stdout:gsub("\n", "")
if name ~= "" then
window:active_tab():set_title(name)
end
end
end),
},
--
-- Pane management
--
{ -- Split pane vertically (bottom, 30%)
key = "s",
mods = "LEADER",
action = wezterm.action.SplitPane({
direction = "Down",
size = { Percent = 30 },
}),
},
{ -- Split pane horizontally (left, 28%)
key = "v",
mods = "LEADER",
action = wezterm.action.SplitPane({
direction = "Left",
size = { Percent = 28 },
}),
},
{ -- Focus previous pane
key = "UpArrow",
key = "PageUp",
mods = "ALT",
action = wezterm.action.ActivatePaneDirection("Prev"),
},
{ -- Focus next pane
key = "DownArrow",
key = "PageDown",
mods = "ALT",
action = wezterm.action.ActivatePaneDirection("Next"),
},
{ -- Rotate panes counter-clockwise
key = "PageUp",
mods = "ALT",
mods = "ALT|CTRL",
action = wezterm.action.RotatePanes("CounterClockwise"),
},
{ -- Rotate panes clockwise
key = "PageDown",
mods = "ALT",
mods = "ALT|CTRL",
action = wezterm.action.RotatePanes("Clockwise"),
},
{ -- Focus largest (master) pane
key = "Delete",
mods = "ALT",
action = wezterm.action_callback(function(window, pane)
local tab = window:active_tab()
local largest = nil
local largest_size = 0
{ -- Maximize/zoom pane
key = "m",
mods = "LEADER",
action = wezterm.action.TogglePaneZoomState,
},
for _, p in ipairs(tab:panes()) do
local dims = p:get_dimensions()
local size = dims.pixel_width * dims.pixel_height
if size > largest_size then
largest_size = size
largest = p
end
end
if largest and largest:pane_id() ~= pane:pane_id() then
largest:activate()
end
end),
{ -- Quit/close pane
key = "q",
mods = "LEADER",
action = wezterm.action.CloseCurrentPane({ confirm = false }),
},
--
-- Copy / Paste
--
{ -- Enter copy mode
key = "Escape",
{ -- Activate vi copy mode
key = "x",
mods = "LEADER",
action = wezterm.action.ActivateCopyMode,
},
{ -- Paste from clipboard
key = "v",
mods = "CTRL|SHIFT",
key = "p",
mods = "LEADER",
action = wezterm.action.PasteFrom("Clipboard"),
},
@ -200,68 +224,6 @@ config.keys = {
},
}
--
-- Key table definitions for modal keybinding namespaces
--
config.key_tables = {
-- Tab management mode (LEADER + t)
tab_mode = {
{ -- Create new tab
key = "n",
action = wezterm.action.SpawnTab("CurrentPaneDomain"),
},
{ -- Close current tab
key = "q",
action = wezterm.action.CloseCurrentTab({ confirm = false }),
},
{ -- Rename current tab
key = "r",
action = wezterm.action_callback(function(window, pane)
local success, stdout, stderr = wezterm.run_child_process({
"dmenu",
"-fn",
"Fisa Code-10",
"-p",
"Tab name:",
})
if success and stdout then
local name = stdout:gsub("\n", "")
if name ~= "" then
window:active_tab():set_title(name)
end
end
end),
},
},
-- Pane management mode (LEADER + p)
pane_mode = {
{ -- Split pane vertically (bottom, 30%)
key = "s",
action = wezterm.action.SplitPane({
direction = "Down",
size = { Percent = 30 },
}),
},
{ -- Split pane horizontally (left, 28%)
key = "v",
action = wezterm.action.SplitPane({
direction = "Left",
size = { Percent = 28 },
}),
},
{ -- Close current pane
key = "q",
action = wezterm.action.CloseCurrentPane({ confirm = false }),
},
{ -- Maximize/zoom pane
key = "m",
action = wezterm.action.TogglePaneZoomState,
},
},
}
-- Jump to specific tabs by number (ALT + 1-9)
for i = 1, 9 do
table.insert(config.keys, {
@ -271,4 +233,16 @@ for i = 1, 9 do
})
end
--
-- Enable neovim integration
--
smart_splits.apply_to_config(config, {
direction_keys = { "LeftArrow", "DownArrow", "UpArrow", "RightArrow" },
modifiers = {
move = "ALT",
resize = "ALT|CTRL",
},
})
return config

View file

@ -30,20 +30,21 @@
# Install plugins
plugins = [
{ # vi(vim) mode for ZSH
name = "zsh-vi-mode";
src = "${pkgs.zsh-vi-mode}/share/zsh-vi-mode";
}
{ # replace zsh's completion with fzf
{
name = "fzf-tab";
src = "${pkgs.zsh-fzf-tab}/share/fzf-tab";
src = pkgs.fetchFromGitHub {
owner = "Aloxaf";
repo = "fzf-tab";
rev = "5a81e13792a1eed4a03d2083771ee6e5b616b9ab";
sha256 = "dPe5CLCAuuuLGRdRCt/nNruxMrP9f/oddRxERkgm1FE=";
};
}
];
# Extra commands that should be added to '.zshrc'
initContent = ''
eval "$(direnv hook zsh)"
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
export PATH