From 6e47d1a8c57cea74c8fcdc5c9c2a887aa992eb65 Mon Sep 17 00:00:00 2001 From: rootiest Date: Wed, 7 Aug 2024 19:55:34 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(dashboard):=20allow=20for=20an?= =?UTF-8?q?si=20in=20dashboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows the dashboard to properly detect and display ANSI files --- lua/plugins/dashboard.lua | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua index f3dbaf3..ac0a30b 100644 --- a/lua/plugins/dashboard.lua +++ b/lua/plugins/dashboard.lua @@ -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("qa") 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"