vimpostor / vim-tpipeline

Embed your vim statusline in tmux
GNU General Public License v3.0
369 stars 11 forks source link

Purpose of `tpipeline_autoembed`? #48

Closed guruor closed 1 year ago

guruor commented 1 year ago

Not an issue, apologies for spamming the issue section, I didn't find any discussion section for the repo.

What am I trying to achieve?

I was trying to skip auto embed by default on plugin load. I need some manual control to attach the vim statusline with tmux only when given flag is true.

What I tried?

I came across tpipeline_autoembed flag, my understanding it that when this flag is enabled then only statusline will be merged with tmux status.

Problem

I couldn't see any difference when tpipeline_autoembed flag is enabled or disabled, in both the cases vim statusline was getting merged with tmux.

vimpostor commented 1 year ago

For me using let g:tpipeline_autoembed = 0 works.

I believe it will work for you too, if you additionally restart tmux. I think in your case the tmux status-left option has a stale value from a time where you started vim with g:tpipeline_autoembed = 1. You can prevent a stale status-left option from ever happening by setting let g:tpipeline_restore = 1. However, for most people setting this option usually is not needed, because it doesn't make a difference in most usecases.

guruor commented 1 year ago

I even tried restarting the tmux. It didn't help. Is there any way I can clear the stale value of status-left?

On a side note, shouldn't we initialise and check for tpipeline_autoembed flag even before plugin initialisation here: https://github.com/vimpostor/vim-tpipeline/blob/master/plugin/tpipeline.vim#L6

As a workaround I am currently having a separate flag named tpipeline_embed_enabled in my local copy and shortcutting the plugin initialisation process when the flag is not set.

vimpostor commented 1 year ago

I even tried restarting the tmux. It didn't help. Is there any way I can clear the stale value of status-left?

It should work, make sure that all tmux sessions have exited, tmux clears some variables only if the entire tmux server shuts down. If that still doesn't help, try sending me your config, because I can't reproduce it with a minimal config.

On a side note, shouldn't we initialise and check for tpipeline_autoembed flag even before plugin initialisation here: https://github.com/vimpostor/vim-tpipeline/blob/master/plugin/tpipeline.vim#L6

No that would disable the plugin entirely. The flag only means that the user will have to set the tmux options manually, everything else should still work.

guruor commented 1 year ago

I closed all the terminals running tmux and then killed the tmux process itself using killall tmux command.

My config can be found here: Neovim config using tpipeline: link Tmux config: link

Ignore the call to vim.fn['tpipeline#state#reload'](), I am not even doing that on local.

vimpostor commented 1 year ago

I tried your config and can't reproduce the problem. With let g:tpipeline_autoembed = 0 the statusline is not embedded automatically in the tmux statusline.

But if you want to conditionally disable the plugin, g:tpipeline_autoembed isn't the correct variable anyway as it only controls the automatic embed progress, the plugin will still be enabled with that flag.

Where are you setting this flag exactly and what is your exact usecase?

guruor commented 1 year ago

@vimpostor I want to not embed the statusline by default, I want it to be controlled by some mapping. Currently I am not able to prevent the autoembed, though I am able to toggle the statusline embedding using vim.call('tpipeline#state#toggle') function with a mapping, Check toggle function here

This function changes the laststatus as well along with toggling the embedding.

vimpostor commented 1 year ago

Yeah, for your usecase g:tpipeline_autoembed is not the right option. You could either set let g:loaded_tpipeline = 1 to disable the plugin from autostarting and then manually call call tpipeline#initialize() the first time you want to activate it, or you could use au VimEnter * call tpipeline#state#restore() to disable the plugin on startup.

vimpostor commented 1 year ago

Closing because the question has been answered.