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;};
|
2023-02-25 14:23:54 +01:00
|
|
|
|
|
|
|
mkSeparatorsOption = {
|
|
|
|
leftDefault ? " ",
|
|
|
|
rightDefault ? " ",
|
|
|
|
name,
|
2023-04-01 05:42:18 -03:00
|
|
|
}:
|
|
|
|
helpers.mkCompositeOption "${name} separtors." {
|
|
|
|
left = helpers.defaultNullOpts.mkStr leftDefault "Left separator";
|
|
|
|
right = helpers.defaultNullOpts.mkStr rightDefault "Right separator";
|
|
|
|
};
|
2023-02-25 14:23:54 +01:00
|
|
|
|
|
|
|
mkComponentOptions = defaultName:
|
|
|
|
helpers.mkNullOrOption
|
2023-04-01 05:42:18 -03:00
|
|
|
(with types;
|
|
|
|
listOf (
|
|
|
|
either
|
|
|
|
str
|
|
|
|
(submodule {
|
|
|
|
options = {
|
|
|
|
name = mkOption {
|
|
|
|
type = types.either types.str helpers.rawType;
|
|
|
|
description = "Component name or function";
|
|
|
|
default = defaultName;
|
|
|
|
};
|
|
|
|
|
|
|
|
icons_enabled = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
Enables the display of icons alongside the component.
|
|
|
|
'';
|
2023-02-25 14:23:54 +01:00
|
|
|
|
2023-04-01 05:42:18 -03:00
|
|
|
icon = helpers.mkNullOrOption types.str ''
|
|
|
|
Defines the icon to be displayed in front of the component.
|
|
|
|
'';
|
|
|
|
|
|
|
|
separator = mkSeparatorsOption {name = "Component";};
|
|
|
|
|
|
|
|
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";
|
|
|
|
};
|
2023-02-25 14:23:54 +01:00
|
|
|
};
|
2023-04-01 05:42:18 -03:00
|
|
|
})
|
|
|
|
)
|
|
|
|
"1"
|
|
|
|
"Adds padding to the left and right of components.";
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = {};
|
|
|
|
description = "extra options for the component";
|
|
|
|
};
|
2023-02-25 14:23:54 +01:00
|
|
|
};
|
2023-04-01 05:42:18 -03:00
|
|
|
})
|
|
|
|
))
|
2023-02-25 14:23:54 +01:00
|
|
|
"";
|
2023-04-01 05:42:18 -03:00
|
|
|
|
|
|
|
mkEmptySectionOption = name:
|
|
|
|
helpers.mkCompositeOption name {
|
|
|
|
lualine_a = mkComponentOptions "";
|
|
|
|
lualine_b = mkComponentOptions "";
|
|
|
|
lualine_c = mkComponentOptions "";
|
|
|
|
lualine_x = mkComponentOptions "";
|
|
|
|
lualine_y = mkComponentOptions "";
|
|
|
|
lualine_z = mkComponentOptions "";
|
|
|
|
};
|
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
|
|
|
|
2023-02-27 23:51:50 +01:00
|
|
|
iconsEnabled = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
description = "Whether to enable/disable icons for all components.";
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
2023-02-25 14:23:54 +01:00
|
|
|
theme = helpers.defaultNullOpts.mkStr "auto" "The theme to use for lualine-nvim.";
|
2021-11-02 19:37:08 +00:00
|
|
|
|
2023-02-25 14:23:54 +01:00
|
|
|
componentSeparators = mkSeparatorsOption {
|
|
|
|
leftDefault = "";
|
|
|
|
rightDefault = "";
|
|
|
|
name = "component";
|
2021-11-02 18:03:01 +01:00
|
|
|
};
|
2021-11-02 19:37:08 +00:00
|
|
|
|
2023-02-25 14:23:54 +01:00
|
|
|
sectionSeparators = mkSeparatorsOption {
|
|
|
|
leftDefault = "";
|
|
|
|
rightDefault = "";
|
|
|
|
name = "section";
|
2021-11-02 19:37:08 +00:00
|
|
|
};
|
|
|
|
|
2023-04-01 05:42:18 -03:00
|
|
|
disabledFiletypes = helpers.mkCompositeOption "Filetypes to disable lualine for." {
|
|
|
|
statusline = helpers.defaultNullOpts.mkNullable (types.str) "[]" ''
|
|
|
|
Only ignores the ft for statusline.
|
|
|
|
'';
|
2021-11-02 18:03:01 +01:00
|
|
|
|
2023-04-01 05:42:18 -03:00
|
|
|
winbar = helpers.defaultNullOpts.mkNullable (types.str) "[]" ''
|
|
|
|
Only ignores the ft for winbar.
|
|
|
|
'';
|
|
|
|
};
|
2021-11-02 19:37:08 +00:00
|
|
|
|
2023-02-25 14:23:54 +01:00
|
|
|
ignoreFocus = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
|
|
|
|
If current filetype is in this list it'll always be drawn as inactive statusline and the
|
|
|
|
last window will be drawn as active statusline.
|
|
|
|
|
|
|
|
For example if you don't want statusline of your file tree / sidebar window to have active
|
|
|
|
statusline you can add their filetypes here.
|
|
|
|
'';
|
2021-11-02 19:37:08 +00:00
|
|
|
|
2023-02-25 14:23:54 +01:00
|
|
|
alwaysDivideMiddle = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
When set to true, left sections i.e. 'a','b' and 'c' can't take over the entire statusline
|
|
|
|
even if neither of 'x', 'y' or 'z' are present.
|
|
|
|
'';
|
|
|
|
|
|
|
|
globalstatus = helpers.defaultNullOpts.mkBool false ''
|
|
|
|
Enable global statusline (have a single statusline at bottom of neovim instead of one for
|
|
|
|
every window).
|
|
|
|
This feature is only available in neovim 0.7 and higher.
|
|
|
|
'';
|
|
|
|
|
|
|
|
refresh =
|
2023-04-01 05:42:18 -03:00
|
|
|
helpers.mkCompositeOption
|
2023-02-25 14:23:54 +01:00
|
|
|
''
|
|
|
|
Sets how often lualine should refresh it's contents (in ms).
|
|
|
|
The refresh option sets minimum time that lualine tries to maintain between refresh.
|
|
|
|
It's not guarantied if situation arises that lualine needs to refresh itself before this
|
|
|
|
time it'll do it.
|
2023-04-01 05:42:18 -03:00
|
|
|
''
|
|
|
|
{
|
|
|
|
statusline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the status line (ms)";
|
2023-02-25 14:23:54 +01:00
|
|
|
|
2023-04-01 05:42:18 -03:00
|
|
|
tabline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the tabline (ms)";
|
2023-02-25 14:23:54 +01:00
|
|
|
|
2023-04-01 05:42:18 -03:00
|
|
|
winbar = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the winbar (ms)";
|
|
|
|
};
|
2023-02-25 14:23:54 +01:00
|
|
|
|
2023-04-01 05:42:18 -03:00
|
|
|
sections = helpers.mkCompositeOption "Sections configuration" {
|
|
|
|
lualine_a = mkComponentOptions "mode";
|
|
|
|
lualine_b = mkComponentOptions "branch";
|
|
|
|
lualine_c = mkComponentOptions "filename";
|
2023-02-25 14:23:54 +01:00
|
|
|
|
2023-04-01 05:42:18 -03:00
|
|
|
lualine_x = mkComponentOptions "encoding";
|
|
|
|
lualine_y = mkComponentOptions "progress";
|
|
|
|
lualine_z = mkComponentOptions "location";
|
|
|
|
};
|
|
|
|
|
|
|
|
inactiveSections = helpers.mkCompositeOption "Inactive Sections configuration" {
|
|
|
|
lualine_a = mkComponentOptions "";
|
|
|
|
lualine_b = mkComponentOptions "";
|
|
|
|
lualine_c = mkComponentOptions "filename";
|
|
|
|
lualine_x = mkComponentOptions "location";
|
|
|
|
lualine_y = mkComponentOptions "";
|
|
|
|
lualine_z = mkComponentOptions "";
|
|
|
|
};
|
|
|
|
|
|
|
|
tabline = mkEmptySectionOption "Tabline configuration";
|
|
|
|
|
|
|
|
winbar = mkEmptySectionOption "Winbar configuration";
|
|
|
|
|
|
|
|
inactiveWinbar = mkEmptySectionOption "Inactive Winbar configuration";
|
2023-02-25 14:23:54 +01:00
|
|
|
|
2021-11-02 18:03:01 +01:00
|
|
|
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,
|
2023-02-25 14:23:54 +01:00
|
|
|
color,
|
|
|
|
padding,
|
2023-02-20 11:42:13 +01:00
|
|
|
extraConfig,
|
|
|
|
}:
|
|
|
|
mergeAttrs
|
|
|
|
{
|
|
|
|
"@" = name;
|
2023-02-25 14:23:54 +01:00
|
|
|
inherit icons_enabled icon separator color padding;
|
2023-02-20 11:42:13 +01:00
|
|
|
}
|
|
|
|
extraConfig;
|
|
|
|
processSections = sections: mapAttrs (_: mapNullable (map processComponent)) sections;
|
|
|
|
setupOptions = {
|
|
|
|
options = {
|
2023-02-27 23:51:50 +01:00
|
|
|
icons_enabled = cfg.iconsEnabled;
|
2023-02-20 11:42:13 +01:00
|
|
|
theme = cfg.theme;
|
|
|
|
section_separators = cfg.sectionSeparators;
|
|
|
|
component_separators = cfg.componentSeparators;
|
|
|
|
disabled_filetypes = cfg.disabledFiletypes;
|
2023-04-01 05:42:18 -03:00
|
|
|
ignore_focus = cfg.ignoreFocus;
|
2023-02-20 11:42:13 +01:00
|
|
|
always_divide_middle = cfg.alwaysDivideMiddle;
|
2023-02-25 14:23:54 +01:00
|
|
|
globalstatus = cfg.globalstatus;
|
|
|
|
refresh = cfg.refresh;
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
|
|
|
|
sections = mapNullable processSections cfg.sections;
|
2023-04-01 05:42:18 -03:00
|
|
|
inactive_sections = mapNullable processSections cfg.inactiveSections;
|
2023-02-20 11:42:13 +01:00
|
|
|
tabline = mapNullable processSections cfg.tabline;
|
2023-04-01 05:42:18 -03:00
|
|
|
winbar = mapNullable processSections cfg.winbar;
|
|
|
|
inactive_winbar = mapNullable processSections cfg.inactiveWinbar;
|
2023-02-20 11:42:13 +01:00
|
|
|
extensions = cfg.extensions;
|
|
|
|
};
|
|
|
|
in
|
2022-09-18 11:19:23 +01:00
|
|
|
mkIf cfg.enable {
|
2023-02-27 23:51:50 +01:00
|
|
|
extraPlugins =
|
|
|
|
[cfg.package]
|
|
|
|
++ (optional cfg.iconsEnabled pkgs.vimPlugins.nvim-web-devicons);
|
2023-02-20 11:42:13 +01:00
|
|
|
extraPackages = [pkgs.git];
|
|
|
|
extraConfigLua = ''require("lualine").setup(${helpers.toLuaObject setupOptions})'';
|
2021-11-02 15:04:12 +01:00
|
|
|
};
|
|
|
|
}
|