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

feat: add zellij support #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions autoload/tpipeline.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,28 @@ 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-vimbridge
let p = "/tmp/zjstatus-" . systemlist("id -u")[-1]
silent! call mkdir(p)
let tmux = p . "/default,0,0"
let session = $ZELLIJ_SESSION_NAME
let p = p . "/"
let zellij = p . session . "-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()
Expand Down Expand Up @@ -169,6 +183,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]
Expand Down
7 changes: 6 additions & 1 deletion autoload/tpipeline/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the correct size as soon as there is a vertical split in zellij. This can also be done by just setting the TpipelineSize autocommand callback, so no code changes needed here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried without, then the STL would be rendered without markers - meaning that the whole line would be rendered on the left side. Currently, zellij has no API to get the width. We probably have to wait.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also: I don't fully understand the case you tried to describe. In my setup, the bar always takes the full width of the terminal. When I do a split, my editor's width halves but the bar stays in full width and so can the STL.

Copy link
Owner

@vimpostor vimpostor Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tput cols will evaluate to the split's width, not to the full width. You likely didn't notice a difference, because half the width was still enough width.

Try resizing the terminal so that it's width is barely enough to fit the vim statusline. Then split the terminal, and you should notice that the statusline is truncated to half the terminal's width.

let g:tpipeline_size = str2nr(systemlist("sh -c 'tput cols'")[-1])
endif
endfunc

func tpipeline#util#set_custom_size()
Expand Down