style: standardize string quotes in highlight.lua

This commit is contained in:
2024-12-11 14:59:40 -05:00
parent 7dc7ec32b9
commit 7931ac4f5d
+95 -95
View File
@@ -7,8 +7,8 @@
local M = {} local M = {}
-- Readability functions -- Readability functions
local get_bg_color = require("data.func").get_bg_color local get_bg_color = require('data.func').get_bg_color
local get_fg_color = require("data.func").get_fg_color local get_fg_color = require('data.func').get_fg_color
local set_hl = vim.api.nvim_set_hl local set_hl = vim.api.nvim_set_hl
local sign_def = vim.fn.sign_define local sign_def = vim.fn.sign_define
@@ -18,23 +18,23 @@ local sign_def = vim.fn.sign_define
function M.apply_todo_highlights(status_string) function M.apply_todo_highlights(status_string)
-- Define patterns and associated highlight groups -- Define patterns and associated highlight groups
local patterns = { local patterns = {
{ icon = "", hl = "lualine_c_diagnostics_info_normal" }, { icon = '', hl = 'lualine_c_diagnostics_info_normal' },
{ icon = "", hl = "lualine_c_diagnostics_warning_normal" }, { icon = '', hl = 'lualine_c_diagnostics_warning_normal' },
{ icon = "", hl = "lualine_c_diagnostics_warning_normal" }, { icon = '', hl = 'lualine_c_diagnostics_warning_normal' },
{ icon = "", hl = "lualine_c_diagnostics_hint_normal" }, { icon = '', hl = 'lualine_c_diagnostics_hint_normal' },
{ icon = "", hl = "lualine_c_diagnostics_hint_normal" }, { icon = '', hl = 'lualine_c_diagnostics_hint_normal' },
} }
-- Apply the highlights -- Apply the highlights
for _, pattern in ipairs(patterns) do for _, pattern in ipairs(patterns) do
status_string = status_string:gsub( status_string = status_string:gsub(
vim.pesc(pattern.icon), vim.pesc(pattern.icon),
"%#" .. pattern.hl .. "#" .. pattern.icon '%#' .. pattern.hl .. '#' .. pattern.icon
) )
end end
-- Reset highlight to normal after the string -- Reset highlight to normal after the string
status_string = status_string .. "%#LualineNormal#" status_string = status_string .. '%#LualineNormal#'
return status_string return status_string
end end
@@ -42,13 +42,13 @@ end
function M.setup_minimap_highlight() function M.setup_minimap_highlight()
vim.api.nvim_set_hl( vim.api.nvim_set_hl(
0, 0,
"NeominimapSearchIcon", 'NeominimapSearchIcon',
{ link = "NeominimapErrorSign" } { link = 'NeominimapErrorSign' }
) )
vim.api.nvim_set_hl( vim.api.nvim_set_hl(
0, 0,
"NeominimapSearchLine", 'NeominimapSearchLine',
{ link = "NeominimapErrorLine" } { link = 'NeominimapErrorLine' }
) )
end end
@@ -56,27 +56,27 @@ end
---@return nil ---@return nil
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 = get_bg_color("CursorLine") local cursorline_bg_hex = get_bg_color('CursorLine') or '#1d1d2d'
-- Get the foreground color of Error -- Get the foreground color of Error
local miniiconsred_fg_hex = get_fg_color("Error") local miniiconsred_fg_hex = get_fg_color('Error') or '#ff5555'
-- Load the ibl plugin -- Load the ibl plugin
if pcall(require, "ibl") then if pcall(require, 'ibl') then
-- Load the ibl plugin hooks -- Load the ibl plugin hooks
local hooks = require("ibl.hooks") local hooks = require('ibl.hooks')
-- create the highlight groups in the highlight setup hook -- create the highlight groups in the highlight setup hook
if cursorline_bg_hex then if cursorline_bg_hex then
-- Define custom highlight groups for indent -- Define custom highlight groups for indent
hooks.register(hooks.type.HIGHLIGHT_SETUP, function() hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
set_hl( set_hl(
0, 0,
"IndentBlanklineIndent", 'IndentBlanklineIndent',
{ fg = cursorline_bg_hex, nocombine = true } { fg = cursorline_bg_hex, nocombine = true }
) )
set_hl( set_hl(
0, 0,
"IndentsScopeHighlight", 'IndentsScopeHighlight',
{ fg = miniiconsred_fg_hex, nocombine = true } { fg = miniiconsred_fg_hex, nocombine = true }
) )
end) end)
@@ -87,65 +87,65 @@ function M.setup_indent_highlight()
if vim.g.tab_char then if vim.g.tab_char then
tab_char = vim.g.tab_char tab_char = vim.g.tab_char
elseif vim.g.tab_char_name then elseif vim.g.tab_char_name then
tab_char = require("data.types").ibl.char[vim.g.tab_char_name] tab_char = require('data.types').ibl.char[vim.g.tab_char_name]
else else
tab_char = require("data.types").ibl.char.none tab_char = require('data.types').ibl.char.none
end end
if vim.g.indent_char then if vim.g.indent_char then
indent_char = vim.g.indent_char indent_char = vim.g.indent_char
elseif vim.g.indent_char_name then elseif vim.g.indent_char_name then
indent_char = require("data.types").ibl.char[vim.g.indent_char_name] indent_char = require('data.types').ibl.char[vim.g.indent_char_name]
else else
indent_char = require("data.types").ibl.char.none indent_char = require('data.types').ibl.char.none
end end
-- Configure the indent-blankline plugin -- Configure the indent-blankline plugin
require("ibl").setup({ require('ibl').setup({
indent = { indent = {
char = indent_char, char = indent_char,
tab_char = tab_char, tab_char = tab_char,
highlight = { highlight = {
"IndentBlanklineIndent", 'IndentBlanklineIndent',
}, },
}, },
scope = { scope = {
enabled = false, enabled = false,
}, },
exclude = { exclude = {
filetypes = require("data.types").highlights.exclude, filetypes = require('data.types').highlights.exclude,
}, },
}) })
end end
-- Configure the deadcolumn plugin -- Configure the deadcolumn plugin
if pcall(require, "deadcolumn") then if pcall(require, 'deadcolumn') then
require("deadcolumn").setup({ require('deadcolumn').setup({
scope = "line", ---@type string|fun(): integer scope = 'line', ---@type string|fun(): integer
modes = function(mode) modes = function(mode)
return mode:find("^[ictRss\x13]") ~= nil return mode:find('^[ictRss\x13]') ~= nil
end, end,
blending = { blending = {
threshold = 0.9, threshold = 0.9,
colorcode = cursorline_bg_hex, colorcode = cursorline_bg_hex,
hlgroup = { "Normal", "bg" }, hlgroup = { 'Normal', 'bg' },
}, },
warning = { warning = {
alpha = 0.4, alpha = 0.4,
offset = 0, offset = 0,
colorcode = miniiconsred_fg_hex, colorcode = miniiconsred_fg_hex,
hlgroup = { "Error", "bg" }, hlgroup = { 'Error', 'bg' },
}, },
extra = { extra = {
follow_tw = "80", follow_tw = '80',
}, },
}) })
end end
-- Set NeoCodeium suggestion highlight -- Set NeoCodeium suggestion highlight
vim.api.nvim_set_hl(0, "NeoCodeiumSuggestion", { link = "Comment" }) vim.api.nvim_set_hl(0, 'NeoCodeiumSuggestion', { link = 'Comment' })
-- Set NeoCodeium label highlight -- Set NeoCodeium label highlight
vim.api.nvim_set_hl(0, "NeoCodeiumLabel", { link = "lualine_a_insert" }) vim.api.nvim_set_hl(0, 'NeoCodeiumLabel', { link = 'lualine_a_insert' })
end end
--- Function to set up smooth cursor mode highlights --- Function to set up smooth cursor mode highlights
@@ -153,38 +153,38 @@ 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 -- Define bg_color variable local bg_color -- Define bg_color variable
if current_mode == "n" then if current_mode == 'n' then
bg_color = get_bg_color("MiniStatuslineModeNormal") bg_color = get_bg_color('MiniStatuslineModeNormal')
set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, 'SmoothCursor', { fg = bg_color })
sign_def("smoothcursor", { text = "" }) sign_def('smoothcursor', { text = '' })
elseif current_mode == "v" then elseif current_mode == 'v' then
bg_color = get_bg_color("MiniStatuslineModeVisual") bg_color = get_bg_color('MiniStatuslineModeVisual')
set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, 'SmoothCursor', { fg = bg_color })
sign_def("smoothcursor", { text = "" }) sign_def('smoothcursor', { text = '' })
elseif current_mode == "V" then elseif current_mode == 'V' then
bg_color = get_bg_color("MiniStatuslineModeVisual") bg_color = get_bg_color('MiniStatuslineModeVisual')
set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, 'SmoothCursor', { fg = bg_color })
sign_def("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 = get_bg_color("MiniStatuslineModeReplace") bg_color = get_bg_color('MiniStatuslineModeReplace')
set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, 'SmoothCursor', { fg = bg_color })
sign_def("smoothcursor", { text = "" }) sign_def('smoothcursor', { text = '' })
elseif current_mode == "i" then elseif current_mode == 'i' then
bg_color = get_bg_color("MiniStatuslineModeInsert") bg_color = get_bg_color('MiniStatuslineModeInsert')
set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, 'SmoothCursor', { fg = bg_color })
sign_def("smoothcursor", { text = "" }) sign_def('smoothcursor', { text = '' })
else else
bg_color = get_bg_color("MiniStatuslineModeNormal") bg_color = get_bg_color('MiniStatuslineModeNormal')
set_hl(0, "SmoothCursor", { fg = bg_color }) set_hl(0, 'SmoothCursor', { fg = bg_color })
sign_def("smoothcursor", { text = "" }) sign_def('smoothcursor', { text = '' })
end end
-- Define the custom highlight outside the function -- Define the custom highlight outside the function
local vis_bg_color = get_bg_color("CursorLineNr") local vis_bg_color = get_bg_color('CursorLineNr')
local vis_fg_color = get_bg_color("lualine_a_visual") local vis_fg_color = get_bg_color('lualine_a_visual')
vim.api.nvim_set_hl( vim.api.nvim_set_hl(
0, 0,
"StatusColumnVisualHighlight", 'StatusColumnVisualHighlight',
{ fg = vis_fg_color, bg = vis_bg_color } { fg = vis_fg_color, bg = vis_bg_color }
) )
end end
@@ -193,55 +193,55 @@ end
---@return nil ---@return nil
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 = get_fg_color("Error") local dash_color = get_fg_color('Error')
set_hl(0, "DashboardHeader", { fg = dash_color }) set_hl(0, 'DashboardHeader', { fg = dash_color })
else else
set_hl(0, "DashboardHeader", { fg = vim.g.DashboardHeaderColor }) set_hl(0, 'DashboardHeader', { fg = vim.g.DashboardHeaderColor })
end end
end end
--- Function to set up transparency of the editor --- Function to set up transparency of the editor
---@return nil ---@return nil
function M.setup_transparency() function M.setup_transparency()
if require("data.func").is_kitty() and not vim.g.disable_transparency then if require('data.func').is_kitty() and not vim.g.disable_transparency then
vim.cmd("TransparentEnable") vim.cmd('TransparentEnable')
else else
vim.cmd("TransparentDisable") vim.cmd('TransparentDisable')
end end
end end
function M.setup_avante_highlights() function M.setup_avante_highlights()
-- Apply highlights for title -- Apply highlights for title
set_hl(0, "AvanteTitle", { link = "lualine_a_command" }) set_hl(0, 'AvanteTitle', { link = 'lualine_a_command' })
set_hl(0, "AvanteReversedTitle", { set_hl(0, 'AvanteReversedTitle', {
bg = get_bg_color("Normal"), bg = get_bg_color('Normal'),
fg = get_bg_color("lualine_a_command"), fg = get_bg_color('lualine_a_command'),
}) })
-- Apply highlights for subtitle -- Apply highlights for subtitle
set_hl(0, "AvanteSubtitle", { link = "lualine_a_replace" }) set_hl(0, 'AvanteSubtitle', { link = 'lualine_a_replace' })
set_hl(0, "AvanteReversedSubtitle", { set_hl(0, 'AvanteReversedSubtitle', {
bg = get_bg_color("Normal"), bg = get_bg_color('Normal'),
fg = get_bg_color("lualine_a_replace"), fg = get_bg_color('lualine_a_replace'),
}) })
-- Apply highlights for prompt -- Apply highlights for prompt
set_hl(0, "AvanteThirdTitle", { link = "lualine_a_insert" }) set_hl(0, 'AvanteThirdTitle', { link = 'lualine_a_insert' })
set_hl(0, "AvanteReversedThirdTitle", { set_hl(0, 'AvanteReversedThirdTitle', {
bg = get_bg_color("Normal"), bg = get_bg_color('Normal'),
fg = get_bg_color("lualine_a_insert"), fg = get_bg_color('lualine_a_insert'),
}) })
-- Apply highlights for hints -- Apply highlights for hints
set_hl(0, "AvanteInlineHint", { link = "LspDiagnosticsVirtualTextHint" }) set_hl(0, 'AvanteInlineHint', { link = 'LspDiagnosticsVirtualTextHint' })
set_hl(0, "AvantePopupHint", { link = "DiagnosticVirtualTextHint" }) set_hl(0, 'AvantePopupHint', { link = 'DiagnosticVirtualTextHint' })
end end
function M.setup_multi_cursor_highlight() function M.setup_multi_cursor_highlight()
-- Customize how cursors look. -- Customize how cursors look.
vim.api.nvim_set_hl(0, "MultiCursorCursor", { link = "Cursor" }) vim.api.nvim_set_hl(0, 'MultiCursorCursor', { link = 'Cursor' })
vim.api.nvim_set_hl(0, "MultiCursorVisual", { link = "Visual" }) vim.api.nvim_set_hl(0, 'MultiCursorVisual', { link = 'Visual' })
vim.api.nvim_set_hl(0, "MultiCursorSign", { link = "GitSignsAdd" }) vim.api.nvim_set_hl(0, 'MultiCursorSign', { link = 'GitSignsAdd' })
vim.api.nvim_set_hl(0, "MultiCursorDisabledCursor", { link = "Visual" }) vim.api.nvim_set_hl(0, 'MultiCursorDisabledCursor', { link = 'Visual' })
vim.api.nvim_set_hl(0, "MultiCursorDisabledVisual", { link = "Visual" }) vim.api.nvim_set_hl(0, 'MultiCursorDisabledVisual', { link = 'Visual' })
vim.api.nvim_set_hl(0, "MultiCursorDisabledSign", { link = "SignColumn" }) vim.api.nvim_set_hl(0, 'MultiCursorDisabledSign', { link = 'SignColumn' })
end end
--- Function to set up autocommands --- Function to set up autocommands
@@ -251,12 +251,12 @@ function M.setup_autocommands()
local autocmd = vim.api.nvim_create_autocmd local autocmd = vim.api.nvim_create_autocmd
-- List of filetypes to exclude -- List of filetypes to exclude
local excluded_filetypes = require("data.types").highlights.exclude local excluded_filetypes = require('data.types').highlights.exclude
-- Create a new augroup for the IndentHighlight -- Create a new augroup for the IndentHighlight
local IndentGroup = autogrp("IndentHighlight", { clear = true }) local IndentGroup = autogrp('IndentHighlight', { clear = true })
-- Autocommand to trigger setup on FileType -- Autocommand to trigger setup on FileType
autocmd("FileType", { autocmd('FileType', {
group = IndentGroup, group = IndentGroup,
callback = function() callback = function()
local filetype = vim.bo.filetype local filetype = vim.bo.filetype
@@ -266,8 +266,8 @@ function M.setup_autocommands()
M.setup_avante_highlights() M.setup_avante_highlights()
M.setup_multi_cursor_highlight() M.setup_multi_cursor_highlight()
else else
if pcall(require, "auto-cursorline") then if pcall(require, 'auto-cursorline') then
require("auto-cursorline").disable({ require('auto-cursorline').disable({
buffer = true, buffer = true,
}) })
end end
@@ -276,10 +276,10 @@ function M.setup_autocommands()
}) })
-- Create a new augroup for the dashboard -- Create a new augroup for the dashboard
local dashboardGroup = autogrp("DashboardColors", { clear = true }) local dashboardGroup = autogrp('DashboardColors', { clear = true })
-- Autocommand to trigger setup on FileType -- Autocommand to trigger setup on FileType
autocmd("FileType", { autocmd('FileType', {
pattern = "*", pattern = '*',
group = dashboardGroup, group = dashboardGroup,
callback = function() callback = function()
M.setup_dashboard_highlight() M.setup_dashboard_highlight()