1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-12-06 17:11:05 +01:00

treewide: remove internal use of helpers module arg

This commit is contained in:
Matt Sturgeon 2025-11-19 11:39:41 +00:00
parent 7add68e918
commit dad19c1238
68 changed files with 687 additions and 758 deletions

View file

@ -1,6 +1,5 @@
{
lib,
helpers,
...
}:
with lib;
@ -13,10 +12,10 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraOptions = {
# A list of `Hydra` definitions
hydras = import ./hydras-option.nix { inherit lib helpers; };
hydras = import ./hydras-option.nix { inherit lib; };
};
settingsOptions = import ./settings-options.nix { inherit lib helpers; };
settingsOptions = import ./settings-options.nix { inherit lib; };
settingsExample = {
exit = false;

View file

@ -1,23 +1,23 @@
{ lib, helpers }:
{ lib }:
with lib;
let
hydraType = types.submodule {
freeformType = with types; attrsOf anything;
options = {
name = helpers.mkNullOrStr ''
name = lib.nixvim.mkNullOrStr ''
Hydra's name.
Only used in auto-generated hint.
'';
mode = helpers.defaultNullOpts.mkNullable (
with lib.types; either helpers.keymaps.modeEnum (listOf helpers.keymaps.modeEnum)
mode = lib.nixvim.defaultNullOpts.mkNullable (
with lib.types; either lib.nixvim.keymaps.modeEnum (listOf lib.nixvim.keymaps.modeEnum)
) "n" "Modes where the hydra exists, same as `vim.keymap.set()` accepts.";
body = helpers.mkNullOrStr ''
body = lib.nixvim.mkNullOrStr ''
Key required to activate the hydra, when excluded, you can use `Hydra:activate()`.
'';
hint = helpers.mkNullOrStr ''
hint = lib.nixvim.mkNullOrStr ''
The hint for a hydra can let you know that it's active, and remind you of the
hydra's heads.
The string for the hint is passed directly to the hydra.
@ -26,56 +26,56 @@ let
for more information.
'';
config = import ./settings-options.nix { inherit lib helpers; };
config = import ./settings-options.nix { inherit lib; };
heads =
let
headsOptType = types.submodule {
freeformType = with types; attrsOf anything;
options = {
private = helpers.defaultNullOpts.mkBool false ''
private = lib.nixvim.defaultNullOpts.mkBool false ''
"When the hydra hides, this head does not stick out".
Private heads are unreachable outside of the hydra state.
'';
exit = helpers.defaultNullOpts.mkBool false ''
exit = lib.nixvim.defaultNullOpts.mkBool false ''
When true, stops the hydra after executing this head.
NOTE:
- All exit heads are private
- If no exit head is specified, `esc` is set by default
'';
exit_before = helpers.defaultNullOpts.mkBool false ''
exit_before = lib.nixvim.defaultNullOpts.mkBool false ''
Like `exit`, but stops the hydra BEFORE executing the command.
'';
ok_key = helpers.defaultNullOpts.mkBool true ''
ok_key = lib.nixvim.defaultNullOpts.mkBool true ''
When set to `false`, `config.on_key` isn't run after this head.
'';
desc = helpers.mkNullOrStr ''
desc = lib.nixvim.mkNullOrStr ''
Value shown in auto-generated hint.
When false, this key doesn't show up in the auto-generated hint.
'';
expr = helpers.defaultNullOpts.mkBool false ''
expr = lib.nixvim.defaultNullOpts.mkBool false ''
Same as the builtin `expr` map option.
See `:h :map-expression`.
'';
silent = helpers.defaultNullOpts.mkBool false ''
silent = lib.nixvim.defaultNullOpts.mkBool false ''
Same as the builtin `silent` map option.
See `:h :map-silent`.
'';
nowait = helpers.defaultNullOpts.mkBool false ''
nowait = lib.nixvim.defaultNullOpts.mkBool false ''
For Pink Hydras only.
Allows binding a key which will immediately perform its action and not wait
`timeoutlen` for a possible continuation.
'';
mode = helpers.mkNullOrOption (
with lib.types; either helpers.keymaps.modeEnum (listOf helpers.keymaps.modeEnum)
mode = lib.nixvim.mkNullOrOption (
with lib.types; either lib.nixvim.keymaps.modeEnum (listOf lib.nixvim.keymaps.modeEnum)
) "Override `mode` for this head.";
};
};
@ -93,7 +93,7 @@ let
)
);
in
helpers.mkNullOrOption (types.listOf headType) ''
lib.nixvim.mkNullOrOption (types.listOf headType) ''
Each Hydra's head has the form:
`[head rhs opts]

View file

@ -5,19 +5,19 @@
# - for `plugins.hydra.hydras.[].config`
#
# -> https://github.com/nvimtools/hydra.nvim?tab=readme-ov-file#config
{ helpers, lib, ... }:
{ lib, ... }:
with lib;
{
debug = helpers.defaultNullOpts.mkBool false ''
debug = lib.nixvim.defaultNullOpts.mkBool false ''
Whether to enable debug mode.
'';
exit = helpers.defaultNullOpts.mkBool false ''
exit = lib.nixvim.defaultNullOpts.mkBool false ''
Set the default exit value for each head in the hydra.
'';
foreign_keys =
helpers.defaultNullOpts.mkEnum
lib.nixvim.defaultNullOpts.mkEnum
[
"warn"
"run"
@ -30,38 +30,38 @@ with lib;
- `"run"`: hydra stays active, runs the foreign key
'';
color = helpers.defaultNullOpts.mkStr "red" ''
color = lib.nixvim.defaultNullOpts.mkStr "red" ''
See `:h hydra-colors`.
`"red" | "amaranth" | "teal" | "pink"`
'';
buffer = helpers.defaultNullOpts.mkNullable (
buffer = lib.nixvim.defaultNullOpts.mkNullable (
with types; either (enum [ true ]) ints.unsigned
) null "Define a hydra for the given buffer, pass `true` for current buf.";
invoke_on_body = helpers.defaultNullOpts.mkBool false ''
invoke_on_body = lib.nixvim.defaultNullOpts.mkBool false ''
When true, summon the hydra after pressing only the `body` keys.
Normally a head is required.
'';
desc = helpers.defaultNullOpts.mkStr null ''
desc = lib.nixvim.defaultNullOpts.mkStr null ''
Description used for the body keymap when `invoke_on_body` is true.
When nil, "[Hydra] .. name" is used.
'';
on_enter = helpers.mkNullOrLuaFn ''
on_enter = lib.nixvim.mkNullOrLuaFn ''
Called when the hydra is activated.
'';
on_exit = helpers.mkNullOrLuaFn ''
on_exit = lib.nixvim.mkNullOrLuaFn ''
Called before the hydra is deactivated.
'';
on_key = helpers.mkNullOrLuaFn ''
on_key = lib.nixvim.mkNullOrLuaFn ''
Called after every hydra head.
'';
timeout = helpers.defaultNullOpts.mkNullable (with types; either bool ints.unsigned) false ''
timeout = lib.nixvim.defaultNullOpts.mkNullable (with types; either bool ints.unsigned) false ''
Timeout after which the hydra is automatically disabled.
Calling any head will refresh the timeout
- `true`: timeout set to value of `timeoutlen` (`:h timeoutlen`)
@ -76,7 +76,7 @@ with lib;
freeformType = with types; attrsOf anything;
options = {
type =
helpers.mkNullOrOption
lib.nixvim.mkNullOrOption
(types.enum [
"window"
"cmdline"
@ -93,7 +93,7 @@ with lib;
Defaults to "window" if `hint` is passed to the hydra otherwise defaults to "cmdline".
'';
position = helpers.defaultNullOpts.mkEnum [
position = lib.nixvim.defaultNullOpts.mkEnum [
"top-left"
"top"
"top-right"
@ -105,23 +105,23 @@ with lib;
"bottom-right"
] "bottom" "Set the position of the hint window.";
offset = helpers.defaultNullOpts.mkInt 0 ''
offset = lib.nixvim.defaultNullOpts.mkInt 0 ''
Offset of the floating window from the nearest editor border.
'';
float_opts = helpers.mkNullOrOption (with types; attrsOf anything) ''
float_opts = lib.nixvim.mkNullOrOption (with types; attrsOf anything) ''
Options passed to `nvim_open_win()`. See `:h nvim_open_win()`.
Lets you set `border`, `header`, `footer`, etc.
Note: `row`, `col`, `height`, `width`, `relative`, and `anchor` should not be overridden.
'';
show_name = helpers.defaultNullOpts.mkBool true ''
show_name = lib.nixvim.defaultNullOpts.mkBool true ''
Show the hydras name (or "HYDRA:" if not given a name), at the beginning of an
auto-generated hint.
'';
hide_on_load = helpers.defaultNullOpts.mkBool false ''
hide_on_load = lib.nixvim.defaultNullOpts.mkBool false ''
If set to true, this will prevent the hydra's hint window from displaying immediately.
Note: you can still show the window manually by calling `Hydra.hint:show()` and manually
@ -160,7 +160,7 @@ with lib;
};
};
in
helpers.defaultNullOpts.mkNullable (with types; either (enum [ false ]) hintConfigType)
lib.nixvim.defaultNullOpts.mkNullable (with types; either (enum [ false ]) hintConfigType)
{
show_name = true;
position = "bottom";