treewide: Reformat with nixfmt

This commit is contained in:
traxys 2024-05-05 19:39:35 +02:00
parent c6281260dc
commit 62f32bfc71
459 changed files with 28139 additions and 26377 deletions

View file

@ -5,24 +5,26 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.lualine;
mkSeparatorsOption = {
leftDefault ? " ",
rightDefault ? " ",
}: {
left = helpers.defaultNullOpts.mkStr leftDefault "Left separator";
right = helpers.defaultNullOpts.mkStr rightDefault "Right separator";
};
mkSeparatorsOption =
{
leftDefault ? " ",
rightDefault ? " ",
}:
{
left = helpers.defaultNullOpts.mkStr leftDefault "Left separator";
right = helpers.defaultNullOpts.mkStr rightDefault "Right separator";
};
mkComponentOptions = defaultName:
helpers.mkNullOrOption
(with types;
mkComponentOptions =
defaultName:
helpers.mkNullOrOption (
with types;
listOf (
either
str
(submodule {
either str (submodule {
options = {
name = mkOption {
type = types.either types.str helpers.nixvimTypes.rawLua;
@ -34,51 +36,40 @@ with lib; let
Enables the display of icons alongside the component.
'';
icon =
helpers.mkNullOrOption
(
with types;
either
str
(submodule {
freeformType = attrsOf anything;
icon = helpers.mkNullOrOption (
with types;
either str (submodule {
freeformType = attrsOf anything;
options = {
icon = mkOption {
type = str;
description = "Icon character.";
};
};
})
)
"Defines the icon to be displayed in front of the component.";
options = {
icon = mkOption {
type = str;
description = "Icon character.";
};
};
})
) "Defines the icon to be displayed in front of the component.";
separator = mkSeparatorsOption {};
separator = mkSeparatorsOption { };
color = helpers.mkNullOrOption (types.attrsOf types.str) ''
Defines a custom color for the component.
'';
padding =
helpers.defaultNullOpts.mkNullable
(
types.either
types.int
(types.submodule {
options = {
left = mkOption {
type = types.int;
description = "left padding";
};
right = mkOption {
type = types.int;
description = "left padding";
};
padding = helpers.defaultNullOpts.mkNullable (types.either types.int (
types.submodule {
options = {
left = mkOption {
type = types.int;
description = "left padding";
};
})
)
"1"
"Adds padding to the left and right of components.";
right = mkOption {
type = types.int;
description = "left padding";
};
};
}
)) "1" "Adds padding to the left and right of components.";
fmt = helpers.mkNullOrLuaFn ''
A lua function to format the component string.
@ -93,13 +84,13 @@ with lib; let
extraConfig = mkOption {
type = types.attrs;
default = {};
default = { };
description = "extra options for the component";
};
};
})
))
"";
)
) "";
mkEmptySectionOption = name: {
lualine_a = mkComponentOptions "";
@ -109,7 +100,8 @@ with lib; let
lualine_y = mkComponentOptions "";
lualine_z = mkComponentOptions "";
};
in {
in
{
options = {
plugins.lualine = {
enable = mkEnableOption "lualine";
@ -122,7 +114,9 @@ in {
default = true;
};
theme = helpers.defaultNullOpts.mkNullable (with types; either str attrs) "auto" "The theme to use for lualine-nvim.";
theme = helpers.defaultNullOpts.mkNullable (
with types; either str attrs
) "auto" "The theme to use for lualine-nvim.";
componentSeparators = mkSeparatorsOption {
leftDefault = "";
@ -204,58 +198,58 @@ in {
};
};
};
config = let
processComponent = x:
(
if isAttrs x
then processTableComponent
else id
)
x;
processTableComponent = {
name,
icons_enabled,
icon,
separator,
color,
padding,
extraConfig,
fmt,
}:
mergeAttrs
{
"__unkeyed" = name;
icon =
if isAttrs icon
then removeAttrs (icon // {"__unkeyed" = icon.icon;}) ["icon"]
else icon;
inherit icons_enabled separator color padding fmt;
}
extraConfig;
processSections = mapAttrs (_: mapNullable (map processComponent));
setupOptions = {
options = {
inherit (cfg) theme globalstatus refresh extensions;
icons_enabled = cfg.iconsEnabled;
section_separators = cfg.sectionSeparators;
component_separators = cfg.componentSeparators;
disabled_filetypes = cfg.disabledFiletypes;
ignore_focus = cfg.ignoreFocus;
always_divide_middle = cfg.alwaysDivideMiddle;
};
config =
let
processComponent = x: (if isAttrs x then processTableComponent else id) x;
processTableComponent =
{
name,
icons_enabled,
icon,
separator,
color,
padding,
extraConfig,
fmt,
}:
mergeAttrs {
"__unkeyed" = name;
icon = if isAttrs icon then removeAttrs (icon // { "__unkeyed" = icon.icon; }) [ "icon" ] else icon;
inherit
icons_enabled
separator
color
padding
fmt
;
} extraConfig;
processSections = mapAttrs (_: mapNullable (map processComponent));
setupOptions = {
options = {
inherit (cfg)
theme
globalstatus
refresh
extensions
;
icons_enabled = cfg.iconsEnabled;
section_separators = cfg.sectionSeparators;
component_separators = cfg.componentSeparators;
disabled_filetypes = cfg.disabledFiletypes;
ignore_focus = cfg.ignoreFocus;
always_divide_middle = cfg.alwaysDivideMiddle;
};
sections = processSections cfg.sections;
inactive_sections = processSections cfg.inactiveSections;
tabline = processSections cfg.tabline;
winbar = processSections cfg.winbar;
inactive_winbar = processSections cfg.inactiveWinbar;
};
in
sections = processSections cfg.sections;
inactive_sections = processSections cfg.inactiveSections;
tabline = processSections cfg.tabline;
winbar = processSections cfg.winbar;
inactive_winbar = processSections cfg.inactiveWinbar;
};
in
mkIf cfg.enable {
extraPlugins =
[cfg.package]
++ (optional cfg.iconsEnabled pkgs.vimPlugins.nvim-web-devicons);
extraPackages = [pkgs.git];
extraPlugins = [ cfg.package ] ++ (optional cfg.iconsEnabled pkgs.vimPlugins.nvim-web-devicons);
extraPackages = [ pkgs.git ];
extraConfigLua = ''require("lualine").setup(${helpers.toLuaObject setupOptions})'';
};
}