Skip to content

Commit 4b1788e

Browse files
committed
fix(alpha): patch alpha button function until resolved upstream
PR fix opened upstream: goolord/alpha-nvim#271
1 parent 4ab1098 commit 4b1788e

1 file changed

Lines changed: 34 additions & 6 deletions

File tree

lua/astronvim/plugins/alpha.lua

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,42 @@ return {
7777
opts = function()
7878
local dashboard = require "alpha.themes.dashboard"
7979

80-
local orig_button = dashboard.button -- customize button function
81-
dashboard.button = function(...)
82-
return vim.tbl_deep_extend("force", orig_button(...), {
83-
opts = { cursor = -2, width = 36, hl = "DashboardCenter", hl_shortcut = "DashboardShortcut" },
84-
})
85-
end
8680
dashboard.leader = "LDR"
8781

82+
--- @param sc string
83+
--- @param txt string
84+
--- @param keybind string? optional
85+
--- @param keybind_opts table? optional
86+
dashboard.button = function(sc, txt, keybind, keybind_opts)
87+
-- HACK: fixes leader customization, remove after fixed upstream
88+
-- https://github.com/goolord/alpha-nvim/pull/271
89+
local sc_ = sc:gsub("%s", ""):gsub(dashboard.leader, "<leader>")
90+
91+
return {
92+
type = "button",
93+
val = txt,
94+
on_press = function()
95+
local key = vim.api.nvim_replace_termcodes(keybind or sc_ .. "<Ignore>", true, false, true)
96+
vim.api.nvim_feedkeys(key, "t", false)
97+
end,
98+
opts = {
99+
position = "center",
100+
shortcut = sc,
101+
cursor = -2,
102+
width = 36,
103+
align_shortcut = "right",
104+
hl = "DashboardCenter",
105+
hl_shortcut = "DashboardShortcut",
106+
keymap = keybind and {
107+
"n",
108+
sc_,
109+
keybind,
110+
vim.F.if_nil(keybind_opts, { noremap = true, silent = true, nowait = true }),
111+
},
112+
},
113+
}
114+
end
115+
88116
dashboard.section.header.val = {
89117
" █████ ███████ ████████ ██████ ██████",
90118
"██ ██ ██ ██ ██ ██ ██ ██",

0 commit comments

Comments
 (0)