local status_ok, alpha = pcall(require, "alpha") if not status_ok then return end local function button(sc, txt, cmd, kopts, opts) opts = opts or { position = "center", shortcut = sc:gsub("", "LDR"), cursor = 0, width = 49, align_shortcut = "right", hl_shortcut = "AlphaShortcut", hl = "AlphaText", } if cmd then kopts = kopts or { noremap = true, silent = true, nowait = true } opts.keymap = { "n", sc, cmd, kopts } end local function on_press() local key = vim.api.nvim_replace_termcodes(cmd, true, false, true) vim.api.nvim_feedkeys(key, "t", false) end return { type = "button", val = txt, opts = opts, on_press = on_press, } end local header = { '█▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀▀█ █▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀▀█ ', '█ ░█████▀▀▀▀▀█████▓▄ ▀▀▀▀ ░ ░█ ░█ ░█ █ ', '█ ▒███████ ▓███████ ▒██ ▓███ ▓███ ▓███ █ ', '█ ▓███████ ▓███████ ▓█████████████████ █ ', '█ ▓███████ ▓███████ ███ ██████████████ █ ', '█ ▓███████ ▓███████ ███ ██████████████ █ ', '█ ▓███████ ▓███████ ███ ██████████████ █ ', '█ ▓███████ ▓███████ ███▄██████████████ █ ', '█ ▓███████ ▓███████ ██████▀▀██████████ █ ', '▀ ▓███████ ▓███████▄ ▄▄███████████ █ ', '█ ▓███████ ██████████████████ █▄▄▄', '█ ▓███████▀▀ ▀ ▀ ▀████████████████▄ ▄ █', '█▄▄▄▄▄▄▄ ▀ █▀▀▀▀▀▀▀▀▀▀▀▀█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█', ' █ ▀ █ ', ' ▀▀▀▀▀ ', } local footer = { '▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄', } alpha.setup { layout = { { type = 'text', val = function() local padding = {} for i = 1, math.floor((vim.api.nvim_win_get_height(0) - #header - 6 - #footer) / 2), 1 do table.insert(padding, " ") end return padding end }, { type = 'text', val = header, opts = { position = 'center', hl = 'AlphaHeader', } }, { type = 'padding', val = 1 }, { type = 'group', val = { button('f', '? Find files', 'Telescope find_files'), button('r', '↺ Recent files', 'Telescope oldfiles '), button('n', '▣ Neorg workspace', 'Telescope neorg switch_workspace'), button('m', '≡ Menu', 'ConfigMenu'), button('q', '✖ Quit', 'wqa'), } }, { type = 'text', val = footer, opts = { position = 'center', hl = 'AlphaFooter', } }, }, opts = { keymap = { press = '', press_queue = nil }, setup = function() vim.api.nvim_create_autocmd('User', { pattern = 'AlphaReady', desc = 'disable stuff for alpha', callback = function() vim.opt.laststatus = 0 vim.opt.showtabline = 0 vim.opt.more = false vim.opt.showcmd = false vim.opt.ruler = false vim.opt.number = false vim.opt.relativenumber = false end, }) vim.api.nvim_create_autocmd('BufUnload', { buffer = 0, desc = 'enable stuff after alpha closes', callback = function() vim.opt.laststatus = 3 vim.opt.showtabline = 2 vim.opt.more = true vim.opt.showcmd = true vim.opt.ruler = true vim.opt.number = false vim.opt.relativenumber = false end, }) end, } }