feat: add custom color support for icons
This commit is contained in:
parent
37a314b9e3
commit
32c85cd214
|
@ -352,7 +352,12 @@ sections = {
|
||||||
{
|
{
|
||||||
'mode',
|
'mode',
|
||||||
icons_enabled = true, -- Enables the display of icons alongside the component.
|
icons_enabled = true, -- Enables the display of icons alongside the component.
|
||||||
icon = nil, -- Defines the icon to be displayed in front of the component.
|
-- Defines the icon to be displayed in front of the component.
|
||||||
|
-- Can be string|table
|
||||||
|
-- As table it must contain the icon as first entry and can use
|
||||||
|
-- color option to custom color the icon. Example:
|
||||||
|
-- {'branch', icon = ''} / {'branch', icon = {'', color={fg='green'}}}
|
||||||
|
icon = nil,
|
||||||
|
|
||||||
separator = nil, -- Determines what separator to use for the component.
|
separator = nil, -- Determines what separator to use for the component.
|
||||||
-- Note:
|
-- Note:
|
||||||
|
|
|
@ -365,7 +365,12 @@ General component options These are options that control behavior
|
||||||
{
|
{
|
||||||
'mode',
|
'mode',
|
||||||
icons_enabled = true, -- Enables the display of icons alongside the component.
|
icons_enabled = true, -- Enables the display of icons alongside the component.
|
||||||
icon = nil, -- Defines the icon to be displayed in front of the component.
|
-- Defines the icon to be displayed in front of the component.
|
||||||
|
-- Can be string|table
|
||||||
|
-- As table it must contain the icon as first entry and can use
|
||||||
|
-- color option to custom color the icon. Example:
|
||||||
|
-- {'branch', icon = ''} / {'branch', icon = {'', color={fg='green'}}}
|
||||||
|
icon = nil,
|
||||||
|
|
||||||
separator = nil, -- Determines what separator to use for the component.
|
separator = nil, -- Determines what separator to use for the component.
|
||||||
-- Note:
|
-- Note:
|
||||||
|
|
|
@ -58,6 +58,15 @@ function M:create_option_highlights()
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
-- setup icon highlight
|
||||||
|
if type(self.options.icon) == 'table' and self.options.icon.color then
|
||||||
|
self.options.icon_color_highlight = highlight.create_component_highlight_group(
|
||||||
|
self.options.icon.color,
|
||||||
|
self.options.component_name .. 'icon',
|
||||||
|
self.options,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---adds spaces to left and right of a component
|
---adds spaces to left and right of a component
|
||||||
|
@ -111,8 +120,22 @@ end
|
||||||
|
|
||||||
---apply icon in front of component (prepemds component with icon)
|
---apply icon in front of component (prepemds component with icon)
|
||||||
function M:apply_icon()
|
function M:apply_icon()
|
||||||
if self.options.icons_enabled and self.options.icon then
|
local icon = self.options.icon
|
||||||
self.status = self.options.icon .. ' ' .. self.status
|
if self.options.icons_enabled and icon then
|
||||||
|
if type(icon) == 'table' then
|
||||||
|
icon = icon[1]
|
||||||
|
end
|
||||||
|
if self.options.icon_color_highlight then
|
||||||
|
self.status = table.concat {
|
||||||
|
highlight.component_format_highlight(self.options.icon_color_highlight),
|
||||||
|
icon,
|
||||||
|
self:get_default_hl(),
|
||||||
|
' ',
|
||||||
|
self.status,
|
||||||
|
}
|
||||||
|
else
|
||||||
|
self.status = table.concat({ icon, self.status }, ' ')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue