From a3ac43c2cf69d31b45cc92180da9a1e9c4b6b1ee Mon Sep 17 00:00:00 2001 From: rootiest Date: Sat, 23 Nov 2024 14:23:21 -0500 Subject: [PATCH] feat: implement snacks dashboard functionality --- lua/data/dash.lua | 9 ++++ lua/plugins/dashboard/snacks.lua | 75 ++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 lua/plugins/dashboard/snacks.lua diff --git a/lua/data/dash.lua b/lua/data/dash.lua index 8c65c98..f97b240 100644 --- a/lua/data/dash.lua +++ b/lua/data/dash.lua @@ -13,6 +13,15 @@ if vim.g.dash_logo then end M.logo = logofile +M.fallback_logo = [[ +███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ +████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ +██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ +██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ +██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ +╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ +]] + -- Define dashboard button items in a single table local dashboard_buttons = { -- stylua: ignore start diff --git a/lua/plugins/dashboard/snacks.lua b/lua/plugins/dashboard/snacks.lua new file mode 100644 index 0000000..d9ec647 --- /dev/null +++ b/lua/plugins/dashboard/snacks.lua @@ -0,0 +1,75 @@ +-- ╭─────────────────────────────────────────────────────────╮ +-- │ Snacks Dashboard │ +-- ╰─────────────────────────────────────────────────────────╯ + +local fallback_logo = require('data.dash').fallback_logo + +local function read_file(file_path) + local success, content_or_error = pcall(function() + local file = assert(io.open(file_path, 'r')) -- Open the file in read mode + local content = file:read('*a') -- Read the entire file content + file:close() -- Close the file + return content + end) + if not success then + return fallback_logo + end + return content_or_error +end + +return { + { + 'folke/snacks.nvim', + opts = { + dashboard = { + enabled = require('data.func').check_global_var( + 'dashboard', + 'snacks', + 'alpha' + ), + preset = { + keys = require('data.dash').dashboard_nvim.choices, + header = read_file(require('data.dash').logo), + }, + sections = { + -- { section = 'header' }, + { + section = 'terminal', + cmd = 'pokemon-colorscripts -n porygon-z --no-title', + padding = 0, + height = 20, + indent = 44, + }, + { section = 'keys', gap = 1, padding = 1 }, + { + pane = 2, + icon = ' ', + title = 'Recent Files', + section = 'recent_files', + indent = 2, + padding = { 2, 20 }, + }, + { + pane = 2, + icon = ' ', + title = 'Projects', + section = 'projects', + indent = 2, + padding = 2, + }, + { + pane = 2, + icon = ' ', + title = 'Git Status', + section = 'terminal', + enabled = require('data.func').is_git_repo(), + cmd = 'hub status --short --branch --renames', + padding = 2, + indent = 3, + }, + { section = 'startup' }, + }, + }, + }, + }, +}