Adds config for smart split navigation
This commit is contained in:
parent
1b8e401ada
commit
158700874c
6 changed files with 57 additions and 20 deletions
|
|
@ -20,13 +20,7 @@
|
||||||
"6" = "secondary";
|
"6" = "secondary";
|
||||||
};
|
};
|
||||||
mode.main.binding = {
|
mode.main.binding = {
|
||||||
alt-h = "focus left";
|
|
||||||
alt-j = "focus down";
|
|
||||||
alt-k = "focus up";
|
|
||||||
alt-l = "focus right";
|
|
||||||
alt-shift-h = "move left";
|
alt-shift-h = "move left";
|
||||||
alt-shift-j = "move down";
|
|
||||||
alt-shift-k = "move up";
|
|
||||||
alt-shift-l = "move right";
|
alt-shift-l = "move right";
|
||||||
alt-comma = "layout tiles horizontal vertical";
|
alt-comma = "layout tiles horizontal vertical";
|
||||||
alt-period = "layout accordion horizontal vertical";
|
alt-period = "layout accordion horizontal vertical";
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,7 @@
|
||||||
"6" = "secondary";
|
"6" = "secondary";
|
||||||
};
|
};
|
||||||
mode.main.binding = {
|
mode.main.binding = {
|
||||||
alt-h = "focus left";
|
|
||||||
alt-j = "focus down";
|
|
||||||
alt-k = "focus up";
|
|
||||||
alt-l = "focus right";
|
|
||||||
alt-shift-h = "move left";
|
alt-shift-h = "move left";
|
||||||
alt-shift-j = "move down";
|
|
||||||
alt-shift-k = "move up";
|
|
||||||
alt-shift-l = "move right";
|
alt-shift-l = "move right";
|
||||||
alt-comma = "layout tiles horizontal vertical";
|
alt-comma = "layout tiles horizontal vertical";
|
||||||
alt-period = "layout accordion horizontal vertical";
|
alt-period = "layout accordion horizontal vertical";
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
fd . ~/dev/ride/apps/backend/backend-services -t d -d 1;
|
fd . ~/dev/ride/apps/backend/backend-services -t d -d 1;
|
||||||
fd . ~/dev/ride/apps/frontend/projects -t d -d 1;
|
fd . ~/dev/ride/apps/frontend/projects -t d -d 1;
|
||||||
fd . ~/dev/ride/apps/native -t d -d 1;
|
fd . ~/dev/ride/apps/native -t d -d 1;
|
||||||
fd . ~/dev/ride/packages -t d -d 1;
|
# Enable as soon as we have packages
|
||||||
|
# fd . ~/dev/ride/packages -t d -d 1;
|
||||||
echo "$HOME/dev/ride/apps/frontend";
|
echo "$HOME/dev/ride/apps/frontend";
|
||||||
echo "$HOME/dev/ride/apps/lib";
|
echo "$HOME/dev/ride/apps/lib";
|
||||||
echo "$HOME/dev/ride";
|
echo "$HOME/dev/ride";
|
||||||
|
|
|
||||||
19
home/modules/nvim/config/lua/plugins/smart-splits.lua
Normal file
19
home/modules/nvim/config/lua/plugins/smart-splits.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
return {
|
||||||
|
"mrjones2014/smart-splits.nvim",
|
||||||
|
keys = {
|
||||||
|
{ "<C-h>", "require('smart-splits').move_cursor_left", desc = "Move to left split", mode = "n" },
|
||||||
|
{ "<C-j>", "require('smart-splits').move_cursor_down", desc = "Move to lower split", mode = "n" },
|
||||||
|
{ "<C-k>", "require('smart-splits').move_cursor_up", desc = "Move to upper split", mode = "n" },
|
||||||
|
{ "<C-l>", "require('smart-splits').move_cursor_right", desc = "Move to right split", mode = "n" },
|
||||||
|
|
||||||
|
{ "<A-h>", "require('smart-splits').resize_left", desc = "Resize to left", mode = "n" },
|
||||||
|
{ "<A-j>", "require('smart-splits').resize_down", desc = "Resize lower", mode = "n" },
|
||||||
|
{ "<A-k>", "require('smart-splits').resize_up", desc = "Resize upper", mode = "n" },
|
||||||
|
{ "<A-l>", "require('smart-splits').resize_right", desc = "Resize to right", mode = "n" },
|
||||||
|
|
||||||
|
{ "<leader>mh", "require('smart-splits').swap_buf_left", desc = "Swap to left" },
|
||||||
|
{ "<leader>mj", "require('smart-splits').swap_buf_down", desc = "Swap to lower" },
|
||||||
|
{ "<leader>mk", "require('smart-splits').swap_buf_up", desc = "Swap to upper" },
|
||||||
|
{ "<leader>ml", "require('smart-splits').swap_buf_right", desc = "Swap to right" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -44,11 +44,36 @@ function M.get_padding(padding, remove_padding_bottom)
|
||||||
}
|
}
|
||||||
end
|
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 {
|
return {
|
||||||
key = key,
|
key = key,
|
||||||
mods = "LEADER",
|
mods = resize_or_move == "resize" and "META" or "CTRL",
|
||||||
action = wezterm.action.ActivatePaneDirection(direction),
|
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
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,14 @@ function M.apply_to_config(config)
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
-- Navigation
|
-- Navigation
|
||||||
helpers.move_pane("j", "Down"),
|
helpers.split_nav("move", "h"),
|
||||||
helpers.move_pane("k", "Up"),
|
helpers.split_nav("move", "j"),
|
||||||
helpers.move_pane("h", "Left"),
|
helpers.split_nav("move", "k"),
|
||||||
helpers.move_pane("l", "Right"),
|
helpers.split_nav("move", "l"),
|
||||||
|
helpers.split_nav("resize", "h"),
|
||||||
|
helpers.split_nav("resize", "j"),
|
||||||
|
helpers.split_nav("resize", "k"),
|
||||||
|
helpers.split_nav("resize", "l"),
|
||||||
-- Workspaces
|
-- Workspaces
|
||||||
{
|
{
|
||||||
key = "s",
|
key = "s",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue