Commit graph

363 commits

Author SHA1 Message Date
Austin Horstman
3f17f500b3
lib/maintainers: remove duplicate entry 2024-09-26 10:45:23 -05: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
47364df496
lib/types/pluginLuaConfig: use lib.optional instead of lib.mkIf
This may slightly increase performance by reducing work done by the
module system.
2024-09-23 20:08:52 +01:00
Matt Sturgeon
81ae3febd2
lib: throw when deprecated builders are used on a lib without pkgs
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`.
2024-09-22 18:18:05 +01:00
Matt Sturgeon
191b0a9502
treewide: avoid passing pkgs to our lib
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.
2024-09-22 18:18:05 +01:00
Matt Sturgeon
76df09619d
lib/types/pluginLuaConfig: only merge pre and post when defined
- Have them default to `null`
- Only merge them into `content` when non-null
- Mention this in `content`'s description
2024-09-22 17:49:41 +01:00
Quentin Boyer
d2f9e011d9 lib/neovim-plugin: Add lua configuration scoped to the plugin
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.
2024-09-22 16:15:27 +00:00
Jeremy Fleischman
400d1d927d
lib: fix escaping bugs in wrapVimscriptForLua and wrapLuaForVimscript
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.
2024-09-19 15:41:46 -07: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
f47e8f8f79
lib: use lib.fix and self internally 2024-09-13 17:25:17 +01:00
Matt Sturgeon
7a147234f8
lib: rename helpers.nix -> default.nix
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` 👑
2024-09-13 17:25:17 +01:00
Matt Sturgeon
27a0dd435d
lib/types: simplify eitherRecursive by defining it only once 2024-09-12 14:44:54 +01:00
Matt Sturgeon
555035ef79
lib: add types.flagInt + defaultNullOpts.mkIntFlag
Either `0` or `1`, but can be coerced from a boolean definition to
support legacy definitions.

When coerced, a warning is printed
2024-09-08 12:54:30 +01:00
Matt Sturgeon
fd923a3dd3
lib/options: remove deprecated package option helpers
`mkPackageOption` and `mkPluginPackageOption` have both been replaced
with nixpkg's `lib.mkPackageOption`.
2024-09-05 02:24:52 +01:00
Matt Sturgeon
cdb2e79e51
lib/pkg-lists: move to common location
Extract the helper functions defined in `efmls-configs-pkgs` to a common
location where they can also be used by none-ls's package list.
2024-09-04 20:29:52 +01:00
Austin Horstman
35788bbc5a
lib: cleanup with lib 2024-09-03 22:12:33 -05:00
Matt Sturgeon
1fd4b6c739
plugins: migrate defaultPackage -> package
Migrate all users of `mkVimPlugin` and `mkNeovimPlugin` to use the new
`package` argument instead of the old `defaultPackage` argument.
2024-09-04 03:29:34 +01:00
Matt Sturgeon
285f6cbd7b
lib/*-plugin: use lib.mkPackageOption internally
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.
2024-09-04 03:07:49 +01:00
Matt Sturgeon
18b7597e6c
lib/neovim-plugin: drop config arg 2024-09-02 10:35:52 +01:00
Matt Sturgeon
2a054b039e
lib/vim-plugin: drop config arg
Instead, access it via an imported module
2024-09-02 10:33:50 +01:00
Andrew Plaza
204f1aecf2
maintainers: add insipx 2024-09-02 02:05:40 -04:00
refaelsh
f3362d2e9d
lib/maintainers: add refaelsh 2024-09-01 15:51:46 -05:00
Matt Sturgeon
9af4c3970c
tests: fix tests by enabling wrapRc
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`?
2024-08-26 21:57:05 +01:00
Matt Sturgeon
fa2058970c
lib/tests.nix: fix infinite recursion in args 2024-08-26 21:57:05 +01:00
elythh
aa1f5a74ff plugins/comment-box-nvim: init 2024-08-26 20:28:32 +02: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
b7f419a759
lib: migrate helpers.nixvimTypes -> lib.types 2024-08-21 07:37:11 +01:00
Matt Sturgeon
b414a53649
lib/types: merge into extendedLib 2024-08-21 07:37:11 +01:00
Matt Sturgeon
19d5f4b134
lib/test: move from tests/test-derivation 2024-08-21 02:48:06 +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
851edc8df1
lib/modules: add evalNixvim
Evaluates a nixvim config, by default also checking warnings and assertions.

This used internally by the standalone wrapper.
2024-08-20 22:22:53 +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
8f99c3953c
lib/util: add groupListBySize
Splits up a list into many sub-lists based on the given max-size.

e.g.
```nix
groupListBySize 2 [ 1 2 3 4 5 ]
=> [ [ 1 2 ] [ 3 4 ] [ 5 ] ]
```
2024-08-19 00:50:57 +01:00
Matt Sturgeon
7a11b66f11
lib/keymap: allow extra options/modules in mkMapOptionSubmodule
This is needed to allow plugins to add bespoke features to their keymap
submodules without having to re-implement the whole thing.
2024-08-18 22:38:24 +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
db4c4e5b17 lib/deprecation: expose mkSettingsRenamedOptionModules publicly
Extracted the `optionsRenamedToSettings` implementation
from`mkVimPlugin` and `mkNeovimPlugin` into a new public helper.
2024-08-14 11:20:17 +00:00
Austin Horstman
e3ec1c4a46 plugins/which-key: move listOfLen to lib.types
Allows us to require a list to have a certain length for plugins that
request it.
2024-08-14 11:20:17 +00:00
Matt Sturgeon
4eb2ad7db7
lib/lua: support nixpkg's "lua-inline" type
See #1935
2024-08-14 00:25:59 +01:00
psfloyd
6c1e87676c maintainers: add psfloyd 2024-08-06 22:58:32 -03:00
Matt Sturgeon
27c4c9c210
lib/modules: init with specialArgs helpers 2024-08-02 14:38:38 +01:00
Matt Sturgeon
491ca5cf51
lib: provide an "extended lib" to our modules
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.
2024-08-02 14:33:59 +01:00
Matt Sturgeon
7c39d77b9f
lib/helpers: scope each subsection, but offer aliases 2024-08-01 18:05:00 +01:00
Matt Sturgeon
bc84fda2b8
lib/options: remove with helpers 2024-08-01 17:55:03 +01:00
Stanislav Asunkin
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 Asunkin
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
Matt Sturgeon
040bab5f55
lib/helpers: call with auto-args
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.
2024-07-28 22:51:24 +01:00
Matt Sturgeon
0e98d9cf1e
lib/helpers: build recursively 2024-07-28 22:30:11 +01:00
GGORG
230f95eae0 maintainers: add GGORG 2024-07-25 13:40:08 +02:00
Nathan Felber
a1bd7aebc6
maintainers: add NathanFelber 2024-07-24 10:15:51 +01:00
Stanislav Asunkin
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