Add support for no shift navigation keymaps
This commit is contained in:
parent
13bd3b3704
commit
0becf1e5cd
28
wezterm.lua
28
wezterm.lua
@ -53,14 +53,26 @@ config.keys = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local move_mods = 'CTRL|SHIFT'
|
local function send_move_key(window, pane)
|
||||||
local function send_key(window, pane)
|
-- TODO: Detect if vim/nvim is running
|
||||||
-- TODO: Detect if tmux is running
|
-- We can't use pane:get_foreground_process_info() because it appears to
|
||||||
-- Detect if vim/nvim is running
|
-- contain info about the most recent process launched in the pane. During
|
||||||
-- Failing that, check if there is only a single pane
|
-- testing this was lua-language-server.exe so obisouly can't be used to
|
||||||
return false
|
-- determine if we're running inside neovim.
|
||||||
|
-- WezTerm supports the OSC 1337 SetUserVar escape sequence, this could be
|
||||||
|
-- used to inform WezTerm that neovim is running in a given tab.
|
||||||
|
|
||||||
|
if pane:get_user_vars()['vim'] ~= nil then
|
||||||
|
if pane:get_user_vars().vim ~= '1' then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
elseif #window:active_tab():panes() > 1 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local move_mods = 'CTRL'
|
||||||
for _, map in pairs({
|
for _, map in pairs({
|
||||||
{ key = 'h', direction = 'Left' },
|
{ key = 'h', direction = 'Left' },
|
||||||
{ key = 'l', direction = 'Right' },
|
{ key = 'l', direction = 'Right' },
|
||||||
@ -71,9 +83,9 @@ for _, map in pairs({
|
|||||||
key = map.key,
|
key = map.key,
|
||||||
mods = move_mods,
|
mods = move_mods,
|
||||||
action = wezterm.action_callback(function(window, pane)
|
action = wezterm.action_callback(function(window, pane)
|
||||||
if send_key(window, pane) then
|
if send_move_key(window, pane) then
|
||||||
window:perform_action(
|
window:perform_action(
|
||||||
wezterm.action.SendKey({ key = map.key, modes = move_mods }), pane)
|
wezterm.action.SendKey({ key = map.key, mods = move_mods }), pane)
|
||||||
else
|
else
|
||||||
window:perform_action(
|
window:perform_action(
|
||||||
wezterm.action.ActivatePaneDirection(map.direction), pane)
|
wezterm.action.ActivatePaneDirection(map.direction), pane)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user