♻️ refactor(rootilities): rooticolor -> rootilities
Rename rooticolor as it now includes more general utilities
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
-- ╰─────────────────────────────────────────────────────────╯
|
-- ╰─────────────────────────────────────────────────────────╯
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local rooticolor = require("utils.rooticolor")
|
local rootilities = require("utils.rootilities")
|
||||||
|
|
||||||
local precog_first_time = true
|
local precog_first_time = true
|
||||||
|
|
||||||
@@ -78,27 +78,27 @@ function M.set_cursor_icons()
|
|||||||
local bg_color
|
local bg_color
|
||||||
|
|
||||||
if current_mode == "n" then
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "v" then
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "V" then
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "R" or current_mode == "r" then
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "i" then
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
else
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
-- │ Utilities │
|
-- │ Utilities │
|
||||||
-- ╰─────────────────────────────────────────────────────────╯
|
-- ╰─────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
local rooticolor = require("utils.rooticolor")
|
local rootilities = require("utils.rootilities")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{ -- Chezmoi
|
{ -- Chezmoi
|
||||||
@@ -265,11 +265,17 @@ return {
|
|||||||
-- Get the current lualine configuration
|
-- Get the current lualine configuration
|
||||||
local config = require("lualine").get_config()
|
local config = require("lualine").get_config()
|
||||||
local git_blame = require("gitblame")
|
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
|
-- Add Git-blame to lualine_c section
|
||||||
table.insert(config.sections.lualine_c, {
|
table.insert(config.sections.lualine_c, {
|
||||||
git_blame.get_current_blame_text,
|
git_blame.get_current_blame_text,
|
||||||
cond = git_blame.is_blame_text_available,
|
cond = function()
|
||||||
color = { fg = rooticolor.get_fg_color("GitSignsCurrentLineBlame") },
|
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
|
-- Apply the new configuration
|
||||||
|
|||||||
+10
-10
@@ -3,15 +3,15 @@
|
|||||||
-- ╰─────────────────────────────────────────────────────────╯
|
-- ╰─────────────────────────────────────────────────────────╯
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local rooticolor = require("utils.rooticolor")
|
local rootilities = require("utils.rootilities")
|
||||||
|
|
||||||
-- Function to set up indent highlights
|
-- Function to set up indent highlights
|
||||||
function M.setup_indent_highlight()
|
function M.setup_indent_highlight()
|
||||||
-- Get the background color of CursorLine
|
-- 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
|
-- 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")
|
local hooks = require("ibl.hooks")
|
||||||
-- create the highlight groups in the highlight setup hook, so they are reset
|
-- 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
|
local bg_color
|
||||||
|
|
||||||
if current_mode == "n" then
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "v" then
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "V" then
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "R" or current_mode == "r" then
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "i" then
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
else
|
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.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
end
|
end
|
||||||
@@ -138,7 +138,7 @@ end
|
|||||||
|
|
||||||
function M.setup_dashboard_highlight()
|
function M.setup_dashboard_highlight()
|
||||||
if not vim.g.DashboardHeaderColor then
|
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 })
|
vim.api.nvim_set_hl(0, "DashboardHeader", { fg = dash_color })
|
||||||
else
|
else
|
||||||
vim.api.nvim_set_hl(
|
vim.api.nvim_set_hl(
|
||||||
|
|||||||
@@ -34,4 +34,11 @@ function M.get_bg_color(hlgroup)
|
|||||||
return nil
|
return nil
|
||||||
end
|
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
|
return M
|
||||||
Reference in New Issue
Block a user