r/neovim • • Feb 22 '20

Lens.vim: A Vim Automatic Window Resizing Plugin

133 Upvotes

18 comments sorted by

12

u/metanat Feb 22 '20

You can find the plugin at camspiers/lens.vim. The idea behind this plugin is to resize windows (on enter) to a minimal viewport that allows you to see meaningful content if the current size of the window is too small. This is the first plugin I've written that (optionally) integrates with the animate.vim library for window animation, and so provides an example of how other plugin might do that too.

2

u/brokenbyteio Feb 22 '20

This is really cool, but any way to make it ignore floating windows? It gets a little wonky with vim-floatterm and Vista-Vim completely shits itself with the popup code previews.

Otherwise, really good job! I think it's a great plugin!

1

u/metanat Feb 22 '20

Thanks for the bug report, I really appreciate it. Would you be able to file it at: https://github.com/camspiers/lens.vim/issues as I want to fix it but need as much detail as you can give.

2

u/brokenbyteio Feb 23 '20

Looks like either someone beat me to making the issue or you figured it out on your own, but as I was making my issue this morning I decided to pull the latest version and check the log, and my issue has been fixed! Thank you very much!

1

u/metanat Feb 23 '20

A contributor fixed it!

2

u/brokenbyteio Feb 22 '20

I'd be happy to, but it might take me a day or two. I'll definitely get to it as soon as I can though!

5

u/ChintusTheGreat Feb 22 '20

Damn, never thought Vim/Neovim could do something like that. Well, now that I am thinking about it, Vim/Neovim can do just about anything one wants. Nice job dude.

1

u/syslino Feb 25 '20

Sorry, I don't want to be rude, but why would I need a plugin for this? Okay - fancy animations. But this could be easily achieved with some autocmds - minus the fancy-bling of course - or am I missing something?

I did not install it, as I have some similar functionality and try to keep my plugged clean.

Please do not interpret this as critique, I'm just curious!

1

u/metanat Feb 25 '20

If some easy autocmds work for you then totally go for it! This was created out of my desire to have something that works for me, especially when I am on smaller screens but still want to retain a splits layout.

Would you like to share your autocmds?

1

u/syslino Feb 25 '20

I don't have autocmds for this, as I do not need these kind of resizing happening automatically. I'm a simple man, I use some really simple bindings for this. :-)

If I want to have a big view on a file I have a binding for :tabopen and :tabclose, toggleable per global var.

Mostly this is enough. There are some commands acccepting a count, like creating splits either :vs or :hs for each file (or the provided count).

Really nothing too fancy, mostly one-liners. But for me it's perfectly enough.

I really was just curious! I can provide some snippets, if you are interested - and when I'm back home and find some time!

1

u/pablo1107 Feb 22 '20

Men, you don't know how much I wanted someone to maintain a resizer plugin, I'm currently using roman/golden-ratio. Yours look cool with animate.vim! :D

1

u/[deleted] Feb 22 '20

as someone with a 32 in monitor and a 29 in monitor, i sincerely thank you!

1

u/[deleted] Feb 22 '20

Great job!!!

1

u/[deleted] Feb 22 '20

Only issue I can think of is that it would resize terminal buffers and mess up terminal output.

1

u/pain666 Feb 22 '20

I was using something similar, now CTRL-W= does the trick for me.