dhruvasagar / vim-zoom

Toggle zoom in / out individual windows (splits)
239 stars 15 forks source link

suggestion: zoom status #4

Closed damnskippy closed 5 years ago

damnskippy commented 5 years ago

Is there a way to know whether one is currently zoomed in or not. If not it would be nice to add a flag or an API that could be queried to see the status. Often it's not unreasonable to zoom in on a window, switch out to some other task and then come back to vim a while later, and in such cases would be nice to remind/indicate the current zoom status. Would just need to expose the t:zoomed through an API. Thanks.

dhruvasagar commented 5 years ago

There's a tab local variable t:zoomed that indicates whether it is currently zoomed (value 1) or not (value 0).

EDIT: Ideally you can show this in the status line, what would you expect such an API to do ?

damnskippy commented 5 years ago

Yes display it in the statusline. I believe t:zoomed is not loaded until zoom operation/toggle is invoked. So it will be an undefined variable to start with.

damnskippy commented 5 years ago

No different from tmux pane zoom and the tmux's zoom status flag. Thanks.

damnskippy commented 5 years ago

Thanks.

dhruvasagar commented 5 years ago

I have added a new API zoom#statusline(), you can add it to your statusline with something like this :

set statusline+=%{zoom#statusline()}

It spits out the string 'zoomed' if we're zoomed currently and blank if not.

damnskippy commented 5 years ago

Yes, I pulled this in immediately - thanks again.

BTW, probably an edge case. Open vim, single window (no splits), hit C-w m. Vim will rightfully say "Already only one window". zoom#statusline() should probably not say zoomed in this case i.e s:is_zoomed() probably shouldn't think we're zoomed() if there's only one window.

dhruvasagar commented 5 years ago

That would be a question for vim-zoom, whether we should invoke zoom or skip it in case there is just 1 window / split. The statusline is only displaying the zoom status so that's doing it's job correctly.

damnskippy commented 5 years ago

Indeed - question for vim-zoom.

dhruvasagar commented 5 years ago

I think it's a fair point that we should just not do anything in case we're already the only split in the current tab and vim-zoom is invoked, i'll make the changes appropriately.

damnskippy commented 5 years ago

Thank you.

NeilsC commented 5 years ago

Great plugin :+1:

When I add this to my .vimrc: set statusline+=${zoom#statusline()}

I get a statusline that literally says "${zoom#statusline()}". I know this is an issue on my side but I'm wondering if anyone here might point me in the right direction.

dhruvasagar commented 5 years ago

@NeilsC sry there's a typo in the README, i'll fix it, it should be : set statusline+=%{zoom#statusline()}

NeilsC commented 5 years ago

@dhruvasagar That did the trick, thanks!

ovidius72 commented 5 years ago

Hi, is there a way to add it to vim-airline ?

dhruvasagar commented 5 years ago

@ovidius72 You'll need to refer to vim-airline help for that, :h airline-advanced-customizations specifically may be what you need to use.

savchenko commented 4 years ago

@ovidius72 ,

function! AirlineInit()
    let g:airline_section_z = airline#section#create('%#__accent_bold#%{zoom#statusline()}%3l%#__restore__#/%L :%3v')
endfunction
autocmd User AirlineAfterInit call AirlineInit()