christoomey / vim-tmux-navigator

Seamless navigation between tmux panes and vim splits
MIT License
5.24k stars 322 forks source link

Vim-Tmux-Navigator with Tmux only loophole 'C-h' #286

Open javijjavi opened 3 years ago

javijjavi commented 3 years ago

Hi everyone,

First of all, thank you for helping me. The issue is when I'm using vim tmux navigator with a session in tmux, I can use all the commands of vim tmux navigator, except the command Crtl + h.

Vim version 8.2.1913

Tmux version 3.1b

ZSH 5.8

TmuxNavigatorProccessList-

.tmux.conf.local- [...]

# 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
bind-key -T copy-mode-vi 'C-\' select-pane -l

vimrc-

runtime! debian.vim
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif
set number
set mouse=a
set numberwidth=1
set clipboard=unnamed
syntax enable
set showcmd
set ruler
set encoding=utf-8
set showmatch
set sw=2
set relativenumber
set laststatus=2
set cursorline
call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox'
Plug 'easymotion/vim-easymotion'
Plug 'scrooloose/nerdtree'
Plug 'christoomey/vim-tmux-navigator'
call plug#end()
colorscheme gruvbox
let g:gruvbox_contrast_dark = "hard"
let mapleader=" "
let NERDTreeQuitOnOpen=1
nmap <Leader>s <Plug>(easymotion-s2)
nmap <Leader>nt :NERDTreeFind<CR>

When I'm using vim-tmux-tavigator without tmux all work properly, but when I used in a tmux session the C-h doesn't work. I think it's a mistake in the tmux configuration but I can't find it.

Thank you very much!

christoomey commented 3 years ago

A few questions to help debug:

javijjavi commented 3 years ago

Hi Chris,

First of all, thank you for your help.

Exactly if I execute Prefix + h in tmux I can change between panels, but when I'm use that in vim-tmux-navigator inside a tmux session that doesn't it seen like C-h works as backward. The rest of the commands works properly.

If I execute bindkey "^H" I get: "^H" backward-delete-char

I dont know if this can help.

Thank you very much for your help, I'm triying a lot of different things but I dont know what it can be, because out of a tmux session all works fine.

christoomey commented 3 years ago

Unfortunately, nothing in your response stands out as odd, so I'm not sure where to go. Just to confirm, did you read back through any of the other related issues (searching for C-h in the issues)? I know this has been a sticking point, and there may be some tips in there. Specifically, I've seen things around neovim vs vim, the TERM setting, etc. Sorry I can't provide much more here.

javijjavi commented 3 years ago

Thank you, Christ,

Yes, I have been watching the other issues and trying all things, like the TERM. But nothing works. I'm going to continue trying, if I find the solution I will put it in this issue.

Thanks for your help Christ and for the amazing project 👍

xq-chia commented 3 years ago

solution found at tmux/tmux#1838