Closed mochouaaaaa closed 1 month ago
The solution I'm currently using is.
local function is_tmux(pane) return pane:get_user_vars().WEZTERM_IN_TMUX == "1" end
-- Mapping modifier keys to CSI codes
local mod_map = {
SHIFT = 1,
ALT = 2,
CTRL = 4,
CMD = 8,
}
-- Function: Generate CSI Sequence
function get_csi_sequence(key, mods)
local mod_code = 0 -- default is 0
for mod in string.gmatch(mods, "([^|]+)") do
if mod_map[mod] then
mod_code = mod_code + mod_map[mod]
end
end
local csi_sequence = string.format("\x1b[%d;%du", string.byte(key), mod_code + 1)
print(mods, key)
print(string.format("Generated CSI sequence: \\x1b[%d;%du", string.byte(key), mod_code + 1))
return csi_sequence
end
function M.wezterm_nvim(operation, key, mods)
return {
key = key,
mods = mods,
action = w.action_callback(function(win, pane)
-- not run tmux
if is_vim(pane) or is_tmux(pane) then
-- pass the keys through to vim/nvim
local csi_keymap = get_csi_sequence(key, mods)
win:perform_action({ SendString = csi_keymap }, pane)
-- win:perform_action({ SendKey = { key = key, mods = mods } }, pane)
else
if operation == "resize" then
win:perform_action({ AdjustPaneSize = { direction_keys[key], 3 } }, pane)
elseif operation == "move" then
win:perform_action({ ActivatePaneDirection = direction_keys[key] }, pane)
elseif operation == "split" then
win:perform_action({ SplitPane = { direction = direction_keys[key] } }, pane)
elseif operation == "close_tab" then
win:perform_action({ CloseCurrentPane = { confirm = false } }, pane)
end
-- end
end
end),
}
end
Similar Issues
Neovim Version
NVIM v0.10.0 Build type: Release LuaJIT 2.1.1716656478 Run "nvim -V1 -v" for more info
Multiplexer Integration
Wezterm
Multiplexer Version
wezterm 20240203-110809-5046fc22
Steps to Reproduce
Expected Behavior
Actual Behavior
Minimal Configuration to Reproduce
Additional Details and/or Screenshots
not error image
error image