lib/extend-lib.nix returns a nixpkg's lib extended with our own
helpers.
This is exposed as `helpers.extendedLib`, but when evaluating our
modules it should be assigned to `specialArgs.lib`.
Outside of our modules you must still access our helpers via
`config.lib.nixvim` or `config.lib.nixvim.extendedLib`.
Within helpers' sub-sections, `lib` is the extended lib.
This commit adds support for byte compiling lua configuration files.
It's enabled by default (if byte compiling is enabled at all) and can be
disabled with `performance.byteCompileLua.configs` toggle.
To implement this feature `extraFiles.<name>.finalSource` internal
read-only option is introduced. `source` option cannot be used because
it's user configurable. In order to access the values of the
`performance.byteCompileLua` options, parent config is added to
specialArgs of extraFiles submodule. Then the usages of `source` option
changed to `finalSource` in all relevant places (filesPlugin and
wrappers).
Added more helpers for various cases of byte compiling:
* `byteCompileLuaFile` byte compiles lua file
* `byteCompileLuaHook` is a setup hook that byte compiles all lua files
* `byteCompileLuaDrv` overrides derivation by adding byteCompileLuaHook
to it
Added tests to validate that extraFiles specified by various methods are
handled correctly. Added a separate home-manager test, that is intended
to validate that extraFiles propagated to wrapper modules are correctly
byte compiled.
* add `performance.byteCompileLua.enable` toggle to enable or disable
all byte compiling features
* add `performance.byteCompileLua.initLua` toggle to enable or
disable byte compiling of init.lua
* add `writeByteCompiledLua` helper for saving byte compiled lua source
code to the nix store
* `nixvim-print-init` utility is always pointed to uncompiled init.lua
* add tests
Define `call = callPackageWith { inherit pkgs lib helpers; }`, which can
be used to automatically pass the correct args into helpers files.
`helpers` is passed in recursively.
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
Based on `types.coerceTo`, which is like `types.either` but coerces the
left-hand type into the right-hand type.
`transitionType` only shows the right-hand type in its description and
also prints a warning when the left-hand type is used.
Co-authored-by: Silvan Mosberger <contact@infinisil.com>
- The `setup` function name can be overridden with `setup`
(default ".setup")
- The entire `settings` option description can be overridden with
`settingsDescription`
- `luaName` and `setup` are used in the default description
No longer assume that string-type plugin defaults are already
pre-formatted.
Instead, pre-formatted values should be defined using
`literalExpression` or `literalMD`.
All helpers eventually go through `mkNullOrOption`, so we can move where
`pluginDefault` is handled there.
Added a private helper `processNixvimArgs` that can be used by any future
helper that needs to call `lib.mkOption` directly.
It might make sense to offer a `helpers.mkOption` which simply wraps
`lib.mkOption` but with support for custom args like `pluginDefault`?
Introduce a new `helpers.pluginDefaultText` and deprecate `helpers.defaultNullOpts.mkDesc`.
Displaying the "plugin default" within `defaultText` ensures that both
defaults are grouped together in the docs.
Also take the first step towards transitioning `defaultNullOpts` from
using `default` to `pluginDefault` to mean "plugin default".
Made the `default` and `description` arguments optional for all prime
variants of `defaultNullOpts` functions.
If neither `default` nor `description` are provided, the option will
have no description.
The "Plugin default" line is only added when a `default` argument is
present (`args ? default`).
Allow passing in `key` and `action` as either bool or an attrset.
If `false`, the option is omitted. If `true` or an attrset, the option is included.
If an attrset is used, it will update the default `mkOption` args.
This is useful for overriding `type` or adding an `example`.