2023-02-20 11:42:13 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
2022-09-18 11:19:23 +01:00
|
|
|
cfg = config.plugins.lualine;
|
2023-02-20 11:42:13 +01:00
|
|
|
helpers = import ../helpers.nix {inherit lib;};
|
2021-11-02 18:03:01 +01:00
|
|
|
separators = mkOption {
|
2021-12-11 14:55:05 +00:00
|
|
|
type = types.nullOr (types.submodule {
|
2021-11-02 18:03:01 +01:00
|
|
|
options = {
|
|
|
|
left = mkOption {
|
|
|
|
default = " ";
|
|
|
|
type = types.str;
|
|
|
|
description = "left separator";
|
|
|
|
};
|
|
|
|
right = mkOption {
|
|
|
|
default = " ";
|
|
|
|
type = types.str;
|
|
|
|
description = "right separator";
|
|
|
|
};
|
|
|
|
};
|
2021-12-11 14:55:05 +00:00
|
|
|
});
|
|
|
|
default = null;
|
2021-11-02 18:03:01 +01:00
|
|
|
};
|
2022-10-17 21:00:18 +08:00
|
|
|
component_options = defaultName:
|
2021-11-02 18:03:01 +01:00
|
|
|
mkOption {
|
2022-10-17 21:00:18 +08:00
|
|
|
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 {
|
2023-02-20 11:42:13 +01:00
|
|
|
type = types.enum ["True" "False"];
|
2022-10-17 21:00:18 +08:00
|
|
|
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;
|
2023-02-20 11:42:13 +01:00
|
|
|
default = {};
|
2022-10-17 21:00:18 +08:00
|
|
|
description = "extra options for the component";
|
|
|
|
};
|
2021-11-02 18:03:01 +01:00
|
|
|
};
|
2022-10-17 21:00:18 +08:00
|
|
|
})
|
|
|
|
]));
|
2021-12-11 14:55:05 +00:00
|
|
|
default = null;
|
2021-11-02 18:03:01 +01:00
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
in {
|
2021-11-02 15:04:12 +01:00
|
|
|
options = {
|
2022-09-18 11:19:23 +01:00
|
|
|
plugins.lualine = {
|
2023-01-22 03:32:08 +00:00
|
|
|
enable = mkEnableOption "lualine";
|
2021-11-02 18:03:01 +01:00
|
|
|
|
2023-01-25 19:46:49 +01:00
|
|
|
package = helpers.mkPackageOption "lualine" pkgs.vimPlugins.lualine-nvim;
|
2023-01-19 10:45:15 +00:00
|
|
|
|
2021-11-02 19:37:08 +00:00
|
|
|
theme = mkOption {
|
2022-09-18 11:19:23 +01:00
|
|
|
default = config.colorscheme;
|
2021-12-11 14:55:05 +00:00
|
|
|
type = types.nullOr types.str;
|
2021-11-02 19:37:08 +00:00
|
|
|
description = "The theme to use for lualine-nvim.";
|
|
|
|
};
|
|
|
|
|
|
|
|
sectionSeparators = separators;
|
|
|
|
componentSeparators = separators;
|
|
|
|
|
2021-11-03 09:10:52 +01:00
|
|
|
disabledFiletypes = mkOption {
|
2021-12-11 14:55:05 +00:00
|
|
|
type = types.nullOr (types.listOf types.str);
|
|
|
|
default = null;
|
2021-11-02 19:37:08 +00:00
|
|
|
example = ''[ "lua" ]'';
|
|
|
|
description = "filetypes to disable lualine on";
|
2021-11-02 18:03:01 +01:00
|
|
|
};
|
2021-11-02 19:37:08 +00:00
|
|
|
|
|
|
|
alwaysDivideMiddle = mkOption {
|
2021-12-11 14:55:05 +00:00
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
2023-02-20 11:42:13 +01:00
|
|
|
description = "When true, left_sections (a,b,c) can't take over entire statusline";
|
2021-11-02 19:37:08 +00:00
|
|
|
};
|
|
|
|
|
2021-11-02 18:03:01 +01:00
|
|
|
sections = mkOption {
|
2023-02-20 11:42:13 +01:00
|
|
|
type = types.nullOr (types.submodule ({...}: {
|
2021-11-02 18:03:01 +01:00
|
|
|
options = {
|
|
|
|
lualine_a = component_options "mode";
|
|
|
|
lualine_b = component_options "branch";
|
|
|
|
lualine_c = component_options "filename";
|
|
|
|
|
|
|
|
lualine_x = component_options "encoding";
|
|
|
|
lualine_y = component_options "progress";
|
|
|
|
lualine_z = component_options "location";
|
|
|
|
};
|
|
|
|
}));
|
2021-11-02 19:37:08 +00:00
|
|
|
|
2021-12-11 14:55:05 +00:00
|
|
|
default = null;
|
2021-11-02 18:03:01 +01:00
|
|
|
};
|
2021-11-02 19:37:08 +00:00
|
|
|
|
2021-11-02 18:03:01 +01:00
|
|
|
tabline = mkOption {
|
2023-02-20 11:42:13 +01:00
|
|
|
type = types.nullOr (types.submodule ({...}: {
|
2021-11-02 18:03:01 +01:00
|
|
|
options = {
|
|
|
|
lualine_a = component_options "";
|
|
|
|
lualine_b = component_options "";
|
|
|
|
lualine_c = component_options "";
|
|
|
|
|
|
|
|
lualine_x = component_options "";
|
|
|
|
lualine_y = component_options "";
|
|
|
|
lualine_z = component_options "";
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
extensions = mkOption {
|
2021-12-11 14:55:05 +00:00
|
|
|
type = types.nullOr (types.listOf types.str);
|
|
|
|
default = null;
|
2021-11-02 18:03:01 +01:00
|
|
|
example = ''[ "fzf" ]'';
|
|
|
|
description = "list of enabled extensions";
|
|
|
|
};
|
2021-11-02 15:04:12 +01:00
|
|
|
};
|
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
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;
|
|
|
|
section_separators = cfg.sectionSeparators;
|
|
|
|
component_separators = cfg.componentSeparators;
|
|
|
|
disabled_filetypes = cfg.disabledFiletypes;
|
|
|
|
always_divide_middle = cfg.alwaysDivideMiddle;
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
|
|
|
|
sections = mapNullable processSections cfg.sections;
|
|
|
|
tabline = mapNullable processSections cfg.tabline;
|
|
|
|
extensions = cfg.extensions;
|
|
|
|
};
|
|
|
|
in
|
2022-09-18 11:19:23 +01:00
|
|
|
mkIf cfg.enable {
|
2023-02-20 11:42:13 +01:00
|
|
|
extraPlugins = [cfg.package];
|
|
|
|
extraPackages = [pkgs.git];
|
|
|
|
extraConfigLua = ''require("lualine").setup(${helpers.toLuaObject setupOptions})'';
|
2021-11-02 15:04:12 +01:00
|
|
|
};
|
|
|
|
}
|