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.
The motivation for this change was to avoid generating empty
config sections like
vim.cmd([[
]])
To make a config generation cleaner several helper functions introduced:
* `hasContent` have been moved to helpers
* `concatNonEmptyLines` joins strings (which has content) separated with
newlines
* `wrapVimscriptForLua` wraps a lua string for using in Vimscript, but
only if the string has content, otherwise empty string is returned
* `wrapLuaForVimscript` wraps Vimscript for using in lua, but only if
the string has content, otherwise empty string is returned
Added tests:
* testing that all possible config sections are present in the final
generated config
* testing that the config files generated by empty `files` definitions
don't have any content in it
When setting any filetype suboption to null (or anything else guarded by
mkIf) it's value becomes:
{ extension = null; filename = null; pattern = null; }
Account for that case in mkIf condition so that the option would not
produce empty filetype definition.
This avoids having the option always "defined".
This also avoids luaLoader configuration in extra files by default.
Earlier `vim.loader.disable()` was always added to configs produced
by `files` option, effectively disabling luaLoader even if it was
explicitly enabled in a top-level configuration.
Moved `extraFiles` from `modules/output.nix` into its own file `modules/files.nix`.
Users should now assign text to a `text` attribute, however they could
also assign a file path to a `source` attribute instead.
The old method of directly assigning a string still works, and is
coerced to the new type along with a deprecation warning.
Replaced the `isDocs` specialArg added in #1807 with an internal module
option.
We should only use `specialArgs` when absolutely necessary, a module or
`_module.args` is preferred, but those aren't available until `config`
is evaluated so they can't be used for `imports`.
The main problem with `specialArgs` is it makes our modules less
portable.
Luckily that shouldn't be an issue for these context flags.
This (internal) option introduces IFD, and can be substituted internally
with the `initPath` option easily.
If the content is required somewhere users can use readFile on the
initPath, though it will result in an IFD in their project.
`lib.evalModules` always includes `lib`, `config`, `options`, &
(configured) `specialArgs` in the (final) `specialArgs`[1].
Therefore, setting `_module.args.lib` has no effect.
[1]: 329d232802/lib/modules.nix (L233)
Let's simplify things by defining all modules in `./plugins`, `./modules`
and `./wrappers/modules`.
Instead of currying `pkgs` into a bootstrapping module, we can require
`defaultPkgs` be provided as a special arg.
This refactor allows us to completely remove `flake-modules/modules.nix`!