feat: separate lualine confiig and apply globalstatus

This commit is contained in:
NotAShelf 2023-03-01 15:22:41 +03:00
parent dee6b4b21b
commit 0a7d4e49ae
No known key found for this signature in database
GPG key ID: 5B5C8895F28445F1
2 changed files with 162 additions and 137 deletions

View file

@ -4,91 +4,56 @@
lib, lib,
... ...
}: }:
with lib; { with lib; let
config = { cfg = config.vim.statusline.lualine;
vim.statusline.lualine = { in {
enable = mkDefault false; config = (mkIf cfg.enable) {
vim.startPlugins = [
"lualine"
];
icons = mkDefault true; vim.luaConfigRC.lualine = nvim.dag.entryAnywhere ''
theme = mkDefault "auto"; require('lualine').setup {
sectionSeparator = { options = {
left = mkDefault ""; icons_enabled = ${boolToString cfg.icons.enable},
right = mkDefault ""; theme = "${cfg.theme}",
}; component_separators = {"${cfg.componentSeparator.left}","${cfg.componentSeparator.right}"},
section_separators = {"${cfg.sectionSeparator.left}","${cfg.sectionSeparator.right}"},
componentSeparator = { disabled_filetypes = { 'alpha' }, -- 'NvimTree'
left = mkDefault ""; always_divide_middle = true,
right = mkDefault ""; globalstatus = ${boolToString cfg.globalStatus},
}; ignore_focus = {'NvimTree'},
refresh = {
activeSection = { statusline = ${toString cfg.refresh.statusline},
# left side of the statusline 4 tabline = ${toString cfg.refresh.tabline},
a = mkDefault "{'mode'}"; winbar = ${toString cfg.refresh.winbar},
b = mkDefault ''
{
{
"filename",
color = {bg='none'},
symbols = {modified = '', readonly = ''},
}, },
},
-- active sections
sections = {
lualine_a = ${cfg.activeSection.a},
lualine_b = ${cfg.activeSection.b},
lualine_c = ${cfg.activeSection.c},
lualine_x = ${cfg.activeSection.x},
lualine_y = ${cfg.activeSection.y},
lualine_z = ${cfg.activeSection.z},
},
--
inactive_sections = {
lualine_a = ${cfg.inactiveSection.a},
lualine_b = ${cfg.inactiveSection.b},
lualine_c = ${cfg.inactiveSection.c},
lualine_x = ${cfg.inactiveSection.x},
lualine_y = ${cfg.inactiveSection.y},
lualine_z = ${cfg.inactiveSection.z},
},
tabline = {},
extensions = {${
if (config.vim.filetree.nvimTreeLua.enable)
then "\"nvim-tree\""
else ""
}},
} }
''; '';
c = mkDefault ''
{
{
"branch",
icon = ' ',
separator = { left = '(', right = ')'},
},
}
'';
# right side of the statusline (x, y, z)
x = mkDefault ''
{
{
"diagnostics",
sources = {'nvim_lsp', 'nvim_diagnostic'},
symbols = {error = '', warn = '', info = '', hint = ''}
},
}
'';
y = mkDefault ''
{
{
"fileformat",
color = {bg='none'}
},
}
'';
z = mkDefault ''
{
{
"progress",
color = {
bg='none',
fg='lavender'
}
},
{
"location",
color = {bg='none', fg='lavender'},
},
{
"filetype",
color = {bg='none', fg='lavender'},
},
}
'';
};
inactiveSection = {
a = mkDefault "{}";
b = mkDefault "{}";
c = mkDefault "{'filename'}";
x = mkDefault "{'location'}";
y = mkDefault "{}";
z = mkDefault "{}";
};
};
}; };
} }

View file

