modules/statusline: switch to explicit lib calls

This commit is contained in:
NotAShelf 2024-03-12 03:47:57 +03:00
parent e80f2c9280
commit 3a9f5db55f
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
4 changed files with 63 additions and 55 deletions

View file

@ -1,4 +1,4 @@
{...}: {
{
imports = [
./lualine
];

View file

@ -3,16 +3,21 @@
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.strings) optionalString;
inherit (lib.nvim.lua) luaTable listToLuaTable;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.statusline.lualine;
breadcrumbsCfg = config.vim.ui.breadcrumbs;
inherit (lib) mkIf nvim boolToString optionalString;
in {
config = (mkIf cfg.enable) {
vim.startPlugins = [
"lualine"
];
vim.luaConfigRC.lualine = nvim.dag.entryAnywhere ''
vim.luaConfigRC.lualine = entryAnywhere ''
local lualine = require('lualine')
lualine.setup {
options = {
@ -20,10 +25,10 @@ in {
theme = "${cfg.theme}",
component_separators = {"${cfg.componentSeparator.left}","${cfg.componentSeparator.right}"},
section_separators = {"${cfg.sectionSeparator.left}","${cfg.sectionSeparator.right}"},
disabled_filetypes = ${nvim.lua.listToLuaTable cfg.disabledFiletypes},
disabled_filetypes = ${listToLuaTable cfg.disabledFiletypes},
always_divide_middle = ${boolToString cfg.alwaysDivideMiddle},
globalstatus = ${boolToString cfg.globalStatus},
ignore_focus = ${nvim.lua.listToLuaTable cfg.ignoreFocus},
ignore_focus = ${listToLuaTable cfg.ignoreFocus},
extensions = {${optionalString config.vim.filetree.nvimTree.enable "'nvim-tree'"}},
refresh = {
statusline = ${toString cfg.refresh.statusline},
@ -34,22 +39,22 @@ in {
-- active sections
sections = {
lualine_a = ${nvim.lua.luaTable (cfg.activeSection.a ++ cfg.extraActiveSection.a)},
lualine_b = ${nvim.lua.luaTable (cfg.activeSection.b ++ cfg.extraActiveSection.b)},
lualine_c = ${nvim.lua.luaTable (cfg.activeSection.c ++ cfg.extraActiveSection.c)},
lualine_x = ${nvim.lua.luaTable (cfg.activeSection.x ++ cfg.extraActiveSection.x)},
lualine_y = ${nvim.lua.luaTable (cfg.activeSection.y ++ cfg.extraActiveSection.y)},
lualine_z = ${nvim.lua.luaTable (cfg.activeSection.z ++ cfg.extraActiveSection.z)},
lualine_a = ${luaTable (cfg.activeSection.a ++ cfg.extraActiveSection.a)},
lualine_b = ${luaTable (cfg.activeSection.b ++ cfg.extraActiveSection.b)},
lualine_c = ${luaTable (cfg.activeSection.c ++ cfg.extraActiveSection.c)},
lualine_x = ${luaTable (cfg.activeSection.x ++ cfg.extraActiveSection.x)},
lualine_y = ${luaTable (cfg.activeSection.y ++ cfg.extraActiveSection.y)},
lualine_z = ${luaTable (cfg.activeSection.z ++ cfg.extraActiveSection.z)},
},
-- inactive sections
inactive_sections = {
lualine_a = ${nvim.lua.luaTable (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a)},
lualine_b = ${nvim.lua.luaTable (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b)},
lualine_c = ${nvim.lua.luaTable (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c)},
lualine_x = ${nvim.lua.luaTable (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x)},
lualine_y = ${nvim.lua.luaTable (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y)},
lualine_z = ${nvim.lua.luaTable (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z)},
lualine_a = ${luaTable (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a)},
lualine_b = ${luaTable (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b)},
lualine_c = ${luaTable (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c)},
lualine_x = ${luaTable (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x)},
lualine_y = ${luaTable (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y)},
lualine_z = ${luaTable (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z)},
},
-- tabline (currently unsupported)

View file

@ -1,4 +1,4 @@
_: {
{
imports = [
./lualine.nix
./config.nix

View file

@ -3,7 +3,10 @@
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types elem optional;
inherit (builtins) elem;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) int bool str listOf enum;
inherit (lib.lists) optional;
supported_themes = import ./supported_themes.nix;
colorPuccin =
@ -20,44 +23,44 @@ in {
refresh = {
statusline = mkOption {
type = types.int;
type = int;
description = "Refresh rate for lualine";
default = 1000;
};
tabline = mkOption {
type = types.int;
type = int;
description = "Refresh rate for tabline";
default = 1000;
};
winbar = mkOption {
type = types.int;
type = int;
description = "Refresh rate for winbar";
default = 1000;
};
};
globalStatus = mkOption {
type = types.bool;
type = bool;
description = "Enable global status for lualine";
default = true;
};
alwaysDivideMiddle = mkOption {
type = types.bool;
type = bool;
description = "Always divide middle section";
default = true;
};
disabledFiletypes = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Filetypes to disable lualine on";
default = ["alpha"];
};
ignoreFocus = mkOption {
type = with types; listOf str;
type = listOf str;
default = ["NvimTree"];
description = ''
If current filetype is in this list it'll always be drawn as inactive statusline
@ -70,7 +73,7 @@ in {
in
mkOption {
description = "Theme for lualine";
type = types.enum ([
type = enum ([
"auto"
"16color"
"gruvbox"
@ -112,13 +115,13 @@ in {
sectionSeparator = {
left = mkOption {
type = types.str;
type = str;
description = "Section separator for left side";
default = "";
};
right = mkOption {
type = types.str;
type = str;
description = "Section separator for right side";
default = "";
};
@ -126,13 +129,13 @@ in {
componentSeparator = {
left = mkOption {
type = types.str;
type = str;
description = "Component separator for left side";
default = "";
};
right = mkOption {
type = types.str;
type = str;
description = "Component separator for right side";
default = "";
};
@ -140,7 +143,7 @@ in {
activeSection = {
a = mkOption {
type = with types; listOf str;
type = listOf str;
description = "active config for: | (A) | B | C X | Y | Z |";
default = [
''
@ -157,7 +160,7 @@ in {
};
b = mkOption {
type = with types; listOf str;
type = listOf str;
description = "active config for: | A | (B) | C X | Y | Z |";
default = [
''
@ -180,7 +183,7 @@ in {
};
c = mkOption {
type = with types; listOf str;
type = listOf str;
description = "active config for: | A | B | (C) X | Y | Z |";
default = [
''
@ -207,7 +210,7 @@ in {
};
x = mkOption {
type = with types; listOf str;
type = listOf str;
description = "active config for: | A | B | C (X) | Y | Z |";
default = [
''
@ -268,7 +271,7 @@ in {
};
y = mkOption {
type = with types; listOf str;
type = listOf str;
description = "active config for: | A | B | C X | (Y) | Z |";
default = [
''
@ -290,7 +293,7 @@ in {
};
z = mkOption {
type = with types; listOf str;
type = listOf str;
description = "active config for: | A | B | C X | Y | (Z) |";
default = [
''
@ -322,32 +325,32 @@ in {
};
extraActiveSection = {
a = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for activeSection.a";
default = [];
};
b = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for activeSection.b";
default = [];
};
c = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for activeSection.c";
default = [];
};
x = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for activeSection.x";
default = [];
};
y = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for activeSection.y";
default = [];
};
z = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for activeSection.z";
default = [];
};
@ -355,69 +358,69 @@ in {
inactiveSection = {
a = mkOption {
type = with types; listOf str;
type = listOf str;
description = "inactive config for: | (A) | B | C X | Y | Z |";
default = [];
};
b = mkOption {
type = with types; listOf str;
type = listOf str;
description = "inactive config for: | A | (B) | C X | Y | Z |";
default = [];
};
c = mkOption {
type = with types; listOf str;
type = listOf str;
description = "inactive config for: | A | B | (C) X | Y | Z |";
default = ["'filename'"];
};
x = mkOption {
type = with types; listOf str;
type = listOf str;
description = "inactive config for: | A | B | C (X) | Y | Z |";
default = ["'location'"];
};
y = mkOption {
type = with types; listOf str;
type = listOf str;
description = "inactive config for: | A | B | C X | (Y) | Z |";
default = [];
};
z = mkOption {
type = with types; listOf str;
type = listOf str;
description = "inactive config for: | A | B | C X | Y | (Z) |";
default = [];
};
};
extraInactiveSection = {
a = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for inactiveSection.a";
default = [];
};
b = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for inactiveSection.b";
default = [];
};
c = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for inactiveSection.c";
default = [];
};
x = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for inactiveSection.x";
default = [];
};
y = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for inactiveSection.y";
default = [];
};
z = mkOption {
type = with types; listOf str;
type = listOf str;
description = "Extra entries for inactiveSection.z";
default = [];
};