From d703cb7a6d76d5319fc520b0314eed482dbebd62 Mon Sep 17 00:00:00 2001 From: Vivek Myers Date: Wed, 16 Oct 2024 15:30:22 -0700 Subject: [PATCH 1/2] Fix tmux pane detection and rename imgcat backend to avoid conflicts with existing installation --- autoload/jukit/splits.vim | 4 ++-- helpers/{imgcat => imgcat_jukit}/LICENSE.txt | 0 helpers/{imgcat => imgcat_jukit}/__init__.py | 4 +++- helpers/{imgcat => imgcat_jukit}/imgcat.py | 0 4 files changed, 5 insertions(+), 3 deletions(-) rename helpers/{imgcat => imgcat_jukit}/LICENSE.txt (100%) rename helpers/{imgcat => imgcat_jukit}/__init__.py (94%) rename helpers/{imgcat => imgcat_jukit}/imgcat.py (100%) diff --git a/autoload/jukit/splits.vim b/autoload/jukit/splits.vim index b1c3a9d..8f4a87b 100644 --- a/autoload/jukit/splits.vim +++ b/autoload/jukit/splits.vim @@ -215,14 +215,14 @@ fun! jukit#splits#_build_shell_cmd(...) abort \. 'matplotlib.use("module://matplotlib-backend-kitty");' \. 'plt.show.__annotations__["save_dpi"] = ' . g:jukit_savefig_dpi . ";" elseif g:jukit_terminal == 'tmux' - let current_pane = matchstr(system('tmux run "echo #{pane_id}"'), '%\d*') + let current_pane = $TMUX_PANE if is_outhist let target_pane = g:jukit_outhist_title else let target_pane = g:jukit_output_title endif let cmd = cmd - \. 'matplotlib.use("module://imgcat");' + \. 'matplotlib.use("module://imgcat_jukit");' \. 'plt.show.__annotations__["tmux_panes"] = ["' \. current_pane . '", "' . target_pane . '"];' \. 'plt.show.__annotations__["save_dpi"] = ' . g:jukit_savefig_dpi . ";" diff --git a/helpers/imgcat/LICENSE.txt b/helpers/imgcat_jukit/LICENSE.txt similarity index 100% rename from helpers/imgcat/LICENSE.txt rename to helpers/imgcat_jukit/LICENSE.txt diff --git a/helpers/imgcat/__init__.py b/helpers/imgcat_jukit/__init__.py similarity index 94% rename from helpers/imgcat/__init__.py rename to helpers/imgcat_jukit/__init__.py index 6d1cac5..c61cbac 100644 --- a/helpers/imgcat/__init__.py +++ b/helpers/imgcat_jukit/__init__.py @@ -1,7 +1,7 @@ import codecs, io, sys from matplotlib._pylab_helpers import Gcf from matplotlib.figure import Figure -from matplotlib.backend_bases import FigureManagerBase +from matplotlib.backend_bases import FigureManagerBase, FigureCanvasBase import matplotlib.pyplot as plt from .imgcat import imgcat @@ -39,6 +39,8 @@ def show(self): else: imgcat(self.canvas.figure) +class FigureCanvas(FigureCanvasBase): + pass def show(block=None): for manager in Gcf.get_all_fig_managers(): diff --git a/helpers/imgcat/imgcat.py b/helpers/imgcat_jukit/imgcat.py similarity index 100% rename from helpers/imgcat/imgcat.py rename to helpers/imgcat_jukit/imgcat.py From d5534a9c5f2bb8716f955d4e3fe33e174a2beb56 Mon Sep 17 00:00:00 2001 From: Vivek Myers Date: Wed, 16 Oct 2024 23:53:49 -0700 Subject: [PATCH 2/2] Update get_pane_by_name to use $TMUX_PANE instead of tmux command to avoid extra /%\d+/ printouts --- autoload/jukit/tmux/layouts.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/jukit/tmux/layouts.vim b/autoload/jukit/tmux/layouts.vim index a7d115b..85a89d1 100644 --- a/autoload/jukit/tmux/layouts.vim +++ b/autoload/jukit/tmux/layouts.vim @@ -1,6 +1,7 @@ fun! s:get_pane_by_name(name, output_exists, outhist_exists) abort if a:name == 'file_content' - let current_pane = matchstr(system('tmux run "echo #{pane_id}"'), '%\d*') + " let current_pane = matchstr(system('tmux run "echo #{pane_id}"'), '%\d*') + let current_pane = $TMUX_PANE return current_pane elseif a:name == 'output' && a:output_exists return g:jukit_output_title