Previously the deprecated builders would warn when used on a lib _with_
`pkgs`, but were simply not present on a lib _without_ `pkgs`.
Now, they are always present, but will throw when evaluated on a lib
_without_ `pkgs`.
In the two places where our "helpers" lib is exclusively internal
(flake module args and building the docs), we no longer supply `pkgs`.
In the other 4 locations, we now note why we still do in a comment.
This commit adds a `plugins.<name>.luaConfig` section controlling the
plugin specific configuration.
The section contains the internal `init` option, containing the plugin's
initialization code.
It also contains the public `pre` and `post` options, that allow to add
code before & after the `init` section
Finally, it contains the `final` option, being the concatenation of the
three previous options.
These functions had very similar bugs: they didn't check if their chosen
"close token" was already present in the string they're escaping.
I went ahead and did the work implied by the TODOs: search for a "close
token" that is *not* in the original string. Pretty simple concept, but
it turned into an annoying amount of code. I couldn't find anything in
upstream nixpkgs lib, or some clever insight about lua/vimscript that
makes this work unecessary, but I'll be thrilled (and a little bummed
about a wasted afternoon) to learn about something.
Splits everything that depends on a `pkgs` instance into an optional
attrs, allowing `helpers.nix` to be bootstrapped without `pkgs`.
This required some refactoring:
- `modules.specialArgs` is only available when `pkgs` is used
- `modules.specialArgsWith` now requires `defaultPkgs` be provided
- `builders.*` now have `*With` variants that take `pkgs` as an argument
and a `withPkgs` function that returns the old interface
- Had to define the fixed part of `builders` outside the attrs for now,
to avoid infinite recursion.
- The old `builders` are now deprecated, and print a warning when
evaluated
- `withOptoinalFns` was introduced to merge the optional attrs into the
final lib.
The old `default.nix` is inlined into the "lib" flake-module, which is
the only place it was used.
This allows "helpers" to take its rightful place at the root of `./lib` 👑
Instead of maintainers providing an actual `defaultPackage`, they should
specify the pkg name which we'll use when calling `lib.mkPackageOption`.
This makes `mkVimPlugin` and `mkNeovimPlugin` compliant with #1950.
Since cbd1003d9d I'm able to add _some_
invalid config definitions to modules the tests are using and get no
build error.
For example `extraConfigLua = null;` should produce an invalid type
error, but doesn't.
One less visible change in that commit is the move away from using the
"standalone" wrapper (`makeNixvimWithModule`), which implicitly sets
`wrapRc = true`.
Adding back `wrapRc` to the tests seems to fix the issue, however this
makes me wonder if there's an underlying issue with wrapping/not-wrapping?
Perhaps we've simply uncovered a long-standing eval issue that is masked
over by using `wrapRc`?
Warnings and assertions defined as `config.warnings` and `config.assertions`
respectively will be checked as part of the test derivation, instead of
when evaluating the modules.
Adds new `checkWarnings` and `checkAssertions` test options (default true).
Introduces the `test.runNvim` module option.
Deprecates the historic `dontRun` argument passed to the test-derivation
helpers.
Soft-deprecates the `tests.dontRun` attr used in tests currently.
- Replace nullable lua option with a no-default option.
- Made it so the deprecated option is only declared when `lua = true` is passed.
- Replace `normalizeMappings` with a `removeDeprecatedMapAttrs` helper.
- Added warnings for all options that historically had `lua` support.
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.