lambdalisue/vim-fern

[feature] <Plug>(fern-action-zoom:half-toggle) <Plug>(fern-action-zoom:full-toggle)

Freed-Wu opened this issue · 4 comments

<Plug>(fern-action-zoom:XXX-toggle) is <Plug>(fern-action-zoom:XXX) or <Plug>(fern-action-zoom:reset).

Thanks!

I don't get what you mean

<Plug>(fern-action-zoom:XXX-toggle) is <Plug>(fern-action-zoom:XXX) or <Plug>(fern-action-zoom:reset).

Sorry, I mean:

Screenshot from 2022-10-19 14-11-07
Now press <plug>(fern-action-zoom:half-toggle) equal to <plug>(fern-action-zoom:half)

Screenshot from 2022-10-19 14-11-13
Now press <plug>(fern-action-zoom:half-toggle) equal to <plug>(fern-action-zoom:reset)

Maybe should be named <plug>(fern-action-zoom:half-or-reset)?

A simple method is just set a b:half and if b:half == 1 <plug>(fern-action-zoom:half-or-reset) is <plug>(fern-action-zoom:reset) and let b:half = 0. Else <plug>(fern-action-zoom:half-or-reset) is <plug>(fern-action-zoom:half) and let b:half = 0. Or detect the window width to choose different behavior.

Got it but I think it's easy to implement it by using <expr> like

nnoremap <buffer><expr> winwidth(0) > 10 
      \ ? "\<Plug>(fern-action-zoom:reset)"
      \ : "\<Plug>(fern-action-zoom:half)"

Thanks! ❤️