feat(dashboard): allow for ansi in dashboard

Allows the dashboard to properly detect and display ANSI files
This commit is contained in:
2024-08-07 19:55:34 -04:00
parent 73bce16090
commit 6e47d1a8c5
+21 -17
View File
@@ -13,7 +13,7 @@ return {
if height >= 80 and width >= 80 then if height >= 80 and width >= 80 then
logo_file = "rootiest.txt" logo_file = "rootiest.txt"
elseif height >= 48 and width >= 48 then elseif height >= 48 and width >= 48 then
logo_file = "nvim.txt" logo_file = "taco.ans"
elseif width >= 100 then elseif width >= 100 then
logo_file = "long.txt" logo_file = "long.txt"
elseif width >= 80 then elseif width >= 80 then
@@ -24,80 +24,76 @@ return {
logo_file = "tiny.txt" logo_file = "tiny.txt"
end end
local logo_content = vim.fn.readfile(logo_path .. logo_file)
local LOGO = "\n\n" .. table.concat(logo_content, "\n") .. "\n\n"
local opts = { local opts = {
theme = "doom", theme = "doom",
hide = { hide = {
statusline = false, statusline = false,
tabline = true, tabline = true,
}, },
-- By default, use ANSI art header
preview = { preview = {
command = "cat", command = "cat",
file_path = logo_path .. "taco.ans", file_path = logo_path .. logo_file,
file_width = 33, file_width = 33,
file_height = 15, file_height = 15,
}, },
config = { config = {
-- header = vim.split(LOGO, "\n"),
center = { center = {
{ { -- Find File
action = "lua LazyVim.pick()()", action = "lua LazyVim.pick()()",
desc = " Find File", desc = " Find File",
icon = "", icon = "",
key = "f", key = "f",
}, },
{ { -- New File
action = "ene | startinsert", action = "ene | startinsert",
desc = " New File", desc = " New File",
icon = "", icon = "",
key = "n", key = "n",
}, },
{ { -- Open Recent Files
action = 'lua LazyVim.pick("oldfiles")()', action = 'lua LazyVim.pick("oldfiles")()',
desc = " Recent Files", desc = " Recent Files",
icon = "", icon = "",
key = "r", key = "r",
}, },
{ { -- Find Text
action = 'lua LazyVim.pick("live_grep")()', action = 'lua LazyVim.pick("live_grep")()',
desc = " Find Text", desc = " Find Text",
icon = "", icon = "",
key = "g", key = "g",
}, },
{ { -- LazyGit
action = "LazyGit", action = "LazyGit",
desc = " LazyGit", desc = " LazyGit",
icon = "", icon = "",
key = "z", key = "z",
}, },
{ { -- Config
action = "lua LazyVim.pick.config_files()()", action = "lua LazyVim.pick.config_files()()",
desc = " Config", desc = " Config",
icon = "", icon = "",
key = "c", key = "c",
}, },
{ { -- Restore Session
action = 'lua require("persistence").load()', action = 'lua require("persistence").load()',
desc = " Restore Session", desc = " Restore Session",
icon = "", icon = "",
key = "s", key = "s",
}, },
{ { -- Remote Session
action = 'lua require("config.rootiest").load_remote()', action = 'lua require("config.rootiest").load_remote()',
desc = " Remote Session", desc = " Remote Session",
icon = "󰢹 ", icon = "󰢹 ",
key = "S", key = "S",
}, },
{ -- Lazy
{
action = "Lazy", action = "Lazy",
desc = " Lazy", desc = " Lazy",
icon = "󰒲 ", icon = "󰒲 ",
key = "l", key = "l",
}, },
{ { -- Quit
action = function() action = function()
vim.api.nvim_input("<cmd>qa<cr>") vim.api.nvim_input("<cmd>qa<cr>")
end, end,
@@ -123,6 +119,14 @@ return {
}, },
} }
-- if logo_file extension is not .ans then read the content and add it to the header
if logo_file:sub(-4) ~= ".ans" then
local logo_content = vim.fn.readfile(logo_path .. logo_file)
local LOGO = "\n\n" .. table.concat(logo_content, "\n") .. "\n\n"
opts.config.header = vim.split(LOGO, "\n")
opts.preview = nil
end
for _, button in ipairs(opts.config.center) do for _, button in ipairs(opts.config.center) do
button.desc = button.desc .. string.rep(" ", 43 - #button.desc) button.desc = button.desc .. string.rep(" ", 43 - #button.desc)
button.key_format = " %s" button.key_format = " %s"