-
Notifications
You must be signed in to change notification settings - Fork 22
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
Does not work when running Vim in a Poetry shell #13
Comments
This thread is relevant, but I didn't find a satisfactory solution: christoomey/vim-tmux-navigator#230 |
Here is a workaround involving checking for a poetry environment. It's a little weird because the tty does not show up with # add a check for the poetry env
is_poetry="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE 'Frameworks\/Python.framework'"
# all other lines in tmux config remain the same, but change the "bind-key" lines to:
bind -n C-h run "($is_vim && tmux send-keys C-h) || ($is_poetry && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "($is_vim && tmux send-keys C-j) || ($is_poetry && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "($is_vim && tmux send-keys C-k) || ($is_poetry && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "($is_vim && tmux send-keys C-l) || ($is_poetry && tmux send-keys C-l) || tmux select-pane -R"
bind-key -n 'C-\\' if-shell "$is_vim" 'send-keys C-\\\\' 'select-pane -l' |
Edit: nevermind, still broken |
Hey, Thanks for reporting the issue! I am aware that some of the functionality of the plugin is broken inside python* shells/environments. It's always Python that's broken, am I right.. My long term idea was to completely change how the plugin detects vim/neovim and tmux, since we cannot always determine them reliably with the current solution. However, due to life issues, I am currently unable to look into it. I will be able to do so in about 1 to 2 months. I cannot provide a workaround solution for now, since I don't use any of the tools, however I will keep the thread open, and perhaps someone else would be able to find a fix. In the meantime, please keep posting if you do find new information that could be helpful for a future fix. Regards |
The workaround works for me, thanks @gegnew! Would love to see a fix still. |
The problem I have is that, although I can detect the Poetry environment, it cannot detect vim in a pane if it's in the Poetry environment. The If anyone has any ideas, I'm all 👂 |
So, I've been coming back to this issue on and off for a while now and found how to get things working right with For
I found the same experience with
I've been trying to find a way to extract all the children but it gets cumbersome pretty quickly. Pipenv offers a flag on the shell to command
When running in this mode, it does not start a new process in a new tty and only seems to modify the environment variables. |
Just wanted to chime in here with another workaround. I've found trying to modify the I also tried this workaround but found it to be a bit slow because it needs multiple shell commands to first see if we're inside poetry, then to get its child processes to see if we're inside vim as well. I'm not an expert and I'm working on personal projects so perhaps there are problems with this approach I'm not aware of in larger or professional settings, but afaict |
One workaround is to activate the poetry virtual env in the current shell instead of of using In bash you can run this command: https://python-poetry.org/docs/basic-usage#activating-the-virtual-environment |
I've been trying to find a solution for this for a long time. I generally don't use As described by akail, While it's possible to find the I've found a way that is rather naive and may not work for everybody, but it works for me just fine and I find it practically as fast as the default solution with just one I use the user options feature of get_next_tty() {
pts_array=($(ls /dev/pts | \grep -E "^[0-9]+$"))
for ((i=0; i<${#pts_array[@]}; i++)); do
if [ $i -ne ${pts_array[i]} ]; then
break
fi
done
echo /dev/pts/$i
}
alias psh="[ ! $POETRY_ACTIVE ] && (tmux set -p @active_tty \$(get_next_tty) &>/dev/null; poetry shell && tmux set -pu @active_tty &>/dev/null)" EDIT: I've added the I can then start a In my is_vim="ps -o state= -o comm= -t '#{?#{@active_tty},#{@active_tty},#{pane_tty}}' \
| grep -iqE '^([^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?)$'" |
This works, ty |
nvim-tmux-navigation
doesn't work at all if the neovim session is run afterpoetry shell
. Would appreciate help debugging, if possible.:checkhealth
outside of poetry shell:and inside poetry shell, the same except for a virtualenv error:
The text was updated successfully, but these errors were encountered: