diff --git a/README.md b/README.md index 84bb14a..40770e2 100644 --- a/README.md +++ b/README.md @@ -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

`color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}`

The fields of color table are optional and default to theme | All +color | nil | Sets custom color for the component in this format

`color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}`

The fields 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. | All #### Using global options Global options can be set in two ways. One is as part of options table in setup. diff --git a/doc/lualine.txt b/doc/lualine.txt index c58cbc3..6674ce6 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -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: diff --git a/lua/lualine/component.lua b/lua/lualine/component.lua index 2047527..47c236c 100644 --- a/lua/lualine/component.lua +++ b/lua/lualine/component.lua @@ -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,