modules/statusline: switch to explicit lib calls

This commit is contained in:
raf 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 = [ imports = [
./lualine ./lualine
]; ];

View file

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

View file

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

View file

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