fix(dashboard): Use more robust method for toggling statusline

This commit is contained in:
Gazareth 2023-01-04 23:46:01 +00:00 committed by Sidhanth Rathod
parent e6a230129a
commit f67c629249
1 changed files with 20 additions and 8 deletions

View File

@ -97,14 +97,26 @@ alpha.setup {
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = "alpha", pattern = "alpha",
callback = function() callback = function()
-- store current statusline value and use that -- store initial statusline value to be used later
local old_laststatus = vim.opt.laststatus if type(vim.g.nvchad_vim_laststatus) == "nil" then
vim.api.nvim_create_autocmd("BufUnload", { vim.g.nvchad_vim_laststatus = vim.opt.laststatus._value
buffer = 0, end
callback = function()
vim.opt.laststatus = old_laststatus -- Remove statusline since we have just loaded into an "alpha" filetype (i.e. dashboard)
end,
})
vim.opt.laststatus = 0 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, end,
}) })