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

Navigating vim splits doesn't work properly. #317

Open
Zerophase opened this issue Jun 7, 2022 · 28 comments
Open

Navigating vim splits doesn't work properly. #317

Zerophase opened this issue Jun 7, 2022 · 28 comments

Comments

@Zerophase
Copy link

How to reproduce.

  1. Have two tmux panes split vertically.
  2. Open vim on the right pane
  3. split vim with vsplit
  4. Switch to the left tmux pane with ctrl-h.
  5. Press ctrl-h again

You'll switch to the last active vim split, instead of wrapping around to the split furthest to the right.

@dattran1232003
Copy link

Same here

@azinsharaf
Copy link

same here. It moves between tmux panes. It also moves from tmux pane to neovim pane and visa versa. But it doesn't move between neovim panes itself.

@christoomey
Copy link
Owner

Hey folks, could you run through the troubleshooting list, notably the TmuxNavigatorProcessList bit? I'm wondering if something may be up with neovim in recent versions (see #324 for a potentially related issue).

@azinsharaf
Copy link

:TmuxNavigatorProcessList is not an option in my neovim setup.

image

@christoomey
Copy link
Owner

Hmm, are you perhaps on a very old version of the vim plugin? :TmuxNavigatorProcessList was added in mid 2018, so possible you're version predates that @azinsharaf?

@azinsharaf
Copy link

I doubt it since i installed it recently. How can I check its version?

@christoomey
Copy link
Owner

Definitely odd then. Can you try running :TmuxNavigatorProcessList directly? Your screenshot is showing tab completion and I'm wondering if the prefix :TmuxNavigate... vs TmuxNavigator... being different might explain why you're not seeing it.

Alternatively you could track down where your vim plugins are installed and look at the contents of the file itself to see if it matches what's on github right now.

@azinsharaf
Copy link

:TmuxNavigatorProcessList is not an editor command. I am wondering how it works for @Zerophase and @dattran1232003.

@azinsharaf
Copy link

@christoomey i am using Neovim v0.8.0. Does the plugin support neovim?

@christoomey
Copy link
Owner

The plugin is definitely intended to support Neovim. I'm surprised to see that it's not working. Can you track down the installed version of the plugin on your machine and confirm if it matches the version on Github? Specifically this line is the one that defines the command in question.

@azinsharaf
Copy link

I re-installed it and have the same issue. Confirming that i am using the latest version.
This is a gif file about how it looks like:

neovim

@christoomey
Copy link
Owner

Yup, I can definitely see what you're reporting. Unfortunately not much more for me to go from in the gif.

Can you track down the installed version of the plugin code on your machine and confirm if it matches the version on Github? Specifically this line is the one that defines the command in question.

@lambda0xff
Copy link

Exact same issue here.

TmuxNavigatorProcessList gives: Ss+ /bin/zsh (figterm)

@lambda0xff
Copy link

Probably same issue a #295 ?

Copy-Paste fix that works for me:
In .tmux.conf, replace is_vim with:

is_vim="children=(); i=0; pids=( $(ps -o pid= -t '#{pane_tty}') ); \
while read -r c p; do [[ -n c && c -ne p && p -ne 0 ]] && children[p]+=\" $\{c\}\"; done <<< \"$(ps -Ao pid=,ppid=)\"; \
while (( $\{#pids[@]\} > i )); do pid=$\{pids[i++]\}; pids+=( $\{children[pid]-\} ); done; \
ps -o state=,comm= -p \"$\{pids[@]\}\" | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

ps: this works, but seems to have some impact on performance

@geralfonso
Copy link

Exact same issue here.

TmuxNavigatorProcessList gives: Ss+ /bin/zsh (figterm)

I had the same issue but in my case, it was caused by https://fig.io/. I uninstalled it and now it's working as expected.

@popoffvg
Copy link

popoffvg commented Nov 30, 2022

I fixed the issue using this tip

Added lines in .tmux.conf

# smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"

@azinsharaf
Copy link

didn't work for me. Interested to see how it works for others.

@johnoshea
Copy link

