local status_ok, alpha = pcall(require, "alpha") if not status_ok then return end -- buttons local function button(sc, txt, keybind) local opts = { position = "center", shortcut = sc, cursor = 5, width = 80, align_shortcut = "right", hl_shortcut = "Keyword", } local function on_press() local key = vim.api.nvim_replace_termcodes(keybind .. "", true, false, true) vim.api.nvim_feedkeys(key, "t", false) end return { type = "button", val = txt, on_press = on_press, opts = opts, } end -- actual config local R = {} R.width = vim.api.nvim_win_get_width(0) R.height = vim.api.nvim_win_get_height(0) if R.width >= 120 then alpha.setup { layout = { { type = "padding", val = math.floor(R.height / 2.5) }, button([[ `'::. `'::::. ]], "Recent Files", "Telescope oldfiles"), button([[ _________H ,%%&%, _____A_ ]], "New File", "ene"), button([[ /\ _ \%&&%%&% / /\ ]], "Update Plugins", "DepSync"), button([[ / \___/^\___\%&%%&& __/__/\__/ \___ ]], "", ""), button([[ | | [] [] |%\Y&%' /__|" '' "| /___/\ ]], "", ""), button([[ | | .-. | || |''|"'||'"| |' '|| ]], "", ""), button([[~~@._|@@_|||_@@|~||~~~ ~`""`""))""`"`""""`~~]], "", ""), button([[ `""") )"""` // ]], "", ""), } } end if R.width <= 119 then local header = { [[ `'::. `'::::. ]], [[ _________H ,%%&%, _____A_ ]], [[ /\ _ \%&&%%&% / /\ ]], [[ / \___/^\___\%&%%&& __/__/\__/ \___ ]], [[ | | [] [] |%\Y&%' /__|" '' "| /___/\ ]], [[ | | .-. | || |''|"'||'"| |' '|| ]], [[~~@._|@@_|||_@@|~||~~~ ~`""`""))""`"`""""`~~]], [[ `""") )"""` // ]], } alpha.setup { layout = { { type = "padding", val = math.floor(R.height / 2.5) }, { type = "text", val = header, opts = { position = "center", hl = "AlphaHeader" } }, { type = "padding", val = 1 }, button([[]], "Recent Files", "Telescope oldfiles"), button([[]], "New File", "ene"), button([[]], "Update Plugins", "DepSync"), } } end