From f67c62924902804fbbd1abdf402a27ffc860804e Mon Sep 17 00:00:00 2001 From: Gazareth Date: Wed, 4 Jan 2023 23:46:01 +0000 Subject: [PATCH] fix(dashboard): Use more robust method for toggling statusline --- lua/plugins/configs/alpha.lua | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lua/plugins/configs/alpha.lua b/lua/plugins/configs/alpha.lua index b91c233..7a54242 100644 --- a/lua/plugins/configs/alpha.lua +++ b/lua/plugins/configs/alpha.lua @@ -97,14 +97,26 @@ alpha.setup { vim.api.nvim_create_autocmd("FileType", { pattern = "alpha", callback = function() - -- store current statusline value and use that - local old_laststatus = vim.opt.laststatus - vim.api.nvim_create_autocmd("BufUnload", { - buffer = 0, - callback = function() - vim.opt.laststatus = old_laststatus - end, - }) + -- store initial statusline value to be used later + if type(vim.g.nvchad_vim_laststatus) == "nil" then + vim.g.nvchad_vim_laststatus = vim.opt.laststatus._value + end + + -- Remove statusline since we have just loaded into an "alpha" filetype (i.e. dashboard) vim.opt.laststatus = 0 + + vim.api.nvim_create_autocmd({ "TabEnter", "BufLeave" }, { + callback = function() + local current_type = vim.bo.filetype + if current_type == "alpha" or #current_type == 0 then + -- Switched to alpha or unknown filetype + vim.opt.laststatus = 0 + else + -- Switched to any other filetype + vim.opt.laststatus = vim.g.nvchad_vim_laststatus + end + end + }) + end, })