mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-03 09:36:10 +02:00
modules: avoid setting empty strings to extraConfig* options
Problem: Some modules are setting empty strings to extraConfig* options with the intention to not generate any config. But empty strings are also values, so they are still concatenated in the final value of extraConfig* options. This results in a multiple empty strings in extraConfigs. Solution: Avoid using optionalString when setting values to extraConfig* options. Use mkIf instead. This commit also fixes mkIf condition in autocmd module. `mkNeovimPlugin` is a special case. To avoid evaluating caller's arguments mkMerge/optionalAttrs pattern is used instead.
This commit is contained in:
parent
299d0406bb
commit
9317537848
7 changed files with 80 additions and 73 deletions
|
@ -55,31 +55,35 @@ in
|
|||
};
|
||||
|
||||
config = {
|
||||
extraConfigLuaPre = concatLines (
|
||||
mapAttrsToList (
|
||||
optionName:
|
||||
{
|
||||
prettyName,
|
||||
luaVariableName,
|
||||
luaApi,
|
||||
...
|
||||
}:
|
||||
let
|
||||
varName = "nixvim_${luaVariableName}";
|
||||
optionDefinitions = config.${optionName};
|
||||
in
|
||||
optionalString (optionDefinitions != { }) ''
|
||||
-- Set up ${prettyName} {{{
|
||||
do
|
||||
local ${varName} = ${helpers.toLuaObject optionDefinitions}
|
||||
extraConfigLuaPre =
|
||||
let
|
||||
content = helpers.concatNonEmptyLines (
|
||||
mapAttrsToList (
|
||||
optionName:
|
||||
{
|
||||
prettyName,
|
||||
luaVariableName,
|
||||
luaApi,
|
||||
...
|
||||
}:
|
||||
let
|
||||
varName = "nixvim_${luaVariableName}";
|
||||
optionDefinitions = config.${optionName};
|
||||
in
|
||||
optionalString (optionDefinitions != { }) ''
|
||||
-- Set up ${prettyName} {{{
|
||||
do
|
||||
local ${varName} = ${helpers.toLuaObject optionDefinitions}
|
||||
|
||||
for k,v in pairs(${varName}) do
|
||||
vim.${luaApi}[k] = v
|
||||
end
|
||||
end
|
||||
-- }}}
|
||||
''
|
||||
) optionsAttrs
|
||||
);
|
||||
for k,v in pairs(${varName}) do
|
||||
vim.${luaApi}[k] = v
|
||||
end
|
||||
end
|
||||
-- }}}
|
||||
''
|
||||
) optionsAttrs
|
||||
);
|
||||
in
|
||||
mkIf (content != "") content;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue