From d9cd55fc0f3f740806538d81bd89cb55bf5f3d2d Mon Sep 17 00:00:00 2001 From: doubleChu <57394064+doubleChu@users.noreply.github.com> Date: Mon, 15 Aug 2022 22:52:52 +0800 Subject: [PATCH] make paddings in the layout can be overrided users can adjust the padding between the top and the header, or the header and buttons. --- lua/plugins/configs/alpha.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lua/plugins/configs/alpha.lua b/lua/plugins/configs/alpha.lua index 1572aa9..e2caab6 100644 --- a/lua/plugins/configs/alpha.lua +++ b/lua/plugins/configs/alpha.lua @@ -34,6 +34,11 @@ local function button(sc, txt, keybind) } end +-- dynamic header padding +local fn = vim.fn +local marginTopPercent = 0.3 +local headerPadding = fn.max { 2, fn.floor(fn.winheight(0) * marginTopPercent) } + local options = { header = { @@ -71,20 +76,18 @@ local options = { spacing = 1, }, }, + + headerPaddingTop = { type = "padding", val = headerPadding }, + headerPaddingBottom = { type = "padding", val = 2 }, } options = require("core.utils").load_override(options, "goolord/alpha-nvim") --- dynamic header padding -local fn = vim.fn -local marginTopPercent = 0.3 -local headerPadding = fn.max { 2, fn.floor(fn.winheight(0) * marginTopPercent) } - alpha.setup { layout = { - { type = "padding", val = headerPadding }, + options.headerPaddingTop, options.header, - { type = "padding", val = 2 }, + options.headerPaddingBottom, options.buttons, }, opts = {},