Commit Graph
146 Commits
Author SHA1 Message Date
Matt Sturgeon c4ad4d0b2e modules/nixpkgs: add overlays option
Based on the `nixpkgs.overlays` option available in NixOS, allows users
to further customize the `pkgs` instance used when evaluating nixvim.

The standard module tests are now provided a few extra module args to
enable a test where we instantiate a custom nixpkgs instance.
2024-10-19 21:11:42 +01:00
Matt Sturgeon b9d17d5e6c modules/nixpkgs: restructure nixpkgs.pkgs.isDefined assertion
We can throw inline to ensure our error is displayed before any attempt
to use the (non-existent) `pkgs` arg results in a less helpful error.
2024-10-19 21:11:42 +01:00
Stanislav Asunkin 767eb62f48 modules/output: obtain plugin configs from wrapped neovim
The official method for obtaining the generated initRc content is from
wrapped neovim rather than from makeNeovimConfig helper. To use this
approach: first wrap neovim with the generated config, then override it
with our wrapperArgs.
2024-10-13 09:54:05 +03:00
Stanislav Asunkin ba77e88740 modules/output: remove unused binding 2024-10-13 09:33:20 +03:00
Matt Sturgeon 4b7a41276a modules/nixpkgs: initial pkgs option, drop defaultPkgs specialArg
This minimal implementation allows `nixpkgs.pkgs` to be defined, but
does not implement evaluating an instance from a pkgsPath when _not_
defined.

The `defaultPkgs` specialArg is dropped in favour of `nixpkgs.pkgs`
being defined. If it's not defined, an assertion is thrown.

In the future, a nixpkgs source path can be supplied, defaulting to the
flake's `inputs.nixpkgs`. Along with other `nixpkgs.*` options, this
will allow a `pkgs` instance to be evaluated within the module eval.
2024-09-27 09:30:12 +01:00
Matt Sturgeon 8c3d521bff modules: move nixpkgs module to top-level modules
Make `pkgs` available to files submodules by passing _all_ module args
through. We already did this for `specialArgs`.
2024-09-27 09:30:12 +01:00
Matt Sturgeon 2f49c76a6a lib: remove nixvimTypes alias 2024-09-27 08:31:07 +01:00
Matt Sturgeon 6a1bf6bdc3 modules/output: check warnings+assertions on build.package
Add a `build.packageUnchecked` option for use instead of the old `check`
evalNixvim argument.
2024-09-26 18:04:36 +01:00
Matt Sturgeon 2ab8751b8b modules/output: add build.initSource option
Allows access to the init "source" file even when
`performance.byteCompileLua` is enabled.
2024-09-26 06:31:57 +01:00
Matt Sturgeon 692e39311e modules/{output,files,test}: move outputs to build scope
Move the following output options into `build`:
- finalPackage -> package
- printInitPackage
- initPath -> initFile
- filesPlugin -> extraFiles
- test.derivation -> test
2024-09-26 06:31:57 +01:00
Matt Sturgeon 7bda0f1ce4 modules/output: don't remove "site" dir when impureRtp is disabled
This is required for storing the state of several things, such as spell
files.
2024-09-25 18:43:32 +01:00
Matt Sturgeon 11924e1593 modules/output: add impureRtp option
Instead of assuming `wrapRc` implies we don't want impurities, configure
this separately.
2024-09-25 18:43:32 +01:00
Matt Sturgeon fb7cda2868 modules/output: refactor wrapRc default
Set default to `true`, with a low priority. Home-manager's wrapper sets
its own default using `mkOptionDefault`.

Clarify using `defaultText`.
2024-09-25 18:43:10 +01:00
Matt Sturgeon b3a90d737d modules/files: don't set shorthandOnlyDefinesConfig 2024-09-24 19:17:44 +01:00
Matt Sturgeon 6da94195c2 modules/misc: include assertions and meta modules in the repo
Based on the modules we previously imported from NixOS.

This will allow us to drop the `defaultPkgs` specialArg and avoids
needing the proposed `pkgsPath` specialArg.
2024-09-24 12:49:28 +01:00
Matt Sturgeon 4e5bd1d79b lib: segregate and deprecate functions that need pkgs
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.
2024-09-13 19:05:26 +01:00
Matt Sturgeon 48e9af500c plugins/by-name: remove pathExists check 2024-09-09 11:50:41 +01:00
Matt Sturgeon faff32b9f1 plugins/by-name: init
Add support for automatically importing any directories under
`plugins/by-name`.

