diff --git a/README.md b/README.md index 8f97511..49f9830 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,7 @@ right_padding | 1 | Adds padding to the right of components | all 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 ##### Global options example ```lua options = {icons_enabled = true} diff --git a/doc/lualine.txt b/doc/lualine.txt index 8271887..128779e 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -263,7 +263,12 @@ option (default_value) • icon (differs for each component) displays an icon infront of a component - • color (nil) + • 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. + + • color (Theme colors) color option can be used to set custom color to a component Color format: `lua color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}` diff --git a/lua/lualine/component.lua b/lua/lualine/component.lua index 4ea5b54..2047527 100644 --- a/lua/lualine/component.lua +++ b/lua/lualine/component.lua @@ -118,6 +118,9 @@ local Component = { -- Driver code of the class draw = function(self, default_highlight) self.status = '' + if self.options.condition ~= nil and self.options.condition() ~= true then + return self.status + end local status = self:update_status() if self.options.format then status = self.options.format(status or '') end if type(status) == 'string' and #status > 0 then