Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default key bindings #46

Open
ya2s opened this issue Oct 29, 2021 · 7 comments
Open

Use default key bindings #46

ya2s opened this issue Oct 29, 2021 · 7 comments
Labels
question Further information is requested

Comments

@ya2s
Copy link

ya2s commented Oct 29, 2021

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?

@ya2s
Copy link
Author

ya2s commented Oct 30, 2021

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

@aserowy aserowy added the question Further information is requested label Dec 13, 2021
@aserowy
Copy link
Owner

aserowy commented Dec 13, 2021

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

@ya2s
Copy link
Author

ya2s commented Dec 13, 2021

@aserowy
Thank you for your reply
Try it with the above settings!
Still doesn't work
The version is stable v0.6.0

@aserowy
Copy link
Owner

aserowy commented Dec 16, 2021

Heho,

you wrote, that even the defaults are not working. Is this still the case for you?

Kind regards

@ErickChacon
Copy link

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>]],
})

@ya2s
Copy link
Author

ya2s commented Apr 20, 2022

@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.

@ya2s
Copy link
Author

ya2s commented Apr 21, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants