refactor(nvim): change header logo for dashboard (alpha)
Some checks failed
Check Formatting of Files / Check-Formatting (push) Failing after 33s
Some checks failed
Check Formatting of Files / Check-Formatting (push) Failing after 33s
This commit is contained in:
parent
e8384118a8
commit
cddedfdfbb
@ -16,36 +16,92 @@ return {
|
|||||||
end,
|
end,
|
||||||
lazy = true,
|
lazy = true,
|
||||||
opts = function()
|
opts = function()
|
||||||
-- Set header
|
-- helper function for utf8 chars
|
||||||
|
local function getCharLen(s, pos)
|
||||||
|
local byte = string.byte(s, pos)
|
||||||
|
if not byte then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return (byte < 0x80 and 1) or (byte < 0xE0 and 2) or (byte < 0xF0 and 3) or (byte < 0xF8 and 4) or 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local function applyColors(logo, colors, logoColors)
|
||||||
local header = {
|
local header = {
|
||||||
type = "text",
|
val = logo,
|
||||||
val = {
|
opts = {
|
||||||
" ",
|
hl = {},
|
||||||
" ",
|
|
||||||
" -╲ '- ",
|
|
||||||
" -' :╲ │ '- ",
|
|
||||||
" -' : ╲ │ '- ",
|
|
||||||
" -'· : ╲ │ '- ",
|
|
||||||
" '.-.· : ╲ │ │ ",
|
|
||||||
" │. .-· : ╲ │ │ ",
|
|
||||||
" │ . .-· : ╲ │ │ ",
|
|
||||||
" │. . .-·; ╲ │ │ ",
|
|
||||||
" │ . . .-│ ╲ │ │ ",
|
|
||||||
" │. . . .│╲ ╲│ │ ",
|
|
||||||
" │ . . . │ ╲ ;- │ ",
|
|
||||||
" │. . . .│ ╲ :·- │ ",
|
|
||||||
" │ . . . │ ╲ : .- │ ",
|
|
||||||
" │. . . .│ ╲ :. .- │ ",
|
|
||||||
" `- . . .│ ╲ : . .- -' ",
|
|
||||||
" `- . .│ ╲ :. ..-' ",
|
|
||||||
" `-. │ ╲ :..-' ",
|
|
||||||
" `│ ╲;-' ",
|
|
||||||
" ",
|
|
||||||
" ",
|
|
||||||
},
|
},
|
||||||
opts = { position = "center", hl = "@boolean" },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for key, color in pairs(colors) do
|
||||||
|
local name = "Alpha" .. key
|
||||||
|
vim.api.nvim_set_hl(0, name, color)
|
||||||
|
colors[key] = name
|
||||||
|
end
|
||||||
|
|
||||||
|
for i, line in ipairs(logoColors) do
|
||||||
|
local highlights = {}
|
||||||
|
local pos = 0
|
||||||
|
|
||||||
|
for j = 1, #line do
|
||||||
|
local opos = pos
|
||||||
|
pos = pos + getCharLen(logo[i], opos + 1)
|
||||||
|
|
||||||
|
local color_name = colors[line:sub(j, j)]
|
||||||
|
if color_name then
|
||||||
|
table.insert(highlights, { color_name, opos, pos })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(header.opts.hl, highlights)
|
||||||
|
end
|
||||||
|
return header
|
||||||
|
end
|
||||||
|
-- Thanks to https://github.com/goolord/alpha-nvim/discussions/16#discussioncomment-10062303
|
||||||
|
local header = applyColors({
|
||||||
|
[[ ███ ███ ]],
|
||||||
|
[[ ████ ████ ]],
|
||||||
|
[[ ████ █████ ]],
|
||||||
|
[[ █ ████ █████ ]],
|
||||||
|
[[ ██ ████ █████ ]],
|
||||||
|
[[ ███ ████ █████ ]],
|
||||||
|
[[ ████ ████ ████ ]],
|
||||||
|
[[ █████ ████████ ]],
|
||||||
|
[[ █████ ███████ ]],
|
||||||
|
[[ █████ ██████ ]],
|
||||||
|
[[ █████ █████ ]],
|
||||||
|
[[ ████ ████ ]],
|
||||||
|
[[ ███ ███ ]],
|
||||||
|
[[ ]],
|
||||||
|
[[ N E O V I M ]],
|
||||||
|
}, {
|
||||||
|
["b"] = { fg = "#3399ff", ctermfg = 33 },
|
||||||
|
["a"] = { fg = "#53C670", ctermfg = 35 },
|
||||||
|
["g"] = { fg = "#39ac56", ctermfg = 29 },
|
||||||
|
["h"] = { fg = "#33994d", ctermfg = 23 },
|
||||||
|
["i"] = { fg = "#33994d", bg = "#39ac56", ctermfg = 23, ctermbg = 29 },
|
||||||
|
["j"] = { fg = "#53C670", bg = "#33994d", ctermfg = 35, ctermbg = 23 },
|
||||||
|
["k"] = { fg = "#30A572", ctermfg = 36 },
|
||||||
|
}, {
|
||||||
|
[[ kkkka gggg ]],
|
||||||
|
[[ kkkkaa ggggg ]],
|
||||||
|
[[ b kkkaaa ggggg ]],
|
||||||
|
[[ bb kkaaaa ggggg ]],
|
||||||
|
[[ bbb kaaaaa ggggg ]],
|
||||||
|
[[ bbbb aaaaaa ggggg ]],
|
||||||
|
[[ bbbbb aaaaaa igggg ]],
|
||||||
|
[[ bbbbb aaaaaahiggg ]],
|
||||||
|
[[ bbbbb aaaaajhigg ]],
|
||||||
|
[[ bbbbb aaaaajhig ]],
|
||||||
|
[[ bbbbb aaaaajhi ]],
|
||||||
|
[[ bbbbb aaaaajh ]],
|
||||||
|
[[ bbbb aaaaa ]],
|
||||||
|
[[ ]],
|
||||||
|
[[ a a a b b b ]],
|
||||||
|
})
|
||||||
|
header.type = "text"
|
||||||
|
header.opts.position = "center"
|
||||||
|
|
||||||
local vim_version = {
|
local vim_version = {
|
||||||
type = "text",
|
type = "text",
|
||||||
val = function()
|
val = function()
|
||||||
@ -169,18 +225,19 @@ return {
|
|||||||
end
|
end
|
||||||
local opts = {
|
local opts = {
|
||||||
layout = {
|
layout = {
|
||||||
padding(8),
|
padding(10),
|
||||||
header,
|
header,
|
||||||
|
padding(1),
|
||||||
vim_version,
|
vim_version,
|
||||||
padding(2),
|
padding(1),
|
||||||
datetime,
|
datetime,
|
||||||
padding(1),
|
padding(1),
|
||||||
plugin_info,
|
plugin_info,
|
||||||
padding(1),
|
padding(1),
|
||||||
plugins_loaded,
|
plugins_loaded,
|
||||||
padding(2),
|
padding(1),
|
||||||
buttons,
|
buttons,
|
||||||
padding(2),
|
padding(1),
|
||||||
fortune,
|
fortune,
|
||||||
},
|
},
|
||||||
opts = { margin = 5 },
|
opts = { margin = 5 },
|
||||||
|
Loading…
Reference in New Issue
Block a user