From f5b275385ca8a9109744c94dd043e2c44cfac0cb Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Thu, 13 Jun 2024 01:27:20 +0200 Subject: [PATCH] feat(nvim/toggleterm): position based on screen size --- pkgs/nvim/config/utils/toggleterm.nix | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/pkgs/nvim/config/utils/toggleterm.nix b/pkgs/nvim/config/utils/toggleterm.nix index f9e23f8..f31229b 100644 --- a/pkgs/nvim/config/utils/toggleterm.nix +++ b/pkgs/nvim/config/utils/toggleterm.nix @@ -22,10 +22,28 @@ shell = "zsh"; direction = "float"; # 'vertical' | 'horizontal' | 'window' | 'float' auto_scroll = true; - float_opts = { + float_opts = let + widthP = "0.9"; + heightP = "0.9"; + in rec { border = "single"; # 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open - width = 80; - height = 20; + width = '' + function() + return math.floor(vim.o.columns * ${widthP}) + end + ''; + height = '' + function() + return math.floor(vim.o.lines * ${heightP}) + end + ''; + row = '' + function() + local heightFn = ${height} + print(heightFn()) + return math.floor((vim.o.lines - heightFn()) / 2) - 1 + end + ''; winblend = 0; }; winbar = {