Adds config for smart split navigation
This commit is contained in:
parent
1b8e401ada
commit
158700874c
6 changed files with 57 additions and 20 deletions
|
|
@ -44,11 +44,36 @@ function M.get_padding(padding, remove_padding_bottom)
|
|||
}
|
||||
end
|
||||
|
||||
function M.move_pane(key, direction)
|
||||
function M.is_vim(pane)
|
||||
-- this is set by the plugin, and unset on ExitPre in Neovim
|
||||
return pane:get_user_vars().IS_NVIM == "true"
|
||||
end
|
||||
|
||||
local direction_keys = {
|
||||
h = "Left",
|
||||
j = "Down",
|
||||
k = "Up",
|
||||
l = "Right",
|
||||
}
|
||||
|
||||
function M.split_nav(resize_or_move, key)
|
||||
return {
|
||||
key = key,
|
||||
mods = "LEADER",
|
||||
action = wezterm.action.ActivatePaneDirection(direction),
|
||||
mods = resize_or_move == "resize" and "META" or "CTRL",
|
||||
action = wezterm.action_callback(function(win, pane)
|
||||
if M.is_vim(pane) then
|
||||
-- pass the keys through to vim/nvim
|
||||
win:perform_action({
|
||||
SendKey = { key = key, mods = resize_or_move == "resize" and "META" or "CTRL" },
|
||||
}, pane)
|
||||
else
|
||||
if resize_or_move == "resize" then
|
||||
win:perform_action({ AdjustPaneSize = { direction_keys[key], 3 } }, pane)
|
||||
else
|
||||
win:perform_action({ ActivatePaneDirection = direction_keys[key] }, pane)
|
||||
end
|
||||
end
|
||||
end),
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue