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

suggestion: zoom status #4

Closed
damnskippy opened this issue Jan 7, 2019 · 16 comments
Closed

suggestion: zoom status #4

damnskippy opened this issue Jan 7, 2019 · 16 comments

Comments

@damnskippy
Copy link

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
Copy link
Owner

dhruvasagar commented Jan 7, 2019

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
Copy link
Author

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
Copy link
Author

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

@damnskippy
Copy link
Author

Thanks.

@dhruvasagar
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

Indeed - question for vim-zoom.

@dhruvasagar
Copy link
Owner

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
Copy link
Author

Thank you.

dhruvasagar added a commit that referenced this issue Jan 7, 2019
Skip if trying to zoom on the only window in the current tab
@NeilsC
Copy link

NeilsC commented Jan 8, 2019

Great plugin 👍

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
Copy link
Owner

dhruvasagar commented Jan 8, 2019

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

@NeilsC
Copy link

NeilsC commented Jan 8, 2019

@dhruvasagar That did the trick, thanks!

@ovidius72
Copy link

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

@dhruvasagar
Copy link
Owner

@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
Copy link

@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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants