Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/options: refactor and rename (non-breaking) #1661

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

MattSturgeon
Copy link
Member

lib/types: add nixvimTypes.freeformModule

We often have submodules in settings options, most of these should be freeform although many aren't.

lib/options: add rawOpts helpers

New helpers for making non-null options that support the raw type.

lib/options: move top-level helpers to nullableOpts

Most of the top-level option helpers were actually creating nullable options. Move them into their own scope.

lib/options: standardise raw-type support in defaultNullOpts

mkAttrsOf (etc) didn't inject maybeRaw everywhere they should. Also begin transitioning mkNullable and mkNullableWithRaw by introducing mkNullableNoRaw alias.

lib/options: merge mkNullOrStrLuaOr' (etc)

This is the only breaking change, although I don't think anyone ever used these.

Other

Do we still need mkCompositeOption? Should we make it freeform?

`freeformModule { foo = mkOption {}; }` is equivalent to:

```nix
submodule {
  freeformType = attrsOf anything;
  options = { foo = mkOption {}; };
}
```
Helper functions to create non-null options that support the raw type.
Where applicable, top-level helper functions are moved into the new
attrset `nullableOpts`.
The base `mkNullOrLua'` function can just check if `type` is provided.
@GaetanLepage
Copy link
Member

Do we still need mkCompositeOption? Should we make it freeform?

We should first look for all the occurences in the code base and then, if none of this use cases is legit, we should remove it.

@MattSturgeon MattSturgeon changed the title lib/types: add nixvimTypes.freeformModule lib/toptions: refactor and rename (non-breaking) Jun 9, 2024
@MattSturgeon MattSturgeon changed the title lib/toptions: refactor and rename (non-breaking) lib/options: refactor and rename (non-breaking) Jun 9, 2024
@GaetanLepage
Copy link
Member

Although your description is very clear, I would prefer if this set of changes is spread accross a few individual PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants