From ed30fd858848be9b0f13d48cfa9ae6fd00df21d6 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Wed, 20 Nov 2024 16:24:36 +0100 Subject: [PATCH] modules/opts: fix code generation condition to prevent false positives Currently, we generate the lua code as soon as the value of the option is not an empty attrs. However, a case where the attrs only contains `null` values (`nord_colorscheme = null; nord_foo = null;}` would pass the `if` condition, but the generated lua table would still be empty because `toLua` filters out those values. Hence, we should directly check if the attrs would be translated to an empty lua table or not to decide whether we should generate the lua snippet or not. --- modules/opts.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/opts.nix b/modules/opts.nix index 10c74a76..4ca93d63 100644 --- a/modules/opts.nix +++ b/modules/opts.nix @@ -67,12 +67,12 @@ in }: let varName = "nixvim_${luaVariableName}"; - optionDefinitions = config.${optionName}; + optionDefinitions = helpers.toLuaObject config.${optionName}; in - lib.optionalString (optionDefinitions != { }) '' + lib.optionalString (optionDefinitions != "{ }") '' -- Set up ${prettyName} {{{ do - local ${varName} = ${helpers.toLuaObject optionDefinitions} + local ${varName} = ${optionDefinitions} for k,v in pairs(${varName}) do vim.${luaApi}[k] = v