Skip to content

Commit

Permalink
fix(alpha): patch alpha button function until resolved upstream
Browse files Browse the repository at this point in the history
PR fix opened upstream: goolord/alpha-nvim#271
  • Loading branch information
mehalter committed Mar 20, 2024
1 parent 4ab1098 commit 4b1788e
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions lua/astronvim/plugins/alpha.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,42 @@ return {
opts = function()
local dashboard = require "alpha.themes.dashboard"

local orig_button = dashboard.button -- customize button function
dashboard.button = function(...)
return vim.tbl_deep_extend("force", orig_button(...), {
opts = { cursor = -2, width = 36, hl = "DashboardCenter", hl_shortcut = "DashboardShortcut" },
})
end
dashboard.leader = "LDR"

--- @param sc string
--- @param txt string
--- @param keybind string? optional
--- @param keybind_opts table? optional
dashboard.button = function(sc, txt, keybind, keybind_opts)
-- HACK: fixes leader customization, remove after fixed upstream
-- https://github.com/goolord/alpha-nvim/pull/271
local sc_ = sc:gsub("%s", ""):gsub(dashboard.leader, "<leader>")

return {
type = "button",
val = txt,
on_press = function()
local key = vim.api.nvim_replace_termcodes(keybind or sc_ .. "<Ignore>", true, false, true)
vim.api.nvim_feedkeys(key, "t", false)
end,
opts = {
position = "center",
shortcut = sc,
cursor = -2,
width = 36,
align_shortcut = "right",
hl = "DashboardCenter",
hl_shortcut = "DashboardShortcut",
keymap = keybind and {
"n",
sc_,
keybind,
vim.F.if_nil(keybind_opts, { noremap = true, silent = true, nowait = true }),
},
},
}
end

dashboard.section.header.val = {
" █████ ███████ ████████ ██████ ██████",
"██ ██ ██ ██ ██ ██ ██ ██",
Expand Down

0 comments on commit 4b1788e

Please sign in to comment.