forked from dineshsalunke/wezterm-config
refactor: add size for the pane splits
This commit is contained in:
parent
90cfde370a
commit
6e2ccb46df
160
keymaps.lua
160
keymaps.lua
@ -5,98 +5,98 @@ local gui = wezterm.gui
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local direction_keys = {
|
local direction_keys = {
|
||||||
Left = "h",
|
Left = "h",
|
||||||
Down = "j",
|
Down = "j",
|
||||||
Up = "k",
|
Up = "k",
|
||||||
Right = "l",
|
Right = "l",
|
||||||
-- reverse lookup
|
-- reverse lookup
|
||||||
h = "Left",
|
h = "Left",
|
||||||
j = "Down",
|
j = "Down",
|
||||||
k = "Up",
|
k = "Up",
|
||||||
l = "Right",
|
l = "Right",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- if you are *NOT* lazy-loading smart-splits.nvim (recommended)
|
-- if you are *NOT* lazy-loading smart-splits.nvim (recommended)
|
||||||
local function is_vim(pane)
|
local function is_vim(pane)
|
||||||
-- this is set by the plugin, and unset on ExitPre in Neovim
|
-- this is set by the plugin, and unset on ExitPre in Neovim
|
||||||
return pane:get_user_vars().IS_NVIM == "true"
|
return pane:get_user_vars().IS_NVIM == "true"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function split_nav(resize_or_move, key)
|
local function split_nav(resize_or_move, key)
|
||||||
return {
|
return {
|
||||||
key = key,
|
key = key,
|
||||||
mods = resize_or_move == "resize" and "META" or "CTRL",
|
mods = resize_or_move == "resize" and "META" or "CTRL",
|
||||||
action = wezterm.action_callback(function(win, pane)
|
action = wezterm.action_callback(function(win, pane)
|
||||||
if is_vim(pane) then
|
if is_vim(pane) then
|
||||||
-- pass the keys through to vim/nvim
|
-- pass the keys through to vim/nvim
|
||||||
win:perform_action({
|
win:perform_action({
|
||||||
SendKey = { key = key, mods = resize_or_move == "resize" and "META" or "CTRL" },
|
SendKey = { key = key, mods = resize_or_move == "resize" and "META" or "CTRL" },
|
||||||
}, pane)
|
}, pane)
|
||||||
else
|
else
|
||||||
if resize_or_move == "resize" then
|
if resize_or_move == "resize" then
|
||||||
win:perform_action({ AdjustPaneSize = { direction_keys[key], 3 } }, pane)
|
win:perform_action({ AdjustPaneSize = { direction_keys[key], 3 } }, pane)
|
||||||
else
|
else
|
||||||
win:perform_action({ ActivatePaneDirection = direction_keys[key] }, pane)
|
win:perform_action({ ActivatePaneDirection = direction_keys[key] }, pane)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.options(config)
|
function M.options(config)
|
||||||
--
|
--
|
||||||
config.leader = { key = "a", mods = "CTRL" }
|
config.leader = { key = "a", mods = "CTRL" }
|
||||||
|
|
||||||
config.keys = {
|
config.keys = {
|
||||||
{ key = "a", mods = "LEADER|CTRL", action = wezterm.action({ SendString = "\x01" }) },
|
{ key = "a", mods = "LEADER|CTRL", action = wezterm.action({ SendString = "\x01" }) },
|
||||||
{ key = "-", mods = "LEADER", action = wezterm.action({ SplitVertical = { domain = "CurrentPaneDomain" } }) },
|
{ key = "-", mods = "LEADER", action = wezterm.action({ SplitPane = { direction = "Down", size = { Percent = 25 } } }) },
|
||||||
{
|
{
|
||||||
key = "\\",
|
key = "\\",
|
||||||
mods = "LEADER",
|
mods = "LEADER",
|
||||||
action = wezterm.action({ SplitHorizontal = { domain = "CurrentPaneDomain" } }),
|
action = wezterm.action({ SplitPane = { direction = "Right", size = { Percent = 25 } } })
|
||||||
},
|
},
|
||||||
{ key = "z", mods = "LEADER", action = "TogglePaneZoomState" },
|
{ key = "z", mods = "LEADER", action = "TogglePaneZoomState" },
|
||||||
{ key = "c", mods = "LEADER", action = wezterm.action({ SpawnTab = "CurrentPaneDomain" }) },
|
{ key = "c", mods = "LEADER", action = wezterm.action({ SpawnTab = "CurrentPaneDomain" }) },
|
||||||
{ key = "x", mods = "LEADER", action = wezterm.action.CloseCurrentPane({ confirm = true }) },
|
{ key = "x", mods = "LEADER", action = wezterm.action.CloseCurrentPane({ confirm = true }) },
|
||||||
{ key = "n", mods = "LEADER", action = wezterm.action.ToggleFullScreen },
|
{ key = "n", mods = "LEADER", action = wezterm.action.ToggleFullScreen },
|
||||||
{ key = "p", mods = "CTRL|SHIFT", action = wezterm.action.ActivateCommandPalette },
|
{ key = "p", mods = "CTRL|SHIFT", action = wezterm.action.ActivateCommandPalette },
|
||||||
{ key = "c", mods = "CTRL|SHIFT", action = wezterm.action.CopyTo("ClipboardAndPrimarySelection") },
|
{ key = "c", mods = "CTRL|SHIFT", action = wezterm.action.CopyTo("ClipboardAndPrimarySelection") },
|
||||||
{ key = "v", mods = "CTRL|SHIFT", action = wezterm.action.PasteFrom("Clipboard") },
|
{ key = "v", mods = "CTRL|SHIFT", action = wezterm.action.PasteFrom("Clipboard") },
|
||||||
-- move between split panes
|
-- move between split panes
|
||||||
split_nav("move", "h"),
|
split_nav("move", "h"),
|
||||||
split_nav("move", "j"),
|
split_nav("move", "j"),
|
||||||
split_nav("move", "k"),
|
split_nav("move", "k"),
|
||||||
split_nav("move", "l"),
|
split_nav("move", "l"),
|
||||||
-- resize panes
|
-- resize panes
|
||||||
split_nav("resize", "h"),
|
split_nav("resize", "h"),
|
||||||
split_nav("resize", "j"),
|
split_nav("resize", "j"),
|
||||||
split_nav("resize", "k"),
|
split_nav("resize", "k"),
|
||||||
{
|
{
|
||||||
key = ",",
|
key = ",",
|
||||||
mods = "LEADER",
|
mods = "LEADER",
|
||||||
action = act.PromptInputLine({
|
action = act.PromptInputLine({
|
||||||
description = "Enter new name for tab",
|
description = "Enter new name for tab",
|
||||||
action = wezterm.action_callback(function(window, pane, line)
|
action = wezterm.action_callback(function(window, pane, line)
|
||||||
-- line will be `nil` if they hit escape without entering anything
|
-- line will be `nil` if they hit escape without entering anything
|
||||||
-- An empty string if they just hit enter
|
-- An empty string if they just hit enter
|
||||||
-- Or the actual line of text they wrote
|
-- Or the actual line of text they wrote
|
||||||
if line then
|
if line then
|
||||||
window:active_tab():set_title(line)
|
window:active_tab():set_title(line)
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
split_nav("resize", "l"),
|
split_nav("resize", "l"),
|
||||||
}
|
}
|
||||||
|
|
||||||
for i = 1, 8 do
|
for i = 1, 8 do
|
||||||
-- CTRL+ALT + number to activate that tab
|
-- CTRL+ALT + number to activate that tab
|
||||||
table.insert(config.keys, {
|
table.insert(config.keys, {
|
||||||
key = tostring(i),
|
key = tostring(i),
|
||||||
mods = "LEADER",
|
mods = "LEADER",
|
||||||
action = wezterm.action.ActivateTab(i - 1),
|
action = wezterm.action.ActivateTab(i - 1),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user