nvim: better function name: dynamic_color -> colored_when_focused

This commit is contained in:
Fernando Schauenburg 2025-07-01 18:36:17 +02:00
parent 15c9d5c0b0
commit ef15c48f5f
2 changed files with 8 additions and 8 deletions

View file

@ -5,7 +5,7 @@ return {
opts = function() opts = function()
local icons = require("util.icons") local icons = require("util.icons")
local dynamic_color = require("util.lualine").dynamic_color local colored_when_focused = require("util.lualine").colored_when_focused
local indicator = require("util.lualine").indicator local indicator = require("util.lualine").indicator
local window = require("util.window") local window = require("util.window")
local orange = "#d65d0e" local orange = "#d65d0e"
@ -28,7 +28,7 @@ return {
cond = window.is_medium, cond = window.is_medium,
} }
local diagnostics = { local diagnostics = {
dynamic_color("diagnostics"), colored_when_focused("diagnostics"),
cond = is_diagnostics_enabled, cond = is_diagnostics_enabled,
} }
local diag_status = indicator { local diag_status = indicator {
@ -41,7 +41,7 @@ return {
} }
local filename = "custom.filename" local filename = "custom.filename"
local filetype = { local filetype = {
dynamic_color("filetype"), colored_when_focused("filetype"),
cond = window.is_medium, cond = window.is_medium,
} }
local mode = "custom.mode" local mode = "custom.mode"
@ -51,12 +51,12 @@ return {
cond = function() return vim.o.spell end, cond = function() return vim.o.spell end,
} }
local status = { local status = {
dynamic_color("custom.status"), colored_when_focused("custom.status"),
color = { fg = orange }, color = { fg = orange },
padding = 0, padding = 0,
} }
local whitespace = { local whitespace = {
dynamic_color("custom.whitespace"), colored_when_focused("custom.whitespace"),
cond = window.is_wide, cond = window.is_wide,
} }
local wrap = indicator { local wrap = indicator {

View file

@ -3,7 +3,7 @@ local M = {}
---Make a lualine component that is colored only when focused. ---Make a lualine component that is colored only when focused.
---@param base table|string Either a lualine component or a component name. ---@param base table|string Either a lualine component or a component name.
---@return table component ---@return table component
M.dynamic_color = function(base) M.colored_when_focused = function(base)
local component = {} local component = {}
if type(base) == "string" then if type(base) == "string" then
@ -19,14 +19,14 @@ M.dynamic_color = function(base)
self, self,
vim.tbl_deep_extend("keep", options or {}, { vim.tbl_deep_extend("keep", options or {}, {
colored = true, colored = true,
dynamic_color = true, colored_when_focused = true,
}) })
) )
self.saved_highlight = self.options.color_highlight self.saved_highlight = self.options.color_highlight
end end
function component:update_status(is_focused) function component:update_status(is_focused)
if self.options.dynamic_color then self.options.colored = is_focused end if self.options.colored_when_focused then self.options.colored = is_focused end
return component.super.update_status(self, is_focused) return component.super.update_status(self, is_focused)
end end