♻️ refactor(rootilities): utils.rootilities -> utils.rootiest

Rename the rootilities module to make it less wordy
This commit is contained in:
2024-08-17 00:43:49 -04:00
parent 82cc6d8757
commit 349f80f7ea
5 changed files with 52 additions and 41 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local M = {} local M = {}
local rootilities = require("utils.rootilities") local rootilities = require("utils.rootiest")
local precog_first_time = true local precog_first_time = true
@@ -53,7 +53,7 @@ function M.toggle_lazygit_term()
cmd = "lazygit", cmd = "lazygit",
hidden = true, hidden = true,
direction = "horizontal", -- Set direction to horizontal split direction = "horizontal", -- Set direction to horizontal split
size = 0.5, -- Set size to 50% of the screen size = 0.8, -- Set size to 80% of the screen
}) })
lazygit:toggle() lazygit:toggle()
else else
+1 -1
View File
@@ -2,7 +2,7 @@
-- │ Lualine │ -- │ Lualine │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local rootilities = require("utils.rootilities") local rootilities = require("utils.rootiest")
return { return {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
+44 -37
View File
@@ -3,15 +3,21 @@
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local M = {} local M = {}
local rootilities = require("utils.rootilities") -- Load utils
local rootilities = require("utils.rootiest")
-- Readability functions
local get_bg_color = rootilities.get_bg_color
local get_fg_color = rootilities.get_fg_color
local set_hl = vim.api.nvim_set_hl
local sign_def = vim.fn.sign_define
-- 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 = rootilities.get_bg_color("CursorLine") local cursorline_bg_hex = get_bg_color("CursorLine")
-- Get the foreground color of Error -- Get the foreground color of Error
local miniiconsred_fg_hex = rootilities.get_fg_color("Error") local miniiconsred_fg_hex = 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
@@ -19,12 +25,12 @@ function M.setup_indent_highlight()
if cursorline_bg_hex then if cursorline_bg_hex then
-- Define custom highlight groups for indent using the CursorLine background color -- Define custom highlight groups for indent using the CursorLine background color
hooks.register(hooks.type.HIGHLIGHT_SETUP, function() hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
vim.api.nvim_set_hl( set_hl(
0, 0,
"IndentBlanklineIndent", "IndentBlanklineIndent",
{ fg = cursorline_bg_hex, nocombine = true } { fg = cursorline_bg_hex, nocombine = true }
) )
vim.api.nvim_set_hl( set_hl(
0, 0,
"IndentsScopeHighlight", "IndentsScopeHighlight",
{ fg = miniiconsred_fg_hex, nocombine = true } { fg = miniiconsred_fg_hex, nocombine = true }
@@ -107,45 +113,41 @@ end
function M.setup_mode_highlight() function M.setup_mode_highlight()
local current_mode = vim.fn.mode() local current_mode = vim.fn.mode()
local bg_color local bg_color -- Define bg_color variable
if current_mode == "n" then if current_mode == "n" then
bg_color = rootilities.get_bg_color("MiniStatuslineModeNormal") bg_color = get_bg_color("MiniStatuslineModeNormal")
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, "SmoothCursor", { fg = bg_color })
vim.fn.sign_define("smoothcursor", { text = "" }) sign_def("smoothcursor", { text = "" })
elseif current_mode == "v" then elseif current_mode == "v" then
bg_color = rootilities.get_bg_color("MiniStatuslineModeVisual") bg_color = get_bg_color("MiniStatuslineModeVisual")
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, "SmoothCursor", { fg = bg_color })
vim.fn.sign_define("smoothcursor", { text = "" }) sign_def("smoothcursor", { text = "" })
elseif current_mode == "V" then elseif current_mode == "V" then
bg_color = rootilities.get_bg_color("MiniStatuslineModeVisual") bg_color = get_bg_color("MiniStatuslineModeVisual")
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, "SmoothCursor", { fg = bg_color })
vim.fn.sign_define("smoothcursor", { text = "" }) sign_def("smoothcursor", { text = "" })
elseif current_mode == "R" or current_mode == "r" then elseif current_mode == "R" or current_mode == "r" then
bg_color = rootilities.get_bg_color("MiniStatuslineModeReplace") bg_color = get_bg_color("MiniStatuslineModeReplace")
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, "SmoothCursor", { fg = bg_color })
vim.fn.sign_define("smoothcursor", { text = "" }) sign_def("smoothcursor", { text = "" })
elseif current_mode == "i" then elseif current_mode == "i" then
bg_color = rootilities.get_bg_color("MiniStatuslineModeInsert") bg_color = get_bg_color("MiniStatuslineModeInsert")
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, "SmoothCursor", { fg = bg_color })
vim.fn.sign_define("smoothcursor", { text = "" }) sign_def("smoothcursor", { text = "" })
else else
bg_color = rootilities.get_bg_color("MiniStatuslineModeNormal") bg_color = get_bg_color("MiniStatuslineModeNormal")
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, "SmoothCursor", { fg = bg_color })
vim.fn.sign_define("smoothcursor", { text = "" }) sign_def("smoothcursor", { text = "" })
end end
end 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 = rootilities.get_fg_color("Error") local dash_color = get_fg_color("Error")
vim.api.nvim_set_hl(0, "DashboardHeader", { fg = dash_color }) set_hl(0, "DashboardHeader", { fg = dash_color })
else else
vim.api.nvim_set_hl( set_hl(0, "DashboardHeader", { fg = vim.g.DashboardHeaderColor })
0,
"DashboardHeader",
{ fg = vim.g.DashboardHeaderColor }
)
end end
end end
@@ -153,7 +155,6 @@ end
function M.setup_autocommands() function M.setup_autocommands()
local autogrp = vim.api.nvim_create_augroup local autogrp = vim.api.nvim_create_augroup
local autocmd = vim.api.nvim_create_autocmd local autocmd = vim.api.nvim_create_autocmd
autogrp("IndentHighlight", { clear = true })
-- List of filetypes to exclude -- List of filetypes to exclude
local excluded_filetypes = { local excluded_filetypes = {
@@ -170,9 +171,11 @@ function M.setup_autocommands()
"lazyterm", "lazyterm",
} }
-- Create a new augroup for the IndentHighlight
local IndentGroup = autogrp("IndentHighlight", { clear = true })
-- Autocommand to trigger setup on FileType -- Autocommand to trigger setup on FileType
autocmd("FileType", { autocmd("FileType", {
group = "IndentHighlight", group = IndentGroup,
callback = function() callback = function()
local filetype = vim.bo.filetype local filetype = vim.bo.filetype
if not vim.tbl_contains(excluded_filetypes, filetype) then if not vim.tbl_contains(excluded_filetypes, filetype) then
@@ -180,11 +183,10 @@ function M.setup_autocommands()
end end
end, end,
}) })
-- Autocommand to trigger setup on ColorScheme -- Autocommand to trigger setup on ColorScheme
autocmd("ColorScheme", { autocmd("ColorScheme", {
pattern = "*", pattern = "*",
group = "IndentHighlight", group = IndentGroup,
callback = function() callback = function()
M.setup_indent_highlight() M.setup_indent_highlight()
end, end,
@@ -216,8 +218,12 @@ function M.setup_autocommands()
M.setup_dashboard_highlight() M.setup_dashboard_highlight()
end, end,
}) })
-- Create a new augroup for the terminal background
local terminalGroup = autogrp("TerminalColors", { clear = true })
-- Match neovim and terminal background colors -- Match neovim and terminal background colors
vim.api.nvim_create_autocmd({ "UIEnter", "ColorScheme" }, { autocmd({ "UIEnter", "ColorScheme" }, {
group = terminalGroup,
callback = function() callback = function()
local normal = vim.api.nvim_get_hl(0, { name = "Normal" }) local normal = vim.api.nvim_get_hl(0, { name = "Normal" })
if not normal.bg then if not normal.bg then
@@ -226,7 +232,8 @@ function M.setup_autocommands()
io.write(string.format("\027]11;#%06x\027\\", normal.bg)) io.write(string.format("\027]11;#%06x\027\\", normal.bg))
end, end,
}) })
vim.api.nvim_create_autocmd("UILeave", { autocmd("UILeave", {
group = terminalGroup,
callback = function() callback = function()
io.write("\027]111\027\\") io.write("\027]111\027\\")
end, end,
@@ -41,4 +41,8 @@ function M.is_window_wide_enough(width_limit)
return width >= width_limit return width >= width_limit
end end
function M.get_date()
return os.date("%Y-%m-%d")
end
return M return M
+1 -1
View File
@@ -78,7 +78,7 @@ end
function M.get_color() function M.get_color()
local total_minutes = M.get_total_minutes() local total_minutes = M.get_total_minutes()
local rootilities = require("utils.rootilities") -- Adjust according to your actual setup local rootilities = require("utils.rootiest") -- Adjust according to your actual setup
if total_minutes >= 60 then if total_minutes >= 60 then
return { fg = rootilities.get_fg_color("GitSignsAdd") } return { fg = rootilities.get_fg_color("GitSignsAdd") }