@ -13,14 +13,43 @@ in {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
description = "Enable lualine"; description = "Enable lualine";
default = true;
}; };
icons = mkOption { icons = {
enable = mkOption {
type = types.bool; type = types.bool;
description = "Enable icons for lualine"; description = "Enable icons for lualine";
default = true;
};
};
refresh = {
statusline = mkOption {
type = types.int;
description = "Refresh rate for lualine";
default = 1000;
};
tabline = mkOption {
type = types.int;
description = "Refresh rate for tabline";
default = 1000;
};
winbar = mkOption {
type = types.int;
description = "Refresh rate for winbar";
default = 1000;
};
};
globalStatus = mkOption {
type = types.bool;
description = "Enable global status for lualine";
default = true;
}; };
theme = mkOption { theme = mkOption {
default = "auto";
type = types.enum ( type = types.enum (
[ [
"auto" "auto"
@ -68,11 +97,13 @@ in {
left = mkOption { left = mkOption {
type = types.str; type = types.str;
description = "Section separator for left side"; description = "Section separator for left side";
default = "";
}; };
right = mkOption { right = mkOption {
type = types.str; type = types.str;
description = "Section separator for right side"; description = "Section separator for right side";
default = "";
}; };
}; };
@ -80,11 +111,13 @@ in {
left = mkOption { left = mkOption {
type = types.str; type = types.str;
description = "Component separator for left side"; description = "Component separator for left side";
default = "";
}; };
right = mkOption { right = mkOption {
type = types.str; type = types.str;
description = "Component separator for right side"; description = "Component separator for right side";
default = "";
}; };
}; };
@ -92,31 +125,102 @@ in {
a = mkOption { a = mkOption {
type = types.str; type = types.str;
description = "active config for: | (A) | B | C X | Y | Z |"; description = "active config for: | (A) | B | C X | Y | Z |";
default = ''
{
{
"mode",
separator = {
left = '',
},
},
}
'';
}; };
b = mkOption { b = mkOption {
type = types.str; type = types.str;
description = "active config for: | A | (B) | C X | Y | Z |"; description = "active config for: | A | (B) | C X | Y | Z |";
default = ''
{
{
"filename",
color = {bg='none'},
symbols = {modified = '', readonly = ''},
},
}
'';
}; };
c = mkOption { c = mkOption {
type = types.str; type = types.str;
description = "active config for: | A | B | (C) X | Y | Z |"; description = "active config for: | A | B | (C) X | Y | Z |";
default = ''
{
{
"branch",
icon = ' ',
separator = {
left = '(',
right = ')'
}
},
}
'';
}; };
x = mkOption { x = mkOption {
type = types.str; type = types.str;
description = "active config for: | A | B | C (X) | Y | Z |"; description = "active config for: | A | B | C (X) | Y | Z |";
default = ''
{
{
"diagnostics",
sources = {'nvim_lsp', 'nvim_diagnostic', 'coc'},
symbols = {error = '', warn = '', info = '', hint = ''}
},
}
'';
}; };
y = mkOption { y = mkOption {
type = types.str; type = types.str;
description = "active config for: | A | B | C X | (Y) | Z |"; description = "active config for: | A | B | C X | (Y) | Z |";
default = ''
{
{
"fileformat",
color = {bg='none', fg='lavender'},
symbols = {
unix = '', -- e712
dos = '', -- e70f
mac = '', -- e711
},
},
}
'';
}; };
z = mkOption { z = mkOption {
type = types.str; type = types.str;
description = "active config for: | A | B | C X | Y | (Z) |"; description = "active config for: | A | B | C X | Y | (Z) |";
default = ''
{
{
"progress",
color = {bg='none', fg='lavender'},
},
{
"location",
color = {bg='none', fg='lavender'},
},
{
"filetype",
colored = true,
icon = { align = 'right' },
color = {bg='none', fg='lavender'},
},
}
'';
}; };
}; };
@ -124,82 +228,38 @@ in {
a = mkOption { a = mkOption {
type = types.str; type = types.str;
description = "inactive config for: | (A) | B | C X | Y | Z |"; description = "inactive config for: | (A) | B | C X | Y | Z |";
default = "{}";
}; };
b = mkOption { b = mkOption {
type = types.str; type = types.str;
description = "inactive config for: | A | (B) | C X | Y | Z |"; description = "inactive config for: | A | (B) | C X | Y | Z |";
default = "{}";
}; };
c = mkOption { c = mkOption {
type = types.str; type = types.str;
description = "inactive config for: | A | B | (C) X | Y | Z |"; description = "inactive config for: | A | B | (C) X | Y | Z |";
default = "{'filename'}";
}; };
x = mkOption { x = mkOption {
type = types.str; type = types.str;
description = "inactive config for: | A | B | C (X) | Y | Z |"; description = "inactive config for: | A | B | C (X) | Y | Z |";
default = "{'location'}";
}; };
y = mkOption { y = mkOption {
type = types.str; type = types.str;
description = "inactive config for: | A | B | C X | (Y) | Z |"; description = "inactive config for: | A | B | C X | (Y) | Z |";
default = "{}";
}; };
z = mkOption { z = mkOption {
type = types.str; type = types.str;
description = "inactive config for: | A | B | C X | Y | (Z) |"; description = "inactive config for: | A | B | C X | Y | (Z) |";
default = "{}";
}; };
}; };
}; };
config =
mkIf cfg.enable
{
#assertions = [
# ({
# assertion = if cfg.icons then (config.vim.visuals.enable && config.vim.visuals.nvimWebDevicons.enable) else true;
# message = "Must enable config.vim.visual.nvimWebDevicons if using config.vim.visuals.lualine.icons";
# })
#];
vim.startPlugins = ["lualine"];
vim.luaConfigRC.lualine = nvim.dag.entryAnywhere ''
require'lualine'.setup {
options = {
icons_enabled = ${
if cfg.icons
then "true"
else "false"
},
theme = "${cfg.theme}",
component_separators = {"${cfg.componentSeparator.left}","${cfg.componentSeparator.right}"},
section_separators = {"${cfg.sectionSeparator.left}","${cfg.sectionSeparator.right}"},
disabled_filetypes = { 'packer', 'NvimTree', 'alpha' }
},
sections = {
lualine_a = ${cfg.activeSection.a},
lualine_b = ${cfg.activeSection.b},
lualine_c = ${cfg.activeSection.c},
lualine_x = ${cfg.activeSection.x},
lualine_y = ${cfg.activeSection.y},
lualine_z = ${cfg.activeSection.z},
},
inactive_sections = {
lualine_a = ${cfg.inactiveSection.a},
lualine_b = ${cfg.inactiveSection.b},
lualine_c = ${cfg.inactiveSection.c},
lualine_x = ${cfg.inactiveSection.x},
lualine_y = ${cfg.inactiveSection.y},
lualine_z = ${cfg.inactiveSection.z},
},
tabline = {},
extensions = {${
if config.vim.filetree.nvimTreeLua.enable
then "\"nvim-tree\""
else ""
}},
}
'';
};
} }