christoomey / vim-tmux-navigator

Seamless navigation between tmux panes and vim splits
MIT License
5.28k stars 325 forks source link

Able to move from NVim to Tmux, but not backwards #306

Closed hjfitz closed 3 years ago

hjfitz commented 3 years ago

I think this is a bit of a weird one looking at the issues. I can move around vim splits and from vim in to another tmux split. When I go to move back in to my Vim split (or any split, for that matter), I can't.

Info

Vim

▶ vim --version
NVIM v0.4.4
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20210318-48132-k7r45c/neovim-0.4.4/build/config -I/tmp/neovim-20210318-48132-k7r45c/neovim-0.4.4/src -I/usr/local/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20210318-48132-k7r45c/neovim-0.4.4/build/src/nvim/auto -I/tmp/neovim-20210318-48132-k7r45c/neovim-0.4.4/build/include
Compiled by brew@BigSur

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.4.4_2/share/nvim"

Run :checkhealth for more info

Tmux

▶ tmux -V
tmux 3.2
▶ cat ~/.tmux.conf
#set-option -g default-command "reattach-to-user-namespace -l zsh"
#set-option -ga terminal-overrides ",xterm*:Tc"
# sane splitting
bind | split-window -h
bind - split-window -v
#unbind '"'
#unbind %

# babby mode
set-option -g mouse on

# resize easier
#bind j resize-pane -D 10
#bind k resize-pane -U 10
#bind l resize-pane -L 10
#bind h resize-pane -R 10

#set -s escape-time 0

# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h'  'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j'  'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k'  'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l'  'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\'  'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\'  'select-pane -l'"

bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R

System/Other

Zsh: zsh 5.8 (x86_64-apple-darwin20.0) OS: Big Sur Term: iTerm 2, 3.3.7

hjfitz commented 3 years ago

Installing the plugin worked! 👍