diff --git a/plugins/statuslines/lualine.nix b/plugins/statuslines/lualine.nix index 7205b847..31454c01 100644 --- a/plugins/statuslines/lualine.nix +++ b/plugins/statuslines/lualine.nix @@ -20,27 +20,36 @@ let }); default = null; }; - component_options = mode: + component_options = defaultName: mkOption { - type = types.nullOr (types.submodule { - options = { - mode = mkOption { - type = types.str; - default = "${mode}"; + type = types.nullOr (types.listOf (types.oneOf [ + types.str + (types.submodule { + options = { + name = mkOption { + type = types.str; + description = "component name"; + default = defaultName; + }; + icons_enabled = mkOption { + type = types.enum [ "True" "False" ]; + default = "True"; + description = "displays icons in alongside component"; + }; + icon = mkOption { + type = types.nullOr types.str; + default = null; + description = "displays icon in front of the component"; + }; + separator = separators; + extraConfig = mkOption { + type = types.attrs; + default = { }; + description = "extra options for the component"; + }; }; - icons_enabled = mkOption { - type = types.enum [ "True" "False" ]; - default = "True"; - description = "displays icons in alongside component"; - }; - icon = mkOption { - type = types.nullOr types.str; - default = null; - description = "displays icon in front of the component"; - }; - separator = separators; - }; - }); + }) + ])); default = null; }; in @@ -112,6 +121,14 @@ in }; config = let + processComponent = x: (if isAttrs x then processTableComponent else id) x; + processTableComponent = { name, icons_enabled, icon, separator, extraConfig }: mergeAttrs + { + "@" = name; + inherit icons_enabled icon separator; + } + extraConfig; + processSections = sections: mapAttrs (_: mapNullable (map processComponent)) sections; setupOptions = { options = { theme = cfg.theme; @@ -121,8 +138,8 @@ in always_divide_middle = cfg.alwaysDivideMiddle; }; - sections = cfg.sections; - tabline = cfg.tabline; + sections = mapNullable processSections cfg.sections; + tabline = mapNullable processSections cfg.tabline; extensions = cfg.extensions; }; in