Compare commits
3 commits
f7de9e3c05
...
d6e648595a
| Author | SHA1 | Date | |
|---|---|---|---|
| d6e648595a | |||
| 9971d2d2a5 | |||
| 3fe607d310 |
2 changed files with 118 additions and 93 deletions
|
|
@ -4,9 +4,6 @@ local wezterm = require("wezterm")
|
||||||
-- Log warnings or generate errors if we define an invalid configuration option
|
-- Log warnings or generate errors if we define an invalid configuration option
|
||||||
local config = wezterm.config_builder()
|
local config = wezterm.config_builder()
|
||||||
|
|
||||||
-- Install plugins
|
|
||||||
local smart_splits = wezterm.plugin.require("https://github.com/mrjones2014/smart-splits.nvim")
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- General configuration options.
|
-- General configuration options.
|
||||||
--
|
--
|
||||||
|
|
@ -92,124 +89,103 @@ config.leader = { key = "a", mods = "ALT", timeout_milliseconds = 2000 }
|
||||||
-- General keymaps
|
-- General keymaps
|
||||||
config.keys = {
|
config.keys = {
|
||||||
--
|
--
|
||||||
-- Tab management
|
-- Enter key table modes
|
||||||
--
|
--
|
||||||
|
|
||||||
{ -- Spawn new tab
|
{ -- Enter tab management mode
|
||||||
key = "t",
|
key = "t",
|
||||||
mods = "LEADER",
|
mods = "LEADER",
|
||||||
action = wezterm.action.SpawnTab("CurrentPaneDomain"),
|
action = wezterm.action.ActivateKeyTable({
|
||||||
|
name = "tab_mode",
|
||||||
|
one_shot = true,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ -- Enter pane management mode
|
||||||
|
key = "p",
|
||||||
|
mods = "LEADER",
|
||||||
|
action = wezterm.action.ActivateKeyTable({
|
||||||
|
name = "pane_mode",
|
||||||
|
one_shot = true,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Navigation
|
||||||
|
--
|
||||||
|
|
||||||
{ -- Focus previous tab
|
{ -- Focus previous tab
|
||||||
key = "Home",
|
key = "LeftArrow",
|
||||||
mods = "ALT",
|
mods = "ALT",
|
||||||
action = wezterm.action.ActivateTabRelative(-1),
|
action = wezterm.action.ActivateTabRelative(-1),
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- Focus next tab
|
{ -- Focus next tab
|
||||||
key = "End",
|
key = "RightArrow",
|
||||||
mods = "ALT",
|
mods = "ALT",
|
||||||
action = wezterm.action.ActivateTabRelative(1),
|
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
|
{ -- Focus previous pane
|
||||||
key = "PageUp",
|
key = "UpArrow",
|
||||||
mods = "ALT",
|
mods = "ALT",
|
||||||
action = wezterm.action.ActivatePaneDirection("Prev"),
|
action = wezterm.action.ActivatePaneDirection("Prev"),
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- Focus next pane
|
{ -- Focus next pane
|
||||||
key = "PageDown",
|
key = "DownArrow",
|
||||||
mods = "ALT",
|
mods = "ALT",
|
||||||
action = wezterm.action.ActivatePaneDirection("Next"),
|
action = wezterm.action.ActivatePaneDirection("Next"),
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- Rotate panes counter-clockwise
|
{ -- Rotate panes counter-clockwise
|
||||||
key = "PageUp",
|
key = "PageUp",
|
||||||
mods = "ALT|CTRL",
|
mods = "ALT",
|
||||||
action = wezterm.action.RotatePanes("CounterClockwise"),
|
action = wezterm.action.RotatePanes("CounterClockwise"),
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- Rotate panes clockwise
|
{ -- Rotate panes clockwise
|
||||||
key = "PageDown",
|
key = "PageDown",
|
||||||
mods = "ALT|CTRL",
|
mods = "ALT",
|
||||||
action = wezterm.action.RotatePanes("Clockwise"),
|
action = wezterm.action.RotatePanes("Clockwise"),
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- Maximize/zoom pane
|
{ -- Focus largest (master) pane
|
||||||
key = "m",
|
key = "Delete",
|
||||||
mods = "LEADER",
|
mods = "ALT",
|
||||||
action = wezterm.action.TogglePaneZoomState,
|
action = wezterm.action_callback(function(window, pane)
|
||||||
},
|
local tab = window:active_tab()
|
||||||
|
local largest = nil
|
||||||
|
local largest_size = 0
|
||||||
|
|
||||||
{ -- Quit/close pane
|
for _, p in ipairs(tab:panes()) do
|
||||||
key = "q",
|
local dims = p:get_dimensions()
|
||||||
mods = "LEADER",
|
local size = dims.pixel_width * dims.pixel_height
|
||||||
action = wezterm.action.CloseCurrentPane({ confirm = false }),
|
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),
|
||||||
},
|
},
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Copy / Paste
|
-- Copy / Paste
|
||||||
--
|
--
|
||||||
|
|
||||||
{ -- Activate vi copy mode
|
{ -- Enter copy mode
|
||||||
key = "x",
|
key = "Escape",
|
||||||
mods = "LEADER",
|
mods = "LEADER",
|
||||||
action = wezterm.action.ActivateCopyMode,
|
action = wezterm.action.ActivateCopyMode,
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- Paste from clipboard
|
{ -- Paste from clipboard
|
||||||
key = "p",
|
key = "v",
|
||||||
mods = "LEADER",
|
mods = "CTRL|SHIFT",
|
||||||
action = wezterm.action.PasteFrom("Clipboard"),
|
action = wezterm.action.PasteFrom("Clipboard"),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -224,6 +200,68 @@ 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)
|
-- Jump to specific tabs by number (ALT + 1-9)
|
||||||
for i = 1, 9 do
|
for i = 1, 9 do
|
||||||
table.insert(config.keys, {
|
table.insert(config.keys, {
|
||||||
|
|
@ -233,16 +271,4 @@ for i = 1, 9 do
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
|
||||||
-- Enable neovim integration
|
|
||||||
--
|
|
||||||
|
|
||||||
smart_splits.apply_to_config(config, {
|
|
||||||
direction_keys = { "LeftArrow", "DownArrow", "UpArrow", "RightArrow" },
|
|
||||||
modifiers = {
|
|
||||||
move = "ALT",
|
|
||||||
resize = "ALT|CTRL",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
|
||||||
|
|
@ -30,21 +30,20 @@
|
||||||
|
|
||||||
# Install plugins
|
# Install plugins
|
||||||
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";
|
name = "fzf-tab";
|
||||||
src = pkgs.fetchFromGitHub {
|
src = "${pkgs.zsh-fzf-tab}/share/fzf-tab";
|
||||||
owner = "Aloxaf";
|
|
||||||
repo = "fzf-tab";
|
|
||||||
rev = "5a81e13792a1eed4a03d2083771ee6e5b616b9ab";
|
|
||||||
sha256 = "dPe5CLCAuuuLGRdRCt/nNruxMrP9f/oddRxERkgm1FE=";
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
# Extra commands that should be added to '.zshrc'
|
# Extra commands that should be added to '.zshrc'
|
||||||
initContent = ''
|
initContent = ''
|
||||||
eval "$(direnv hook zsh)"
|
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;5C" forward-word
|
||||||
bindkey "^[[1;5D" backward-word
|
bindkey "^[[1;5D" backward-word
|
||||||
export PATH
|
export PATH
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue