tmux.nvim
tmux.nvim copied to clipboard
Use default key bindings
I want to use vim's default keybindings (Ctrl-w + hjkl) to move between vim and tmux So I set it as follows:
init.lua (NVIM v0.6.0-dev+bec7f47ce)
local map = vim.api.nvim_set_keymap
local map_opts = {noremap = true, silent = true}
map("", "<C-w>h", ":lua require'tmux'.move_left()<cr>", map_opts)
map("", "<C-w>j", ":lua require'tmux'.move_bottom()<cr>", map_opts)
map("", "<C-w>k", ":lua require'tmux'.move_top()<cr>", map_opts)
map("", "<C-w>l", ":lua require'tmux'.move_right()<cr>", map_opts)
tmux.conf (tmux 3.2a)
bind -n C-w switch-client -T NAVIGATOR
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind -T NAVIGATOR h if-shell "$is_vim" "send-keys C-w h" "select-pane -L"
bind -T NAVIGATOR j if-shell "$is_vim" "send-keys C-w j" "select-pane -D"
bind -T NAVIGATOR k if-shell "$is_vim" "send-keys C-w k" "select-pane -U"
bind -T NAVIGATOR l if-shell "$is_vim" "send-keys C-w l" "select-pane -R"
bind -T NAVIGATOR C-w send-keys C-w
It was possible, but it stopped responding from a certain version What's wrong? Could the plugin support the default key bindings as well?
As per the README, using enable_default_keybindings didn't work either. I can move between tmux panels, but I can't move between vim windows in vim on tmux
Heho,
had a break from tmux and stuff (concentrating on work). Is it still not possible? I guess it was the nvim version because i cannot reproduce the behavior with default keybindings.
Kind regards
@aserowy Thank you for your reply Try it with the above settings! Still doesn't work The version is stable v0.6.0
Heho,
you wrote, that even the defaults are not working. Is this still the case for you?
Kind regards
Default binding works for my case.
local keymaps = require("tmux.keymaps")
keymaps.register("n", {
["<C-w>h"] = [[<cmd>lua require('tmux').move_left()<cr>]],
["<C-w>j"] = [[<cmd>lua require('tmux').move_bottom()<cr>]],
["<C-w>k"] = [[<cmd>lua require('tmux').move_top()<cr>]],
["<C-w>l"] = [[<cmd>lua require('tmux').move_right()<cr>]],
})
@aserowy @ErickChacon
When I move from vim on tmux to pane on tmux, I feel that :lua require('tmux').move_*()
doesn't work.
From tmux pane to tmux pane works fine. Moving from vim on tmux to vim on tmux also works fine.
https://github.com/numToStr/Navigator.nvim works fine