-
Notifications
You must be signed in to change notification settings - Fork 342
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
[WIP] Use tmux variable to indicate running Vim #201
Conversation
@blueyed can you clarify the problem(s) that this is solving, and or new functionality this would bring in? I'm extremely cautious about adding to or altering the process matching code as it is already very complicated and somewhat unwieldy, and I want to better understand what these changes might gain us in order to review more completely. |
@christoomey |
@blueyed This change is awesome - completely eliminates the lag present with the previous One caveat is that this only works for me on tmux 2.7 - it doesn't detect that it's in vim on tmux 2.5 (which has a nicer choose-window interface IMO). I'm not sure if there's something new in 2.6 or 2.7 that you need to do the detection, but it's at least worth mentioning in the README. |
Also, I needed to add
to the top of the vim plugin to allow using neovim outside of tmux. |
@apazzolini As for the |
@apazzolini |
btw: is it a valid use case that |
I think that ideally it should setup the default mappings if you're not running inside of tmux - that's almost certainly what the majority of people would want. I have the mappings set in my vimrc by default since I also use it on remote servers where I'm not running tmux. |
Ok, see #203. |
The feature that requires tmux 2.6 is the pattern matching using bind-key h if-shell 't="#{@tmux_navigator}"; [ "${t##*-#{pane_id}-}" != "$t" ]' 'send-keys C-h' 'select-pane -L' |
@blueyed I'm running the |
@sajoku Rebased it on master now, fixing the conflict due to d030f75. I am using this in
This should work with older tmux then, too. |
Indicator branch also fixed all my problems. Thanks! |
Previously we used the `{pane_current_command}` tmux variable and matched against that, but a while back we switched to using the process list to better handle some edge cases. Overall that change has been a win, but the documentation has lagged a bit around the debugging command `:TmuxPaneCurrentCommand` which is no longer relevant. This change replaces `:TmuxPaneCurrentCommand` with a new `:TmuxNavigatorProcessList` which should allow us to debug the actual issue related to the `ps` command.
@blueyed Regarding your comment on the issue I opened: I'm using the default Ctrl-h,i,j,k (no prefix) for Vim/NeoVim and Tmux both. I ran |
That means the binding from this PR here are either not installed, or Vim wasn't started in any pane yet - this custom options/var gets used to communicate with tmux about in which panes this plugin is running. |
@blueyed I do have a bug, or what I think is a bug. Open a split in tmux (numbers are the splits). Extra: Are you able to reproduce this? |
- use a list instead of single string - add s:GetTmuxCommand to be used later when not using `system()` only - remove `:silent` when calling tmux from `s:TmuxAwareNavigate`: it should not be necessary and is bad practice to use `:silent` unnecessarily. It was added in b068a04 with no explanation.
This uses @tmux_navigator to hold a list of tmux panes when vim-tmux-navigator is running. It uses VimSuspend/VimResume (available on Neovim) to remove itself when it is suspended (`Ctrl-z`). (It could easily get extended to detect if vim-tmux-navigator is not responding (e.g. when a more-prompt is active), but that would involve an additional (async) command every time vim-tmux-navigator is used.)
@sajoku |
Just moved from vim to nvim and found using this branch (as well as the suggested tmux changes within the updated documentation on the branch) was required to re-enable my Ctrl-h/j/k/l movements in Neovim again. Thought I managed to recreate @sajoku's bug (using vim) initially, but tried 20 more times and couldn't reproduce it again, so a little unsure how I managed it and if it's a "real" bug, or just a hiccup from changing and reloading tmux / vim configuration whilst within those tools. |
Thanks for this PR. I came here from #208. However, on the current indicator branch commit afef84a, with vim (not neovim) on windows/cygwin, simply opening and closing vim leaves Here's a quick hack I made to escape the empty string. Not sure whether this is robust (i.e., do any functions need to use fnameescape() if that's no longer done in TmuxCommand()). diff --git a/plugin/tmux_navigator.vim b/plugin/tmux_navigator.vim
index 5445bfe..c7a9005 100644
--- a/plugin/tmux_navigator.vim
+++ b/plugin/tmux_navigator.vim
@@ -73 +73 @@ else
- let cmd = join(map(s:GetTmuxCommand(a:args), 'fnameescape(v:val)'))
+ let cmd = join(s:GetTmuxCommand(a:args))
@@ -156,0 +157,4 @@ function! s:remove_indicator() abort
+ if !has('nvim')
+ " Shellescape new string, in case it's empty
+ let new = shellescape(new)
+ endif |
Unhmm took me 2 hours to figure out this is another branch ... |
Its a bit hard to find witch pane is active. Can the active pane border flash for a second or some other method to see witch plane is active? |
That would be a new feature request. I'll close this PR - I am not using this plugin anymore myself (too much magic - I rather prefer to distinguish between Vim and tmux explicitly). |
This uses @tmux_navigator to hold a list of tmux panes when
vim-tmux-navigator is running.
It uses VimSuspend/VimResume (available on Neovim) to remove itself when
it is suspended (
Ctrl-z
).(It could easily get extended to detect if vim-tmux-navigator is not
responding (e.g. when a more-prompt is active), but that would involve
an additional (async) command every time vim-tmux-navigator is used.)
Includes #200.
TODO: