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
logo_file = "rootiest.txt"
elseif height >= 48 and width >= 48 then
logo_file = "nvim.txt"
logo_file = "taco.ans"
elseif width >= 100 then
logo_file = "long.txt"
elseif width >= 80 then
@@ -24,80 +24,76 @@ return {
logo_file = "tiny.txt"
end
local logo_content = vim.fn.readfile(logo_path .. logo_file)
local LOGO = "\n\n" .. table.concat(logo_content, "\n") .. "\n\n"
local opts = {
theme = "doom",
hide = {
statusline = false,
tabline = true,
},
-- By default, use ANSI art header
preview = {
command = "cat",
file_path = logo_path .. "taco.ans",
file_path = logo_path .. logo_file,
file_width = 33,
file_height = 15,
},
config = {
-- header = vim.split(LOGO, "\n"),
center = {
{
{ -- Find File
action = "lua LazyVim.pick()()",
desc = " Find File",
icon = "",
key = "f",
},
{
{ -- New File
action = "ene | startinsert",
desc = " New File",
icon = "",
key = "n",
},
{
{ -- Open Recent Files
action = 'lua LazyVim.pick("oldfiles")()',
desc = " Recent Files",
icon = "",
key = "r",
},
{
{ -- Find Text
action = 'lua LazyVim.pick("live_grep")()',
desc = " Find Text",
icon = "",
key = "g",
},
{
{ -- LazyGit
action = "LazyGit",
desc = " LazyGit",
icon = "",
key = "z",
},
{
{ -- Config
action = "lua LazyVim.pick.config_files()()",
desc = " Config",
icon = "",
key = "c",
},
{
{ -- Restore Session
action = 'lua require("persistence").load()',
desc = " Restore Session",
icon = "",
key = "s",
},
{
{ -- Remote Session
action = 'lua require("config.rootiest").load_remote()',
desc = " Remote Session",
icon = "󰢹 ",
key = "S",
},
{
{ -- Lazy
action = "Lazy",
desc = " Lazy",
icon = "󰒲 ",
key = "l",
},
{
{ -- Quit
action = function()
vim.api.nvim_input("<cmd>qa<cr>")
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
button.desc = button.desc .. string.rep(" ", 43 - #button.desc)
button.key_format = " %s"