akinsho / toggleterm.nvim

A neovim lua plugin to help easily manage multiple terminal windows
GNU General Public License v3.0
4.21k stars 170 forks source link

doc(float_opts): add number/function description of row and col #532

Closed penryu closed 7 months ago

penryu commented 8 months ago

UPDATE:

A doc-only change to describe that row and col are also configurable via number or function, like width and height.


Original description:

~This one-line patch allows me to do something like this:~

vim.g.toggle_quake_float = true

~in my init.lua. Then by setting~

float_opts = {
  height = math.floor(vim.o.lines * 0.4),
  width = vim.o.columns,
}

~I get a true Quake-style float terminal.~

~It didn't seem worthwhile to create an entirely new direction when it's such a tiny variation on the existing float, but there might be an argument to make it part of the float_opts table?~

~If you think this change is worth incorporating, I can add the corresponding paragraph to toggleterm.txt.~

akinsho commented 7 months ago

This plugin doesn't use g variables so that won't be a good way to go here. Also tbh I think this use case is quite specific and something a user could build into their config not something that needs to ship with this plugin

penryu commented 7 months ago

I agree: I did have concerns about the use of g vars. A key in float_opts would probably fit a lot better.

See comment below. ~When you say "build it into their config", are you talking about a configuration of toggleterm, or a different solution entirely?~

Granted my specific use case is probably very specific — especially the name of the variable I used.

~With that in mind, is there any interest in a more generalized solution like:~

float_opts = {
  horiz_align = 'left' | 'center' | 'right',  -- default: 'center'
  vert_align = 'top' | 'center' | 'bottom',  -- default: 'center'
},
penryu commented 7 months ago

Nevermind. I just realized that row and col are also valid float_opts, and looked at how M._resolve_size() works. So yes, this is truly trivial to implement with:

float_opts = { row = 0, ... },

Here is a doc-only change instead. :)