Feat: Allow color option to accept highlight group
This commit is contained in:
parent
7c6d1f9074
commit
9e957e341e
|
@ -206,7 +206,7 @@ upper | false | Changes components to be uppercase | All
|
|||
lower | false | Changes components to be lowercase | All
|
||||
format | nil | Takes a function . The funtion gets the result of component as argument and it's return value is displayed. So this function can parse and format the output as user wants. | All
|
||||
condition | nil | Takes a function. The component is loaded if the function returns true otherwise not. It can be used to load some comoonents on specific cases. | All
|
||||
color | nil | Sets custom color for the component in this format<br></br>`color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}`<br></br>The fields of color table are optional and default to theme | All
|
||||
color | nil | Sets custom color for the component in this format<br></br>`color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}`<br></br>The fields of color table are optional and default to theme <br></br>Color option can also be a string containing highlight group name `color = "WarningMsg"`. One neat trick set the color to highlight group name then change that highlight with :hi command to change color of that component at runtime. | All
|
||||
|
||||
#### Using global options
|
||||
Global options can be set in two ways. One is as part of options table in setup.
|
||||
|
|
|
@ -287,7 +287,11 @@ option (default_value)
|
|||
Color format:
|
||||
`lua color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}`
|
||||
the members of color table are optional and default to theme
|
||||
|
||||
Color option can also be a string containing highlight group name >
|
||||
color = "WarningMsg"`
|
||||
< One neat trick set the color to highlight group name then change
|
||||
that highlight with :hi command to change color of that component
|
||||
at runtime.
|
||||
|
||||
Using global options~
|
||||
|
||||
|
@ -536,4 +540,4 @@ Vimscript config example
|
|||
lua require("lualine").setup()
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
vim:tw=80:sw=4:ts=8:noet:ft=help:norl:noet:
|
||||
vim:tw=80:sw=4:ts=8:noet:ft=help:norl:et:
|
||||
|
|
|
@ -37,11 +37,13 @@ local Component = {
|
|||
|
||||
create_option_highlights = function(self)
|
||||
-- set custom highlights
|
||||
if self.options.color then
|
||||
if type(self.options.color) == 'table' then
|
||||
self.options.color_highlight = highlight.create_component_highlight_group(
|
||||
self.options.color,
|
||||
self.options.component_name,
|
||||
self.options)
|
||||
elseif type(self.options.color) == 'string' then
|
||||
self.options.color_highlight_link = self.options.color
|
||||
end
|
||||
end,
|
||||
|
||||
|
@ -80,6 +82,8 @@ local Component = {
|
|||
if self.options.color_highlight then
|
||||
self.status = highlight.component_format_highlight(
|
||||
self.options.color_highlight) .. self.status
|
||||
elseif self.options.color_highlight_link then
|
||||
self.status = '%#' .. self.options.color_highlight_link ..'#'.. self.status
|
||||
end
|
||||
self.status = self.status .. default_highlight
|
||||
end,
|
||||
|
|
Loading…
Reference in New Issue