From 57c85a871fef62189bd05a3d4476b9913ad7d38d Mon Sep 17 00:00:00 2001 From: rootiest Date: Fri, 9 Aug 2024 05:32:08 -0400 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20refactor(rootilities):?= =?UTF-8?q?=20rooticolor=20->=20rootilities?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename rooticolor as it now includes more general utilities --- lua/config/rootiest.lua | 14 ++++++------- lua/plugins/util.lua | 12 ++++++++--- lua/utils/highlight.lua | 20 +++++++++---------- lua/utils/{rooticolor.lua => rootilities.lua} | 7 +++++++ 4 files changed, 33 insertions(+), 20 deletions(-) rename lua/utils/{rooticolor.lua => rootilities.lua} (79%) diff --git a/lua/config/rootiest.lua b/lua/config/rootiest.lua index 6700fe5..43361de 100644 --- a/lua/config/rootiest.lua +++ b/lua/config/rootiest.lua @@ -3,7 +3,7 @@ -- ╰─────────────────────────────────────────────────────────╯ local M = {} -local rooticolor = require("utils.rooticolor") +local rootilities = require("utils.rootilities") local precog_first_time = true @@ -78,27 +78,27 @@ function M.set_cursor_icons() local bg_color if current_mode == "n" then - bg_color = rooticolor.get_bg_color("MiniStatuslineModeNormal") + bg_color = rootilities.get_bg_color("MiniStatuslineModeNormal") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) elseif current_mode == "v" then - bg_color = rooticolor.get_bg_color("MiniStatuslineModeVisual") + bg_color = rootilities.get_bg_color("MiniStatuslineModeVisual") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) elseif current_mode == "V" then - bg_color = rooticolor.get_bg_color("MiniStatuslineModeVisual") + bg_color = rootilities.get_bg_color("MiniStatuslineModeVisual") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) elseif current_mode == "R" or current_mode == "r" then - bg_color = rooticolor.get_bg_color("MiniStatuslineModeReplace") + bg_color = rootilities.get_bg_color("MiniStatuslineModeReplace") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) elseif current_mode == "i" then - bg_color = rooticolor.get_bg_color("MiniStatuslineModeInsert") + bg_color = rootilities.get_bg_color("MiniStatuslineModeInsert") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) else - bg_color = rooticolor.get_bg_color("MiniStatuslineModeNormal") + bg_color = rootilities.get_bg_color("MiniStatuslineModeNormal") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) end diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua index 89a7a34..04b34d6 100644 --- a/lua/plugins/util.lua +++ b/lua/plugins/util.lua @@ -2,7 +2,7 @@ -- │ Utilities │ -- ╰─────────────────────────────────────────────────────────╯ -local rooticolor = require("utils.rooticolor") +local rootilities = require("utils.rootilities") return { { -- Chezmoi @@ -265,11 +265,17 @@ return { -- Get the current lualine configuration local config = require("lualine").get_config() local git_blame = require("gitblame") + -- Define the width limit for displaying the Git blame component + local width_limit = 180 -- Adjust this value as needed + -- Add Git-blame to lualine_c section table.insert(config.sections.lualine_c, { git_blame.get_current_blame_text, - cond = git_blame.is_blame_text_available, - color = { fg = rooticolor.get_fg_color("GitSignsCurrentLineBlame") }, + cond = function() + return git_blame.is_blame_text_available() + and rootilities.is_window_wide_enough(width_limit) + end, + color = { fg = rootilities.get_fg_color("GitSignsCurrentLineBlame") }, }) -- Apply the new configuration diff --git a/lua/utils/highlight.lua b/lua/utils/highlight.lua index cfb64f9..f7bbd0b 100644 --- a/lua/utils/highlight.lua +++ b/lua/utils/highlight.lua @@ -3,15 +3,15 @@ -- ╰─────────────────────────────────────────────────────────╯ local M = {} -local rooticolor = require("utils.rooticolor") +local rootilities = require("utils.rootilities") -- Function to set up indent highlights function M.setup_indent_highlight() -- Get the background color of CursorLine - local cursorline_bg_hex = rooticolor.get_bg_color("CursorLine") + local cursorline_bg_hex = rootilities.get_bg_color("CursorLine") -- Get the foreground color of Error - local miniiconsred_fg_hex = rooticolor.get_fg_color("Error") + local miniiconsred_fg_hex = rootilities.get_fg_color("Error") local hooks = require("ibl.hooks") -- create the highlight groups in the highlight setup hook, so they are reset @@ -110,27 +110,27 @@ function M.setup_mode_highlight() local bg_color if current_mode == "n" then - bg_color = rooticolor.get_bg_color("MiniStatuslineModeNormal") + bg_color = rootilities.get_bg_color("MiniStatuslineModeNormal") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) elseif current_mode == "v" then - bg_color = rooticolor.get_bg_color("MiniStatuslineModeVisual") + bg_color = rootilities.get_bg_color("MiniStatuslineModeVisual") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) elseif current_mode == "V" then - bg_color = rooticolor.get_bg_color("MiniStatuslineModeVisual") + bg_color = rootilities.get_bg_color("MiniStatuslineModeVisual") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) elseif current_mode == "R" or current_mode == "r" then - bg_color = rooticolor.get_bg_color("MiniStatuslineModeReplace") + bg_color = rootilities.get_bg_color("MiniStatuslineModeReplace") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) elseif current_mode == "i" then - bg_color = rooticolor.get_bg_color("MiniStatuslineModeInsert") + bg_color = rootilities.get_bg_color("MiniStatuslineModeInsert") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) else - bg_color = rooticolor.get_bg_color("MiniStatuslineModeNormal") + bg_color = rootilities.get_bg_color("MiniStatuslineModeNormal") vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) vim.fn.sign_define("smoothcursor", { text = "" }) end @@ -138,7 +138,7 @@ end function M.setup_dashboard_highlight() if not vim.g.DashboardHeaderColor then - local dash_color = rooticolor.get_fg_color("Error") + local dash_color = rootilities.get_fg_color("Error") vim.api.nvim_set_hl(0, "DashboardHeader", { fg = dash_color }) else vim.api.nvim_set_hl( diff --git a/lua/utils/rooticolor.lua b/lua/utils/rootilities.lua similarity index 79% rename from lua/utils/rooticolor.lua rename to lua/utils/rootilities.lua index 882fea8..4ed63ad 100644 --- a/lua/utils/rooticolor.lua +++ b/lua/utils/rootilities.lua @@ -34,4 +34,11 @@ function M.get_bg_color(hlgroup) return nil end +function M.is_window_wide_enough(width_limit) + -- Get the current width of the Neovim window + local width = vim.fn.winwidth(0) + -- Return true if width is greater than or equal to width_limit + return width >= width_limit +end + return M