From 8aa3a23e9742babdbf98fab17b082fbf1cf1751c Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 12 May 2024 03:17:04 +0200 Subject: [PATCH 1/5] lib: do not filter out empty attrs in toLuaObject --- lib/lua.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/lua.nix b/lib/lua.nix index 9e67b3f..8cef5d5 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -65,6 +65,7 @@ in rec { then if isLuaInline args then args.expr + # if nobody is using this we should get rid of this else if hasAttr "__empty" args then "{ }" else @@ -76,10 +77,7 @@ in rec { then toLuaObject v else "[${toLuaObject n}] = " + (toLuaObject v)) (filterAttrs - ( - _: v: - (v != null) && (toLuaObject v != "{}") - ) + (_: v: v != null) args))) + "}" else if isList args From af72dc105d9aaef1d20e1dc36e6add4d18c60951 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 18 May 2024 14:52:40 +0200 Subject: [PATCH 2/5] lib: remove unused __empty special case in toLuaObject --- lib/lua.nix | 3 --- modules/wrapper/rc/config.nix | 7 +------ 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/lua.nix b/lib/lua.nix index 8cef5d5..e871317 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -65,9 +65,6 @@ in rec { then if isLuaInline args then args.expr - # if nobody is using this we should get rid of this - else if hasAttr "__empty" args - then "{ }" else "{" + (concatStringsSep "," diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index b50531b..c278562 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -60,16 +60,11 @@ config = (attrs) the configuration options for this mapping (noremap, silent...) } */ - normalizeAction = action: let + normalizeAction = action: { # Extract the values of the config options that have been explicitly set by the user config = filterAttrs (_: v: v != null) (getAttrs (attrNames mapConfigOptions) action); - in { - config = - if config == {} - then {"__empty" = null;} - else config; action = if action.lua then mkLuaInline action.action From ac20dfbdd4d1ff1752c6dd7fe10905a5cd8ef049 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Tue, 21 May 2024 06:51:56 -0400 Subject: [PATCH 3/5] lib: add deprecation warning for `__empty` --- lib/lua.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/lua.nix b/lib/lua.nix index e871317..68056b1 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -65,6 +65,11 @@ in rec { then if isLuaInline args then args.expr + else if hasAttr "__empty" args + then + lib.warn '' + Using `__empty` to define an empty lua table is deprecated. Use an empty attrset instead. + '' "{ }" else "{" + (concatStringsSep "," From 69257c03a3a76135971f78ebab9cb54b9b1a823b Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Tue, 21 May 2024 06:55:46 -0400 Subject: [PATCH 4/5] docs: add entry for `__empty` deprecation --- docs/release-notes/rl-0.7.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 9c5d395..5ca9327 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -19,6 +19,8 @@ Release notes for release 0.7 [horriblename](https://github.com/horriblename): - Fix broken treesitter-context keybinds in visual mode +- Depcrecate use of `__empty` to define empty tables in lua. Empty attrset are + no longer filtered and thus should be used instead. [NotAShelf](https://github.com/notashelf) From 68ca227a8767f2141e839b94a8137fa22965184c Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Tue, 21 May 2024 07:08:17 -0400 Subject: [PATCH 5/5] lib: remove alias `lib.warn` --- lib/lua.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/lua.nix b/lib/lua.nix index 68056b1..749e9a3 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -3,7 +3,7 @@ inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON; inherit (lib.attrsets) mapAttrsToList filterAttrs; inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters; - inherit (lib.trivial) boolToString; + inherit (lib.trivial) boolToString warn; in rec { wrapLuaConfig = { luaBefore ? "", @@ -67,7 +67,7 @@ in rec { then args.expr else if hasAttr "__empty" args then - lib.warn '' + warn '' Using `__empty` to define an empty lua table is deprecated. Use an empty attrset instead. '' "{ }" else