Commit graph

36 commits

Author SHA1 Message Date
Matt Sturgeon
57b61e4267 lib/lua-types: init
An initial set of option types for representing values serialisable into
lua.
2025-06-04 09:07:48 +00:00
Matt Sturgeon
f4a7447d27
lib/util: move docs from lib/index to doc-comments
Moved all function-specific docs from `docs/lib/index.md` into RFC145
doc-comments.

Added `lib.nixvim.lua.toLuaObject` to hold the public docs and serve as
a stable impl of `toLua'` in case we decide to change its defaults.
2025-05-19 00:23:21 +01:00
Matt Sturgeon
5cf8cb5ee6
lib/utils: split into public and internal files
We will include the public file in the docs.
2025-05-19 00:23:20 +01:00
Gaetan Lepage
cfd4b61262 modules/dependencies: init + add curl 2025-04-11 08:51:45 +10:00
Quentin Boyer
a2f01876f7 lib: Harmonize package options which may not exist in nixpkgs 2025-01-31 22:55:38 +00:00
Gaetan Lepage
a7e516b322 lib/utils: add mkAssertions 2025-01-20 14:17:26 +01:00
Gaetan Lepage
02e16b2a76 lib/utils: add mkWarnings 2025-01-20 12:25:33 +00:00
Matt Sturgeon
a70b16976b
lib: export evalNixvim as top-level alias
- `lib.nixvim.evalNixvim`
- `<nixvim>.lib.evalNixvim` (flake output)
2025-01-20 05:23:05 +00:00
Heitor Augusto
f878289722 lib/plugins: make plugin optional when lazy-loading 2024-12-26 23:00:27 +00:00
Matt Sturgeon
aefab28b3b
lib/overlay: init
The overlay allows extending any instance of nixpkgs-lib into a
nixvim-compatible "extended" instance.
2024-12-23 09:58:54 +00:00
Matt Sturgeon
214731d355
lib/plugins: deprecate neovim-plugin & vim-plugin aliases 2024-12-22 10:29:38 +00:00
Matt Sturgeon
ec97297fd5
lib/plugins: separate main factory functions 2024-12-22 09:35:16 +00:00
Matt Sturgeon
88a1c1b46a
lib/plugins: organise plugin-factory functions in a subdir 2024-12-22 09:35:15 +00:00
Matt Sturgeon
e2ef15a665
lib: add extend function 2024-12-21 15:14:30 +00:00
Gaetan Lepage
1d50fa4f63 lib: add applyPrefixToAttrs 2024-12-17 21:40:20 +00:00
Matt Sturgeon
bef9feb446
lib/modules: pass inputs.nixpkgs into evalNixvim
Expose our locked nixpkgs as the `nixpkgs.source` module options.

This only happens when `evalNixvim` is part of a lib that was provided
`flake` as an argument.

Stubbed the `nixpkgs.source` option for now. Eventually, this will be
used to construct `pkgs` internally. For now, it's purely informational.
2024-12-15 18:41:23 +00:00
Matt Sturgeon
32027965d8
lib: remove dependency on pkgs 2024-12-15 18:24:57 +00:00
psfloyd
6ed719dba8
lib/options: added mkLazyLoadOption 2024-12-10 08:28:16 -06:00
Matt Sturgeon
da6e3499d4
lib/utils: add nestedLiteral and nestedLiteralLua
`nestedLiteral` converts a `literalExpression` into a `toPretty` style
pretty-printer.

`nestedLiteralLua` composes `nestedLiteral` and `literalLua` together.
2024-11-15 21:46:25 +00:00
Matt Sturgeon
eb76e62a9b
lib/utils: add literalLua for use in option docs
Creates a `literalExpression` equivalent to using `lib.nixvim.mkRaw`.
2024-11-15 21:46:25 +00:00
Matt Sturgeon
cd76b4feb8
lib: remove helpers from internal usage 2024-09-29 14:41:41 +01: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
2f49c76a6a
lib: remove nixvimTypes alias 2024-09-27 08:31:07 +01:00
Matt Sturgeon
d718446b61
lib: remove maintainers alias 2024-09-27 05:31:26 +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
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
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
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
traxys
62f32bfc71 treewide: Reformat with nixfmt 2024-05-05 22:00:40 +02:00
Rob Hanlon
485d21f60d
Add _nixvimTests = false to flake.lib output (#1125)
In my personal configuration, I rely on `nixvim.lib.${system}.helpers` to get access to things like `mkRaw` and `toLuaObject` for use in my extended `lib`.

With the changes made in 6d7e429537, `nixvim.lib.${system}.helpers` can no longer be accessed directly from the `nixvim` input as `_nixvimTests` is not provided as an input attribute, so loading `helpers.nix` fails.

This small change restores what I *think* is the intended behavior of this module
2024-02-21 23:40:49 +01:00
traxys
6d7e429537
tests: Introduce a way to disable options when running in tests (#1095)
In our basic template we used to provide a check based on
`mkTestDerivationFromNvim`. The issue with this check (that is handled
correctly internally) is that some plugins _can't_ be used in the test
environment, for example image.nvim like in #1085.

This commit introduces a new function to generate such checks,
`mkTestDerivationFromNixvimModule`, that wraps a nixvim configuration
instead of a built nvim instance.

Then a configuration can rely on the newly added
`helpers.enableExceptInTests` attribute to disable parts of the
configuration depending if it is evaluated in tests or in a real final
configuration.

Resolves #1085
2024-02-15 14:27:45 +01:00
Alexander Nortung
3600698aba
Added test for template and fixed check export for lib (#361) 2023-05-15 11:04:52 +02:00
Alexander Nortung
2258eb8df8
misc: added flake template (#219)
* Added simple flake template

* Added readme to template

* Updated readme to show how to use the template

* Formatting

* removed unused file from template

* Fixed template url and pkgs

* Formatting
2023-03-03 09:18:52 +00:00