mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-25 02:08:40 +02:00
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:
parent
d62edf4178
commit
3d64fab719
2 changed files with 186 additions and 105 deletions
|
@ -12,73 +12,80 @@ with lib; let
|
||||||
leftDefault ? " ",
|
leftDefault ? " ",
|
||||||
rightDefault ? " ",
|
rightDefault ? " ",
|
||||||
name,
|
name,
|
||||||
}: (
|
}:
|
||||||
helpers.mkNullOrOption
|
helpers.mkCompositeOption "${name} separtors." {
|
||||||
(types.submodule {
|
left = helpers.defaultNullOpts.mkStr leftDefault "Left separator";
|
||||||
options = {
|
right = helpers.defaultNullOpts.mkStr rightDefault "Right separator";
|
||||||
left = helpers.defaultNullOpts.mkStr leftDefault "Left 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
|
||||||
options = {
|
str
|
||||||
name = mkOption {
|
(submodule {
|
||||||
type = types.either types.str helpers.rawType;
|
options = {
|
||||||
description = "Component name or function";
|
name = mkOption {
|
||||||
default = defaultName;
|
type = types.either types.str helpers.rawType;
|
||||||
};
|
description = "Component name or function";
|
||||||
|
default = defaultName;
|
||||||
|
};
|
||||||
|
|
||||||
icons_enabled = helpers.defaultNullOpts.mkBool true ''
|
icons_enabled = helpers.defaultNullOpts.mkBool true ''
|
||||||
Enables the display of icons alongside the component.
|
Enables the display of icons alongside the component.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
icon = helpers.mkNullOrOption types.str ''
|
icon = helpers.mkNullOrOption types.str ''
|
||||||
Defines the icon to be displayed in front of the component.
|
Defines the icon to be displayed in front of the component.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
separator = mkSeparatorsOption {name = "Component";};
|
separator = mkSeparatorsOption {name = "Component";};
|
||||||
|
|
||||||
color = helpers.mkNullOrOption (types.attrsOf types.str) ''
|
color = helpers.mkNullOrOption (types.attrsOf types.str) ''
|
||||||
Defines a custom color for the component.
|
Defines a custom color for the component.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
padding =
|
padding =
|
||||||
helpers.defaultNullOpts.mkNullable
|
helpers.defaultNullOpts.mkNullable
|
||||||
(
|
(
|
||||||
types.either
|
types.either
|
||||||
types.int
|
types.int
|
||||||
(types.submodule {
|
(types.submodule {
|
||||||
options = {
|
options = {
|
||||||
left = mkOption {
|
left = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
description = "left padding";
|
description = "left padding";
|
||||||
|
};
|
||||||
|
right = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
description = "left padding";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
right = mkOption {
|
})
|
||||||
type = types.int;
|
)
|
||||||
description = "left padding";
|
"1"
|
||||||
};
|
"Adds padding to the left and right of components.";
|
||||||
};
|
|
||||||
})
|
|
||||||
)
|
|
||||||
"1"
|
|
||||||
"Adds padding to the left and right of components.";
|
|
||||||
|
|
||||||
extraConfig = mkOption {
|
extraConfig = mkOption {
|
||||||
type = types.attrs;
|
type = types.attrs;
|
||||||
default = {};
|
default = {};
|
||||||
description = "extra options for the component";
|
description = "extra options for the component";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
})
|
||||||
})
|
))
|
||||||
]))
|
|
||||||
"";
|
"";
|
||||||
|
|
||||||
|
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,20 +113,15 @@ in {
|
||||||
name = "section";
|
name = "section";
|
||||||
};
|
};
|
||||||
|
|
||||||
disabledFiletypes =
|
disabledFiletypes = helpers.mkCompositeOption "Filetypes to disable lualine for." {
|
||||||
helpers.mkNullOrOption
|
statusline = helpers.defaultNullOpts.mkNullable (types.str) "[]" ''
|
||||||
(types.submodule {
|
Only ignores the ft for statusline.
|
||||||
options = {
|
'';
|
||||||
statusline = helpers.defaultNullOpts.mkNullable (types.str) "[]" ''
|
|
||||||
Only ignores the ft for statusline.
|
|
||||||
'';
|
|
||||||
|
|
||||||
winbar = helpers.defaultNullOpts.mkNullable (types.str) "[]" ''
|
winbar = helpers.defaultNullOpts.mkNullable (types.str) "[]" ''
|
||||||
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,52 +143,45 @@ in {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
refresh =
|
refresh =
|
||||||
helpers.mkNullOrOption
|
helpers.mkCompositeOption
|
||||||
(types.submodule {
|
|
||||||
options = {
|
|
||||||
statusline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the status line (ms)";
|
|
||||||
|
|
||||||
tabline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the tabline (ms)";
|
|
||||||
|
|
||||||
winbar = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the winbar (ms)";
|
|
||||||
};
|
|
||||||
})
|
|
||||||
''
|
''
|
||||||
Sets how often lualine should refresh it's contents (in 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.
|
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
|
It's not guarantied if situation arises that lualine needs to refresh itself before this
|
||||||
time it'll do it.
|
time it'll do it.
|
||||||
'';
|
''
|
||||||
|
{
|
||||||
|
statusline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the status line (ms)";
|
||||||
|
|
||||||
sections =
|
tabline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the tabline (ms)";
|
||||||
helpers.mkNullOrOption
|
|
||||||
(types.submodule {
|
|
||||||
options = {
|
|
||||||
lualine_a = mkComponentOptions "mode";
|
|
||||||
lualine_b = mkComponentOptions "branch";
|
|
||||||
lualine_c = mkComponentOptions "filename";
|
|
||||||
|
|
||||||
lualine_x = mkComponentOptions "encoding";
|
winbar = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the winbar (ms)";
|
||||||
lualine_y = mkComponentOptions "progress";
|
};
|
||||||
lualine_z = mkComponentOptions "location";
|
|
||||||
};
|
|
||||||
})
|
|
||||||
"Sections configuration";
|
|
||||||
|
|
||||||
tabline =
|
sections = helpers.mkCompositeOption "Sections configuration" {
|
||||||
helpers.mkNullOrOption
|
lualine_a = mkComponentOptions "mode";
|
||||||
(types.submodule {
|
lualine_b = mkComponentOptions "branch";
|
||||||
options = {
|
lualine_c = mkComponentOptions "filename";
|
||||||
lualine_a = mkComponentOptions "";
|
|
||||||
lualine_b = mkComponentOptions "";
|
|
||||||
lualine_c = mkComponentOptions "";
|
|
||||||
|
|
||||||
lualine_x = mkComponentOptions "";
|
lualine_x = mkComponentOptions "encoding";
|
||||||
lualine_y = mkComponentOptions "";
|
lualine_y = mkComponentOptions "progress";
|
||||||
lualine_z = mkComponentOptions "";
|
lualine_z = mkComponentOptions "location";
|
||||||
};
|
};
|
||||||
})
|
|
||||||
"Tabline configuration";
|
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";
|
||||||
|
|
||||||
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
|
||||||
|
|
82
tests/test-sources/plugins/statuslines/lualine.nix
Normal file
82
tests/test-sources/plugins/statuslines/lualine.nix
Normal 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"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue