2022-02-20 06:14:43 +00:00
|
|
|
local present, alpha = pcall(require, "alpha")
|
|
|
|
|
|
|
|
if not present then
|
2022-07-22 17:00:00 +01:00
|
|
|
return
|
2022-02-20 06:14:43 +00:00
|
|
|
end
|
|
|
|
|
2022-06-14 13:06:27 +01:00
|
|
|
require("base46").load_highlight "alpha"
|
|
|
|
|
2022-02-20 06:14:43 +00:00
|
|
|
local function button(sc, txt, keybind)
|
2022-07-22 17:00:00 +01:00
|
|
|
local sc_ = sc:gsub("%s", ""):gsub("SPC", "<leader>")
|
2022-02-20 06:14:43 +00:00
|
|
|
|
2022-07-22 17:00:00 +01:00
|
|
|
local opts = {
|
|
|
|
position = "center",
|
|
|
|
text = txt,
|
|
|
|
shortcut = sc,
|
|
|
|
cursor = 5,
|
|
|
|
width = 36,
|
|
|
|
align_shortcut = "right",
|
|
|
|
hl = "AlphaButtons",
|
|
|
|
}
|
2022-02-20 06:14:43 +00:00
|
|
|
|
2022-07-22 17:00:00 +01:00
|
|
|
if keybind then
|
|
|
|
opts.keymap = { "n", sc_, keybind, { noremap = true, silent = true } }
|
|
|
|
end
|
2022-02-20 06:14:43 +00:00
|
|
|
|
2022-07-22 17:00:00 +01:00
|
|
|
return {
|
|
|
|
type = "button",
|
|
|
|
val = txt,
|
|
|
|
on_press = function()
|
2022-08-17 20:01:31 +01:00
|
|
|
local key = vim.api.nvim_replace_termcodes(sc_, true, false, true) or ""
|
2022-07-22 17:00:00 +01:00
|
|
|
vim.api.nvim_feedkeys(key, "normal", false)
|
|
|
|
end,
|
|
|
|
opts = opts,
|
|
|
|
}
|
2022-02-20 06:14:43 +00:00
|
|
|
end
|
|
|
|
|
2022-08-15 15:52:52 +01:00
|
|
|
-- dynamic header padding
|
|
|
|
local fn = vim.fn
|
|
|
|
local marginTopPercent = 0.3
|
|
|
|
local headerPadding = fn.max { 2, fn.floor(fn.winheight(0) * marginTopPercent) }
|
|
|
|
|
2022-07-30 04:12:18 +01:00
|
|
|
local options = {
|
2022-03-19 04:19:54 +00:00
|
|
|
|
2022-07-30 04:12:18 +01:00
|
|
|
header = {
|
|
|
|
type = "text",
|
|
|
|
val = {
|
|
|
|
" ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ",
|
|
|
|
" ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ",
|
|
|
|
" ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ",
|
|
|
|
" ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ",
|
|
|
|
" ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ",
|
|
|
|
" ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ",
|
|
|
|
" ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ",
|
|
|
|
" ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ",
|
|
|
|
" ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ",
|
|
|
|
" ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ",
|
|
|
|
" ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ",
|
|
|
|
},
|
|
|
|
opts = {
|
|
|
|
position = "center",
|
|
|
|
hl = "AlphaHeader",
|
|
|
|
},
|
2022-07-22 17:00:00 +01:00
|
|
|
},
|
2022-03-19 04:19:54 +00:00
|
|
|
|
2022-07-30 04:12:18 +01:00
|
|
|
buttons = {
|
|
|
|
type = "group",
|
|
|
|
val = {
|
|
|
|
button("SPC f f", " Find File ", ":Telescope find_files<CR>"),
|
|
|
|
button("SPC f o", " Recent File ", ":Telescope oldfiles<CR>"),
|
|
|
|
button("SPC f w", " Find Word ", ":Telescope live_grep<CR>"),
|
|
|
|
button("SPC b m", " Bookmarks ", ":Telescope marks<CR>"),
|
|
|
|
button("SPC t h", " Themes ", ":Telescope themes<CR>"),
|
|
|
|
button("SPC e s", " Settings", ":e $MYVIMRC | :cd %:p:h <CR>"),
|
|
|
|
},
|
|
|
|
opts = {
|
|
|
|
spacing = 1,
|
|
|
|
},
|
2022-07-22 17:00:00 +01:00
|
|
|
},
|
2022-08-15 15:52:52 +01:00
|
|
|
|
|
|
|
headerPaddingTop = { type = "padding", val = headerPadding },
|
|
|
|
headerPaddingBottom = { type = "padding", val = 2 },
|
2022-02-20 06:14:43 +00:00
|
|
|
}
|
|
|
|
|
2022-05-29 11:37:47 +01:00
|
|
|
options = require("core.utils").load_override(options, "goolord/alpha-nvim")
|
2022-03-20 02:00:30 +00:00
|
|
|
|
2022-04-27 16:42:28 +01:00
|
|
|
alpha.setup {
|
2022-07-22 17:00:00 +01:00
|
|
|
layout = {
|
2022-08-15 15:52:52 +01:00
|
|
|
options.headerPaddingTop,
|
2022-07-22 17:00:00 +01:00
|
|
|
options.header,
|
2022-08-15 15:52:52 +01:00
|
|
|
options.headerPaddingBottom,
|
2022-07-22 17:00:00 +01:00
|
|
|
options.buttons,
|
|
|
|
},
|
|
|
|
opts = {},
|
2022-04-27 16:42:28 +01:00
|
|
|
}
|
2022-08-21 12:56:34 +01:00
|
|
|
|
|
|
|
-- Disable statusline in dashboard
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
|
|
pattern = "alpha",
|
|
|
|
callback = function()
|
2023-01-04 23:46:01 +00:00
|
|
|
-- store initial statusline value to be used later
|
2023-01-05 20:57:19 +00:00
|
|
|
if not vim.g.nvchad_vim_laststatus then
|
2023-01-04 23:46:01 +00:00
|
|
|
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" }, {
|
2022-08-21 12:56:34 +01:00
|
|
|
callback = function()
|
2023-01-04 23:46:01 +00:00
|
|
|
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
|
2022-08-21 12:56:34 +01:00
|
|
|
})
|
2023-01-04 23:46:01 +00:00
|
|
|
|
2022-08-21 12:56:34 +01:00
|
|
|
end,
|
|
|
|
})
|