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; default = null;
}; };
component_options = mode: component_options = defaultName:
mkOption { mkOption {
type = types.nullOr (types.submodule { type = types.nullOr (types.listOf (types.oneOf [
types.str
(types.submodule {
options = { options = {
mode = mkOption { name = mkOption {
type = types.str; type = types.str;
default = "${mode}"; description = "component name";
default = defaultName;
}; };
icons_enabled = mkOption { icons_enabled = mkOption {
type = types.enum [ "True" "False" ]; type = types.enum [ "True" "False" ];
@ -39,8 +42,14 @@ let
description = "displays icon in front of the component"; description = "displays icon in front of the component";
}; };
separator = separators; separator = separators;
extraConfig = mkOption {
type = types.attrs;
default = { };
description = "extra options for the component";
}; };
}); };
})
]));
default = null; default = null;
}; };
in in
@ -112,6 +121,14 @@ in
}; };
config = config =
let 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 = { setupOptions = {
options = { options = {
theme = cfg.theme; theme = cfg.theme;
@ -121,8 +138,8 @@ in
always_divide_middle = cfg.alwaysDivideMiddle; always_divide_middle = cfg.alwaysDivideMiddle;
}; };
sections = cfg.sections; sections = mapNullable processSections cfg.sections;
tabline = cfg.tabline; tabline = mapNullable processSections cfg.tabline;
extensions = cfg.extensions; extensions = cfg.extensions;
}; };
in in