lualine: fix components config (#47)

This commit is contained in:
LightQuantum 2022-10-17 21:00:18 +08:00 committed by GitHub
parent a38d531bf4
commit 931db3e83f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,13 +20,16 @@ let
});
default = null;
};
component_options = mode:
component_options = defaultName:
mkOption {
type = types.nullOr (types.submodule {
type = types.nullOr (types.listOf (types.oneOf [
types.str
(types.submodule {
options = {
mode = mkOption {
name = mkOption {
type = types.str;
default = "${mode}";
description = "component name";
default = defaultName;
};
icons_enabled = mkOption {
type = types.enum [ "True" "False" ];
@ -39,8 +42,14 @@ let
description = "displays icon in front of the component";
};
separator = separators;
extraConfig = mkOption {
type = types.attrs;
default = { };
description = "extra options for the component";
};
});
};
})
]));
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