From 3c8814df8a000cd9796f7f09a80fb830112f56f7 Mon Sep 17 00:00:00 2001 From: rootiest Date: Wed, 5 Mar 2025 15:25:33 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Feat(dashboard):=20add=20option=20a?= =?UTF-8?q?nd=20dynamic=20visibility=20for=20github=20contribs=20on=20dash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/config/options.lua | 2 ++ lua/plugins/dashboard/snacks.lua | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lua/config/options.lua b/lua/config/options.lua index 849bd97..4662ac7 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -35,6 +35,8 @@ vim.g.usetinyinline = true ---@type boolean Options: +-- Show GitHub Contributions on dashboard +vim.g.show_github_contrib = true ---@type boolean Options: -- Highlight lines with git changes vim.g.git_line_hl = false ---@type boolean Options: -- Highlight words with git changes diff --git a/lua/plugins/dashboard/snacks.lua b/lua/plugins/dashboard/snacks.lua index 82c65a3..87fb2c9 100644 --- a/lua/plugins/dashboard/snacks.lua +++ b/lua/plugins/dashboard/snacks.lua @@ -4,6 +4,12 @@ local fallback_logo = require('data.dash').fallback_logo +local function get_window_size() + local width = vim.api.nvim_win_get_width(0) + local height = vim.api.nvim_win_get_height(0) + return width, height +end + 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 @@ -67,16 +73,19 @@ local function create_sections(neovide) indent = 60, }) - if not neovide then + if vim.g.show_github_contrib and not neovide then + local w, h = get_window_size() local usrname = vim.g.gitname or 'rootiest' - table.insert(sections, { - section = 'terminal', - cmd = 'kusa ' .. usrname .. ' && sleep 0.2', - padding = { 0, 0 }, - height = 10, - width = 106, - indent = 8, - }) + if w > 130 and h > 30 then + table.insert(sections, { + section = 'terminal', + cmd = 'kusa ' .. usrname .. ' && sleep 0.2', + padding = { 0, 0 }, + height = 10, + width = 106, + indent = 8, + }) + end end return sections