Includes a validation test, which is run by CI and by the pre-commit hook.
2024-09-09 11:50:38 +01:00
Matt Sturgeon c4a54da4a5 modules/output: use mkPackageOption for package option 2024-09-04 21:56:48 +01:00
Austin Horstman 1c9ba58aef modules: cleanup with lib 2024-09-03 22:12:33 -05:00
Matt Sturgeon 4814147442 modules/test: add config and options passthrus
This should make inspection of tests a little easier.
2024-08-28 00:08:10 +01:00
Matt Sturgeon af31063538 modules/test: switch to runCommand 2024-08-28 00:08:10 +01:00
Austin Horstman 8a272143ee modules/opts: move options to top of init.lua
Using mkOrder to ensure the options can be accessible to everything
throughout the config. Setting right below global table available, so
variables can reference stuff inside global table.
2024-08-24 11:50:06 -05:00
Austin Horstman 203d31810f top-level/output: add global table top of init.lua
Creating a global table at top of init.lua to allow sharing between
different sections of the init.lua without worrying about ordering.
2024-08-24 11:33:08 -05:00
Matt Sturgeon 088e584e54 modules/test: check warnings/assertions
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).
2024-08-22 14:46:55 +01:00
Matt Sturgeon 38b09c1621 modules/test: remove docker dependency 2024-08-21 02:48:26 +01:00
Matt Sturgeon cbd1003d9d modules/test: move test derivation to an option
Introduced the `test.derivation` read-only option.
2024-08-21 02:48:00 +01:00
Matt Sturgeon bc7a7ad1d6 module/outputs: use mkIf for wrapRc
Implement the `wrapRc` option using `lib.mkIf` instead of using _real_
`if` branches.
2024-08-20 22:02:29 +01:00
Matt Sturgeon 6975ee09f5 modules/outputs: make type readOnly at the top-level
Instead of relying on `lib.mkForce` we can enforce this more strictly by
setting the option "readOnly".
2024-08-20 22:02:29 +01:00
Matt Sturgeon c4fcbb0dcf modules/context: add isTopLevel option 2024-08-20 22:02:29 +01:00
Matt Sturgeon f47374fd26 modules/test: init, replacing dontRun arg
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.
2024-08-20 00:34:12 +01:00
Matt Sturgeon 7fb1f9dd9d modules/keymap: improve lua deprecation
- 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.
2024-08-18 22:11:11 +01:00
Austin Horstman 6ab17b1b2e top-level/output: include meta in package
Required to prevent errors due to missing license information in
neovim-wrapper.
2024-08-15 22:28:28 -05:00
Matt Sturgeon 27c4c9c210 lib/modules: init with specialArgs helpers 2024-08-02 14:38:38 +01:00
Stanislav AsunkinandGaetanLepage 9314cd46f0 modules/performance: add ability to byte compile nvim runtime directory
This commit adds `performance.byteCompileLua.nvimRuntime` toggle that,
if enabled, byte compiles all lua files in Nvim runtime directory.
2024-07-31 11:31:40 +00:00
Stanislav AsunkinandGaetanLepage 55ca9d235b modules/performance: add ability to byte compile lua plugins
This commit adds `performance.byteCompileLua.plugins` toggle that, if
enabled, byte compiles all lua files in plugins
2024-07-31 11:31:40 +00:00
Stanislav AsunkinandGaetanLepage 44849233e0 modules/performance: add ability to byte compile lua configuration files
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.
2024-07-31 11:31:40 +00:00
Stanislav AsunkinandGaetanLepage 17e8904992 modules/performance: add performance.byteCompileLua option
* 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
2024-07-31 11:31:40 +00:00
Stanislav Asunkinandtraxys 0ac10f6776 modules/performance: refactor after code review 2024-07-24 16:50:50 +02:00
Stanislav Asunkinandtraxys 6e2ec5ed02 modules/performance: add plenary filetypes directory to default pathsToLink
plenary.nvim is often pulled as a dependency of other plugins.
It has filetype definitions in `data/plenary/filetypes` directory.
Even though I don't think there are plugins using it instead of
vim.filetype, but it should be no harm to add this directory by default.
2024-07-24 16:50:50 +02:00
Stanislav Asunkinandtraxys 0c32f5bda5 modules/performance: don't combine filesPlugin into plugin pack
It's expected that user may want to override some runtime files in its
own config directory. Do not combine it into plugin pack to avoid
collisions.
2024-07-24 16:50:50 +02:00
Stanislav Asunkinandtraxys e65c9590d0 modules/performance: add combinePlugins.standalonePlugins option 2024-07-24 16:50:50 +02:00
Stanislav Asunkinandtraxys d6bebcefa3 modules/performance: handle plugin configs when combining plugins 2024-07-24 16:50:50 +02:00
Stanislav Asunkinandtraxys 27201addd7 modules/performance: handle optional plugins when combining plugins 2024-07-24 16:50:50 +02:00
Stanislav Asunkinandtraxys f900dcd6aa modules/performance: handle python3 dependencies when combining plugins 2024-07-24 16:50:50 +02:00
Stanislav Asunkinandtraxys fdb3950c59 modules/performance: add an option to combine plugins to a single plugin pack 2024-07-24 16:50:50 +02:00
Stanislav Asunkinandtraxys 119f12db27 modules/output: avoid using global with lib; 2024-07-24 16:50:50 +02:00
Stanislav AsunkinandGaétan Lepage 9317537848 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.
2024-07-22 23:18:53 +02:00
Stanislav AsunkinandGaétan Lepage 299d0406bb modules/output: refactor config generation
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
2024-07-22 23:18:53 +02:00
Stanislav Asunkin 34aa3e00e7 modules/filetype: ensure that the module does not set empty settings
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.
2024-07-22 11:33:52 +03:00