From 6874641f5f34eebbe10d62233530fd2fa13ff9c3 Mon Sep 17 00:00:00 2001 From: Maxim Onciul Date: Mon, 25 Mar 2024 08:12:54 +0100 Subject: [PATCH 1/2] feat: add zellij support Very rudimentary, draft to support zellij. --- autoload/tpipeline.vim | 32 ++++++++++++++++++++++++++------ autoload/tpipeline/util.vim | 7 ++++++- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/autoload/tpipeline.vim b/autoload/tpipeline.vim index b2dc8d0..e69c539 100644 --- a/autoload/tpipeline.vim +++ b/autoload/tpipeline.vim @@ -5,14 +5,33 @@ endif let s:exit_code = -1 func tpipeline#get_filepath() - " e.g. /tmp/tmux-1000/default-$0-vimbridge - let tmux = $TMUX - if empty(tmux) - let p = "/tmp/tmux-" . systemlist("id -u")[-1] + + if !empty($ZELLIJ) + " e.g. /tmp/zjstatus-$UID/$SESSION_NAME-$PANE_ID-vimbridge + let p = "/tmp/zjstatus-" . systemlist("id -u")[-1] silent! call mkdir(p) - let tmux = p . "/default,0,0" + let session = $ZELLIJ_SESSION_NAME + " TODO: wait for https://github.com/zellij-org/zellij/issues/2835 + " so we can identify the currently active pane. Now I have to hardcode it + " to zjstatus - so no reason to use the variable here, yet. + " let paneid = $ZELLIJ_PANE_ID + let paneid = "0" + let p = p . "/" + let zellij = p . session . "-" . paneid . "-vimbridge" + return zellij + endif + + + if !empty($TMUX) + " e.g. /tmp/tmux-1000/default-$0-vimbridge + let tmux = $TMUX + if empty(tmux) + let p = "/tmp/tmux-" . systemlist("id -u")[-1] + silent! call mkdir(p) + let tmux = p . "/default,0,0" + endif + return strcharpart(tmux, 0, stridx(tmux, ",")) . '-$' . strcharpart(tmux, strridx(tmux, ",") + 1) . '-vimbridge' endif - return strcharpart(tmux, 0, stridx(tmux, ",")) . '-$' . strcharpart(tmux, strridx(tmux, ",") + 1) . '-vimbridge' endfunc func tpipeline#build_hooks() @@ -169,6 +188,7 @@ func tpipeline#exit_cb(job, code) endfunc func tpipeline#fork_job() + " TODO: for ZELLIJ, only do what is necessary if g:tpipeline_restore let s:restore_left = systemlist("sh -c 'echo \"\"; tmux display-message -p \"#{status-left}\"'")[-1] let s:restore_right = systemlist("sh -c 'echo \"\"; tmux display-message -p \"#{status-right}\"'")[-1] diff --git a/autoload/tpipeline/util.vim b/autoload/tpipeline/util.vim index 6e58c3e..b158272 100644 --- a/autoload/tpipeline/util.vim +++ b/autoload/tpipeline/util.vim @@ -12,7 +12,12 @@ func tpipeline#util#left_justify(str) endfunc func tpipeline#util#set_size() - let g:tpipeline_size = str2nr(systemlist("sh -c 'echo \"\"; tmux display-message -p \"#{window_width}\"'")[-1]) + if !empty($TMUX) + let g:tpipeline_size = str2nr(systemlist("sh -c 'echo \"\"; tmux display-message -p \"#{window_width}\"'")[-1]) + elseif !empty($ZELLIJ) + " TODO: verify if this is reasonable. + let g:tpipeline_size = str2nr(systemlist("sh -c 'tput cols'")[-1]) + endif endfunc func tpipeline#util#set_custom_size() From 6b935bfb2c83c951e89227942d79e57011ebe3d6 Mon Sep 17 00:00:00 2001 From: Maxim Onciul Date: Fri, 5 Jul 2024 11:47:00 +0200 Subject: [PATCH 2/2] fix: remove pane_id --- autoload/tpipeline.vim | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/autoload/tpipeline.vim b/autoload/tpipeline.vim index e69c539..9a17dae 100644 --- a/autoload/tpipeline.vim +++ b/autoload/tpipeline.vim @@ -7,17 +7,12 @@ let s:exit_code = -1 func tpipeline#get_filepath() if !empty($ZELLIJ) - " e.g. /tmp/zjstatus-$UID/$SESSION_NAME-$PANE_ID-vimbridge + " e.g. /tmp/zjstatus-$UID/$SESSION_NAME-vimbridge let p = "/tmp/zjstatus-" . systemlist("id -u")[-1] silent! call mkdir(p) let session = $ZELLIJ_SESSION_NAME - " TODO: wait for https://github.com/zellij-org/zellij/issues/2835 - " so we can identify the currently active pane. Now I have to hardcode it - " to zjstatus - so no reason to use the variable here, yet. - " let paneid = $ZELLIJ_PANE_ID - let paneid = "0" let p = p . "/" - let zellij = p . session . "-" . paneid . "-vimbridge" + let zellij = p . session . "-vimbridge" return zellij endif