Wezterm & neovim navigation
This commit is contained in:
parent
b490e41bd1
commit
a3a18c76d9
|
@ -85,12 +85,77 @@ local function unmap(key, mods)
|
|||
}
|
||||
end
|
||||
|
||||
local function bind_if(cond, key, mods, action)
|
||||
local function callback(win, pane)
|
||||
if cond(pane) then
|
||||
win:perform_action(action, pane)
|
||||
else
|
||||
win:perform_action(
|
||||
wezterm.action.SendKey({ key = key, mods = mods }),
|
||||
pane
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
return { key = key, mods = mods, action = wezterm.action_callback(callback) }
|
||||
end
|
||||
|
||||
-- {{{ Detect nvim processes
|
||||
local function is_inside_vim(pane)
|
||||
local tty = pane:get_tty_name()
|
||||
if tty == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
local success, _, _ = wezterm.run_child_process({
|
||||
"sh",
|
||||
"-c",
|
||||
"ps -o state= -o comm= -t"
|
||||
.. wezterm.shell_quote_arg(tty)
|
||||
.. " | "
|
||||
.. "grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)?$'",
|
||||
})
|
||||
|
||||
return success
|
||||
end
|
||||
|
||||
local function is_outside_vim(pane)
|
||||
return not is_inside_vim(pane)
|
||||
end
|
||||
-- }}}
|
||||
|
||||
config.keys = {
|
||||
-- {{{ Disable certain default keybinds
|
||||
unmap("f", "CTRL|SHIFT"),
|
||||
unmap("w", "CTRL|SHIFT"),
|
||||
unmap("Enter", "ALT"),
|
||||
-- }}}
|
||||
-- {{{ Nvim nevigation keybinds
|
||||
bind_if(
|
||||
is_outside_vim,
|
||||
"h",
|
||||
"CTRL",
|
||||
wezterm.action.ActivatePaneDirection("Left")
|
||||
),
|
||||
bind_if(
|
||||
is_outside_vim,
|
||||
"j",
|
||||
"CTRL",
|
||||
wezterm.action.ActivatePaneDirection("Down")
|
||||
),
|
||||
bind_if(
|
||||
is_outside_vim,
|
||||
"k",
|
||||
"CTRL",
|
||||
wezterm.action.ActivatePaneDirection("Up")
|
||||
),
|
||||
bind_if(
|
||||
is_outside_vim,
|
||||
"l",
|
||||
"CTRL",
|
||||
wezterm.action.ActivatePaneDirection("Right")
|
||||
),
|
||||
-- }}}
|
||||
}
|
||||
-- }}}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
"mini.pairs": { "branch": "main", "commit": "04f58f2545ed80ac3b52dd4826e93f33e15b2af6" },
|
||||
"mini.statusline": { "branch": "main", "commit": "dfd3d2ba295473930f78f143852b9b53eb54ae2a" },
|
||||
"mini.surround": { "branch": "main", "commit": "a1b590cc3b676512de507328d6bbab5e43794720" },
|
||||
"navigator": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
|
||||
"neoconf": { "branch": "main", "commit": "4ef6c6c5882e7e16209173fb8c47414202843384" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "b0ccf605c952eb0d1efe3692d5b241c52ceee187" },
|
||||
"nui": { "branch": "main", "commit": "c3c7fd618dcb5a89e443a2e1033e7d11fdb0596b" },
|
||||
|
|
|
@ -736,7 +736,7 @@ let
|
|||
[ "<tab>d" "<tab>f" "<tab>F" "<tab>h" "<tab>r" ]
|
||||
];
|
||||
|
||||
# {{{ Keymaps
|
||||
# {{{ Keybinds
|
||||
opts.mappings = {
|
||||
add = "<tab>s"; # Add surrounding in Normal and Visul modes
|
||||
delete = "<tab>d"; # Delete surrounding
|
||||
|
@ -1348,6 +1348,20 @@ let
|
|||
};
|
||||
};
|
||||
# }}}
|
||||
# {{{ navigator
|
||||
navigator = {
|
||||
package = "numToStr/Navigator.nvim";
|
||||
cond = blacklist [ "vscode" "firenvim" "neovide" ];
|
||||
|
||||
config = true;
|
||||
keys = [
|
||||
(nmap "<c-h>" "<cmd>NavigatorLeft<cr>" "Navigate left")
|
||||
(nmap "<c-j>" "<cmd>NavigatorDown<cr>" "Navigate down")
|
||||
(nmap "<c-k>" "<cmd>NavigatorUp<cr>" "Navigate up")
|
||||
(nmap "<c-l>" "<cmd>NavigatorRight<cr>" "Navigate right")
|
||||
];
|
||||
};
|
||||
# }}}
|
||||
# }}}
|
||||
};
|
||||
# }}}
|
||||
|
|
Loading…
Reference in a new issue