Are you running a poetry shell by any chance? I see the same problem (navigating inside Neovim doesn't work, but does between Neovim and tmux) but only if I've run poetry shell before starting Neovim.

FWIW, the output of :TmuxNavigatorProcessList with a poetry shell running:

Ss   -zsh
S    -zsh
S    /Users/johno/.cache/gitstatus/gitstatusd-darwin-arm64
S+   /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python

and without poetry shell running:

Last login: Fri Nov 25 22:42:57 on ttys000
Ss   -zsh
S    -zsh
S    /Users/johno/.cache/gitstatus/gitstatusd-darwin-arm64
S+   nvim

@sspaeti
Copy link

sspaeti commented Dec 8, 2022

I can confirm I used it for a while without any problem. As soon as I run poetry shell, I can't switch inside neovim anymore, only between tmux windows. I can create a new window again and without poetry, it works again.

TmuxNavigatorProcessList when it does not work any longer :(

Ss   -zsh
S    -zsh
S    -zsh
S    -zsh
S    /Users/sspaeti/.cache/gitstatus/gitstatusd-darwin-arm64
S+   /opt/homebrew/Cellar/python@3.11/3.11.0/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python

Anything I can workaround this?

Found the same error mentioned in #230 (comment). The workaround seems to much for me though, but also didn't work. I'm using Python with venvs all the time without problems, I'm not sure why poetry behaves differently here.

@johnoshea
Copy link

In my case, it looks like I've got $SHELL pointing at the OS-default zsh (/bin/zsh) which isn't the zsh I'm actually using (Homebrew-installed, /opt/homebrew/bin/zsh). Here's some heavily trimmed output showing my normal zsh (top half) and the zsh run by poetry (bottom half):

❯ ps
  PID TTY           TIME CMD
...
 1154 ttys000    0:00.01 tmux -f /Users/johno/.tmux.conf attach
 1372 ttys001    0:21.85 -zsh
...
 
87818 ttys007    0:00.47 /bin/zsh -i

Setting $SHELL to either just zsh on its own, or the full path to the Homebrew zsh seems to have resolved this, though I've only tested this for 10 minutes or so.

@sspaeti
Copy link

sspaeti commented Dec 9, 2022

@johnoshea Wow, that is a big one; thanks for that, I never noticed this! It did not work for me :( But I added the export SHELL=zsh to my .zshrc anyway, as I guess that should be more correct, although I hadn't had any problem otherwise.

My workaround, for now, is that I have alternative moving shortcuts for vim that I can use in case I bump into that problem with:

"Move window
noremap sh <C-w>h
noremap sk <C-w>k
noremap sj <C-w>j
noremap sl <C-w>l

@juliangoetze
Copy link

Exact same issue here.
TmuxNavigatorProcessList gives: Ss+ /bin/zsh (figterm)

I had the same issue but in my case, it was caused by https://fig.io/. I uninstalled it and now it's working as expected.

I had the same problem with https://fig.io/ and uninstalling fig worked for me too. I guess this issue is worth searching for a solution, because I neither want to dispense with fig nor the vim-tmux-navigation... I will open up an issue on that one

conradbeach added a commit to conradbeach/dotfiles that referenced this issue Jan 20, 2023
This reverts commit 7ffe1f2.

I'm removing Fig because it caused issues with vim-tmux-runner [1] [2] [3].
The founders of Fig are trying to work with Chris Toomey to find a
solution though [3], so I could get it working if I really wanted to I bet.

For now, I'm just going to remove Fig; vim and tmux navigation is
more important.

The thing that attracted me to Fig was the command line autocomplete, but
I'm not sure that's worth the cost. Fig does a lot more than I actually
want it to, and it seems to be a fairly complex tool. Dealing with it doesn't
seem worth the value it would create for me. I'll pass.

[1]: christoomey/vim-tmux-navigator#339
[2]: christoomey/vim-tmux-navigator#317
[3]: christoomey/vim-tmux-navigator#295
conradbeach added a commit to conradbeach/dotfiles that referenced this issue Jan 20, 2023
This reverts commit f306816.

I'm removing Fig because it caused issues with vim-tmux-runner [1] [2] [3].
The founders of Fig are trying to work with Chris Toomey to find a
solution though [3], so I could get it working if I really wanted to I bet.

For now, I'm just going to remove Fig; vim and tmux navigation is
more important.

The thing that attracted me to Fig was the command line autocomplete, but
I'm not sure that's worth the cost. Fig does a lot more than I actually
want it to, and it seems to be a fairly complex tool. Dealing with it doesn't
seem worth the value it would create for me. I'll pass.

[1]: christoomey/vim-tmux-navigator#339
[2]: christoomey/vim-tmux-navigator#317
[3]: christoomey/vim-tmux-navigator#295
@tcrundall
Copy link

I feel like @Zerophase 's issue is different to all the subsequent replies, and it's their issue I'm currently facing. Though after looking into both the vim plugin and the tmux binding implementations, I believe what Zerophase and I both want to happen simply isn't part of tmux-vim-navigator's intended behaviour.

When switching from a tmux pane without vim into a tmux pane with vim (i.e. a tmux-vim-pane), if the tmux-vim-pane has multiple vim panes itself, I'd like to switch into the closest of those vim-panes (if this is confusingly described, Zerophase's original comment already gives a simple case example).

So far as I understand, it is the intended behaviour that: when switching into a tmux-vim-pane, the vim-pane that will be selected will be whichever one was last active when this tmux-vim-pane was last active. And therefore not necessarily the vim-pane adjacent to the tmux-pane I just left.

If this is true, please confirm and perhaps update the readme to reflect this.

@nazariyv
Copy link

Just reporting that poetry shell is causing problems for me as well. When I have nvim tree on the very left and some code next to it, with a vertical split, keybindings to move between tmux and nvim will only work in one of the following ways:

1/ if I were focused on nvim-tree, then keybinding will take me to tmux. Then again to nvim-tree
2/ if I were focused on code, then keybinding will take me to tmux. Then again to code

The above happens if poetry shell before starting nvim.

If I do not poetry shell, I can move correctly from nvim-tree to code to tmux and back.

Curious fact, if executing :TmuxNavigateLeft directly (or another navigation command), it all works well.

@nazariyv
Copy link

Just reporting that poetry shell is causing problems for me as well. When I have nvim tree on the very left and some code next to it, with a vertical split, keybindings to move between tmux and nvim will only work in one of the following ways:

1/ if I were focused on nvim-tree, then keybinding will take me to tmux. Then again to nvim-tree 2/ if I were focused on code, then keybinding will take me to tmux. Then again to code

The above happens if poetry shell before starting nvim.

If I do not poetry shell, I can move correctly from nvim-tree to code to tmux and back.

Curious fact, if executing :TmuxNavigateLeft directly (or another navigation command), it all works well.

#230 (comment)

poetry run nvim seems to fix this issue

@miklhh
Copy link

miklhh commented Feb 10, 2024

I also start to feel like @Zerophase's original issue isn't being addressed here anymore. I'm curious if there is going effort in trying to add the original feature (if possible at all). I also feel like, whether it is possible to or not, that the issue at hand should be addressed somewhere. Possibly in the vim-tmux-navigator README.

I would love @christoomey's thoughts on the original issue as well.

@unkindypie
Copy link

I have the same issue when running vim from poetry

@anousonefs
Copy link

same here on mac m3

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

No branches or pull requests