feat(dashboard): hide tabline and statusline when loading during startup

This commit is contained in:
Folke Lemaitre 2024-11-19 08:26:02 +01:00
parent 0b9e09cbd9
commit 75dc74c5dc
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -104,7 +104,7 @@ local defaults = {
},
-- item field formatters
formats = {
icon = function(item, sss)
icon = function(item)
if item.file and item.icon == "file" or item.icon == "directory" then
return M.icon(item.file, item.icon)
end
@ -152,6 +152,7 @@ Snacks.config.style("dashboard", {
signcolumn = "no",
spell = false,
statuscolumn = "",
statusline = "",
winbar = "",
winhighlight = "Normal:SnacksDashboardNormal,NormalFloat:SnacksDashboardNormal",
wrap = false,
@ -213,6 +214,7 @@ function M.open(opts)
if self.opts.debug then
Snacks.debug.stats({ min = 0.2 })
end
self:fire("Opened")
return self
end
@ -250,6 +252,12 @@ function D:init()
end
end,
})
vim.api.nvim_create_autocmd("BufWipeout", {
buffer = self.buf,
callback = function()
self:fire("Closed")
end,
})
end
---@return {width:number, height:number}
@ -959,8 +967,8 @@ function M.sections.terminal(opts)
pcall(vim.fn.jobstop, jid)
return true
end)
vim.api.nvim_create_autocmd("BufWipeout", { buffer = self.buf, callback = close })
self:on("UpdatePre", close)
self:on("Closed", close)
self:trace()
end,
text = ("\n"):rep(height - 1),
@ -996,8 +1004,8 @@ function M.setup()
local buf = 1
-- don't open the dashboard if there are any arguments
if vim.fn.argc() > 0 then
M.status.reason = "argc() > 0"
if vim.fn.argc(-1) > 0 then
M.status.reason = "argc(-1) > 0"
return
end
@ -1038,7 +1046,16 @@ function M.setup()
return
end
M.status.opened = true
M.open({ buf = buf, win = wins[1] })
local options = { showtabline = vim.o.showtabline, laststatus = vim.o.laststatus }
vim.o.showtabline, vim.o.laststatus = 0, 0
M.open({ buf = buf, win = wins[1] }):on("Closed", function()
for k, v in pairs(options) do
if vim.o[k] == 0 and v ~= 0 then
vim.o[k] = v
end
end
end)
end
function M.health()