local present, alpha = pcall(require, "alpha") if not present then return end require("base46").load_highlight "alpha" local function button(sc, txt, keybind) local sc_ = sc:gsub("%s", ""):gsub("SPC", "") local opts = { position = "center", text = txt, shortcut = sc, cursor = 5, width = 36, align_shortcut = "right", hl = "AlphaButtons", } if keybind then opts.keymap = { "n", sc_, keybind, { noremap = true, silent = true } } end return { type = "button", val = txt, on_press = function() local key = vim.api.nvim_replace_termcodes(sc_, true, false, true) or "" vim.api.nvim_feedkeys(key, "normal", false) end, opts = opts, } 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 = { type = "text", val = { " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ", " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", " ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", " ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", " ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ", " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", " ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", " ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ", " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ", " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ", }, opts = { position = "center", hl = "AlphaHeader", }, }, buttons = { type = "group", val = { button("SPC f f", " Find File ", ":Telescope find_files"), button("SPC f o", " Recent File ", ":Telescope oldfiles"), button("SPC f w", " Find Word ", ":Telescope live_grep"), button("SPC b m", " Bookmarks ", ":Telescope marks"), button("SPC t h", " Themes ", ":Telescope themes"), button("SPC e s", " Settings", ":e $MYVIMRC | :cd %:p:h "), }, opts = { spacing = 1, }, }, headerPaddingTop = { type = "padding", val = headerPadding }, headerPaddingBottom = { type = "padding", val = 2 }, } options = require("core.utils").load_override(options, "goolord/alpha-nvim") alpha.setup { layout = { options.headerPaddingTop, options.header, options.headerPaddingBottom, options.buttons, }, opts = {}, } -- Disable statusline in dashboard vim.api.nvim_create_autocmd("FileType", { pattern = "alpha", callback = function() -- 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, })