kassio/neoterm

Dynamically set size of terminal

nwaywood opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
Depending on what I am doing, something I like to have a small terminal at the bottom of the screen (with a height of 10) and sometimes I like a terminal taking up half the screen in a vertical split (e.g. when the output of the command being run is long).

As far as I can tell, I don't believe this functionality is currently possible. If I don't set neoterm_size then the vertical split looks like I want but the horizontal split now takes up half the screen (obviously). If I set let g:neoterm_size = 10 in my init.vim then it looks like I want when I make a horizonal split but messes up the vertical split.

Describe the solution you'd like

  • Solution 1: Split neoterm_size into two different variables neoterm_size_horizontal and neoterm_size_vertical so that the two sizes can be set independently. If they are not set they, the fallback value could still be neoterm_size

  • Solution 2: Use neoterm_size as the default but allow the size to be set dynamically to override the default. e.g. :botright neoterm_size=10 Ttoggle

I personally prefer the second solution if it's possible (I don't really know vimscript enough to know if it's possible) since its more flexible.

Describe alternatives you've considered

As far as I can tell, having a different size for horizontal and vertical terminals isn't possible to do currently

Additional context

Horizontal split how I want it by setting let g:neoterm_size = 10:

image

Messed up vertical split when let g:neoterm_size = 10 is set:

image

@nwaywood Thanks for the suggestion. I started to work on a solution in #293, can you try that and see if it works? It should be working for :Topen and :Ttoggle commands, like:

  • :Topen resize=10
  • vert :Ttoggle resize=32

Hey @kassio,

Thanks so much for implementing my suggestion!

I just tried it out and I have one question, is it possible to tell the resize argument to do an even split instead of providing a specific number?

The reason I ask is because I ran into the following situation:

  1. Make a vertical terminal with :vert :Ttoggle, it creates an even split since it's the default.
  2. Close the terminal with :Ttoggle
  3. Open a horizontal split with :botright :Ttoggle resize=10
  4. Close the terminal with :Ttoggle
  5. Open a vertical split again with :vert :Ttoggle

Now the vertical terminal is 10 columns wide instead of an even split like it was the first time. I understand this is because the resize argument is cached and is used by both vertical and horizontal commands, but if we were able to do something like resize='' the above issue could be avoid by using :vert :Ttoggle resize='' instead of :vert :Ttoggle


Edit: Nevermind I just actually tried :vert :Ttoggle resize= and it works 😅 Looks good!