From a89c8a9a97e3e6d715b402011e2bb247624b9de6 Mon Sep 17 00:00:00 2001 From: Jake Hamilton Date: Fri, 22 Mar 2024 05:09:10 -0700 Subject: [PATCH] feat: allow custom formatting for status components (#1018) --- plugins/statuslines/lualine.nix | 14 +++++++++++++- tests/test-sources/plugins/statuslines/lualine.nix | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/statuslines/lualine.nix b/plugins/statuslines/lualine.nix index 46fb7342..67640928 100644 --- a/plugins/statuslines/lualine.nix +++ b/plugins/statuslines/lualine.nix @@ -80,6 +80,17 @@ with lib; let "1" "Adds padding to the left and right of components."; + fmt = helpers.mkNullOrLuaFn '' + A lua function to format the component string. + + Example: + ```lua + function(text) + return text .. "!!!" + end + ``` + ''; + extraConfig = mkOption { type = types.attrs; default = {}; @@ -209,6 +220,7 @@ in { color, padding, extraConfig, + fmt, }: mergeAttrs { @@ -217,7 +229,7 @@ in { if isAttrs icon then removeAttrs (icon // {"__unkeyed" = icon.icon;}) ["icon"] else icon; - inherit icons_enabled separator color padding; + inherit icons_enabled separator color padding fmt; } extraConfig; processSections = mapAttrs (_: mapNullable (map processComponent)); diff --git a/tests/test-sources/plugins/statuslines/lualine.nix b/tests/test-sources/plugins/statuslines/lualine.nix index 02ca16e1..6015c808 100644 --- a/tests/test-sources/plugins/statuslines/lualine.nix +++ b/tests/test-sources/plugins/statuslines/lualine.nix @@ -85,6 +85,11 @@ TelescopePrompt = "Telescope"; NvimTree = "NvimTree"; }; + fmt = '' + function(value) + return value + end + ''; } ]; lualine_z = [