lualine: add winbar and inactive sections configs (#302)

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>
This commit is contained in:
André Vitor de Lima Matos 2023-04-01 05:42:18 -03:00 committed by GitHub
parent d62edf4178
commit 3d64fab719
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 186 additions and 105 deletions

View file

@ -12,22 +12,19 @@ with lib; let
leftDefault ? " ", leftDefault ? " ",
rightDefault ? " ", rightDefault ? " ",
name, name,
}: ( }:
helpers.mkNullOrOption helpers.mkCompositeOption "${name} separtors." {
(types.submodule {
options = {
left = helpers.defaultNullOpts.mkStr leftDefault "Left separator"; left = helpers.defaultNullOpts.mkStr leftDefault "Left separator";
right = helpers.defaultNullOpts.mkStr rightDefault "Right separator"; right = helpers.defaultNullOpts.mkStr rightDefault "Right separator";
}; };
})
"${name} separtors."
);
mkComponentOptions = defaultName: mkComponentOptions = defaultName:
helpers.mkNullOrOption helpers.mkNullOrOption
(types.listOf (types.oneOf [ (with types;
types.str listOf (
(types.submodule { either
str
(submodule {
options = { options = {
name = mkOption { name = mkOption {
type = types.either types.str helpers.rawType; type = types.either types.str helpers.rawType;
@ -77,8 +74,18 @@ with lib; let
}; };
}; };
}) })
])) ))
""; "";
mkEmptySectionOption = name:
helpers.mkCompositeOption name {
lualine_a = mkComponentOptions "";
lualine_b = mkComponentOptions "";
lualine_c = mkComponentOptions "";
lualine_x = mkComponentOptions "";
lualine_y = mkComponentOptions "";
lualine_z = mkComponentOptions "";
};
in { in {
options = { options = {
plugins.lualine = { plugins.lualine = {
@ -106,10 +113,7 @@ in {
name = "section"; name = "section";
}; };
disabledFiletypes = disabledFiletypes = helpers.mkCompositeOption "Filetypes to disable lualine for." {
helpers.mkNullOrOption
(types.submodule {
options = {
statusline = helpers.defaultNullOpts.mkNullable (types.str) "[]" '' statusline = helpers.defaultNullOpts.mkNullable (types.str) "[]" ''
Only ignores the ft for statusline. Only ignores the ft for statusline.
''; '';
@ -118,8 +122,6 @@ in {
Only ignores the ft for winbar. Only ignores the ft for winbar.
''; '';
}; };
})
"Filetypes to disable lualine for.";
ignoreFocus = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" '' 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 If current filetype is in this list it'll always be drawn as inactive statusline and the
@ -141,27 +143,22 @@ in {
''; '';
refresh = refresh =
helpers.mkNullOrOption helpers.mkCompositeOption
(types.submodule { ''
options = { 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.
''
{
statusline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the status line (ms)"; statusline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the status line (ms)";
tabline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the tabline (ms)"; tabline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the tabline (ms)";
winbar = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the winbar (ms)"; winbar = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the winbar (ms)";
}; };
})
''
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.
'';
sections = sections = helpers.mkCompositeOption "Sections configuration" {
helpers.mkNullOrOption
(types.submodule {
options = {
lualine_a = mkComponentOptions "mode"; lualine_a = mkComponentOptions "mode";
lualine_b = mkComponentOptions "branch"; lualine_b = mkComponentOptions "branch";
lualine_c = mkComponentOptions "filename"; lualine_c = mkComponentOptions "filename";
@ -170,23 +167,21 @@ in {
lualine_y = mkComponentOptions "progress"; lualine_y = mkComponentOptions "progress";
lualine_z = mkComponentOptions "location"; lualine_z = mkComponentOptions "location";
}; };
})
"Sections configuration";
tabline = inactiveSections = helpers.mkCompositeOption "Inactive Sections configuration" {
helpers.mkNullOrOption
(types.submodule {
options = {
lualine_a = mkComponentOptions ""; lualine_a = mkComponentOptions "";
lualine_b = mkComponentOptions ""; lualine_b = mkComponentOptions "";
lualine_c = mkComponentOptions ""; lualine_c = mkComponentOptions "filename";
lualine_x = mkComponentOptions "location";
lualine_x = mkComponentOptions "";
lualine_y = mkComponentOptions ""; lualine_y = mkComponentOptions "";
lualine_z = mkComponentOptions ""; lualine_z = mkComponentOptions "";
}; };
})
"Tabline configuration"; tabline = mkEmptySectionOption "Tabline configuration";
winbar = mkEmptySectionOption "Winbar configuration";
inactiveWinbar = mkEmptySectionOption "Inactive Winbar configuration";
extensions = mkOption { extensions = mkOption {
type = types.nullOr (types.listOf types.str); type = types.nullOr (types.listOf types.str);
@ -227,13 +222,17 @@ in {
section_separators = cfg.sectionSeparators; section_separators = cfg.sectionSeparators;
component_separators = cfg.componentSeparators; component_separators = cfg.componentSeparators;
disabled_filetypes = cfg.disabledFiletypes; disabled_filetypes = cfg.disabledFiletypes;
ignore_focus = cfg.ignoreFocus;
always_divide_middle = cfg.alwaysDivideMiddle; always_divide_middle = cfg.alwaysDivideMiddle;
globalstatus = cfg.globalstatus; globalstatus = cfg.globalstatus;
refresh = cfg.refresh; refresh = cfg.refresh;
}; };
sections = mapNullable processSections cfg.sections; sections = mapNullable processSections cfg.sections;
inactive_sections = mapNullable processSections cfg.inactiveSections;
tabline = mapNullable processSections cfg.tabline; tabline = mapNullable processSections cfg.tabline;
winbar = mapNullable processSections cfg.winbar;
inactive_winbar = mapNullable processSections cfg.inactiveWinbar;
extensions = cfg.extensions; extensions = cfg.extensions;
}; };
in in

View file

@ -0,0 +1,82 @@
{
empty = {
plugins.lualine.enable = true;
};
defaults = {
plugins.lualine = {
enable = true;
iconsEnabled = true;
theme = "auto";
componentSeparators = {
left = "";
right = "";
};
sectionSeparators = {
left = "";
right = "";
};
alwaysDivideMiddle = true;
globalstatus = false;
refresh = {
statusline = 1000;
tabline = 1000;
winbar = 1000;
};
sections = {
lualine_a = ["mode"];
lualine_b = ["branch" "diff" "diagnostics"];
lualine_c = ["filename"];
lualine_x = ["encoding" "fileformat" "filetype"];
lualine_y = ["progress"];
lualine_z = ["location"];
};
inactiveSections = {
lualine_c = ["filename"];
lualine_x = ["location"];
};
};
};
example = {
plugins.lualine = {
enable = true;
ignoreFocus = ["NvimTree"];
sections = {
lualine_c = [
# you can specify only the sections you want to change
{
name = "filename";
extraConfig.newfile_status = true;
extraConfig.path = 1;
extraConfig.shorting_target = 60;
}
];
lualine_z = [
{name = "location";}
{name = "%L";} # total lines
];
};
tabline = {
lualine_a = [
{
name = "buffers";
extraConfig.mode = 4;
extraConfig.filetype_names = {
TelescopePrompt = "Telescope";
NvimTree = "NvimTree";
};
}
];
lualine_z = [
{
name = "tabs";
extraConfig.mode = 2;
}
];
};
extensions = ["nvim-tree"];
};
};
}