mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-25 02:08:40 +02:00
plugins/hardtime: migrate to mkNeovimPlugin
Co-authored-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
810eacf516
commit
2de406d972
2 changed files with 658 additions and 662 deletions
|
@ -1,55 +1,65 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
cfg = config.plugins.hardtime;
|
inherit (lib.nixvim) defaultNullOpts;
|
||||||
|
inherit (lib) types;
|
||||||
in
|
in
|
||||||
{
|
lib.nixvim.neovim-plugin.mkNeovimPlugin {
|
||||||
options = {
|
name = "hardtime";
|
||||||
plugins.hardtime = helpers.neovim-plugin.extraOptionsOptions // {
|
originalName = "hardtime.nvim";
|
||||||
enable = mkEnableOption "hardtime";
|
package = "hardtime-nvim";
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "hardtime" {
|
maintainers = [ lib.maintainers.refaelsh ];
|
||||||
default = [
|
|
||||||
"vimPlugins"
|
# TODO: Added 2024-09-07; remove after 24.11
|
||||||
"hardtime-nvim"
|
deprecateExtraOptions = true;
|
||||||
|
optionsRenamedToSettings = [
|
||||||
|
"hint"
|
||||||
|
"notification"
|
||||||
|
"hints"
|
||||||
|
"maxTime"
|
||||||
|
"maxCount"
|
||||||
|
"disableMouse"
|
||||||
|
"allowDifferentKey"
|
||||||
|
"resettingKeys"
|
||||||
|
"restrictedKeys"
|
||||||
|
"restrictionMode"
|
||||||
|
"disabledKeys"
|
||||||
|
"disabledFiletypes"
|
||||||
];
|
];
|
||||||
};
|
|
||||||
|
|
||||||
maxTime = helpers.defaultNullOpts.mkUnsignedInt 1000 ''
|
settingsOptions = {
|
||||||
|
max_time = defaultNullOpts.mkUnsignedInt 1000 ''
|
||||||
Maximum time (in milliseconds) to consider key presses as repeated.
|
Maximum time (in milliseconds) to consider key presses as repeated.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
maxCount = helpers.defaultNullOpts.mkUnsignedInt 2 ''
|
max_count = defaultNullOpts.mkUnsignedInt 2 ''
|
||||||
Maximum count of repeated key presses allowed within the `max_time` period.
|
Maximum count of repeated key presses allowed within the `max_time` period.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
disableMouse = helpers.defaultNullOpts.mkBool true ''
|
disable_mouse = defaultNullOpts.mkBool true ''
|
||||||
Disable mouse support.
|
Disable mouse support.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
hint = helpers.defaultNullOpts.mkBool true ''
|
hint = defaultNullOpts.mkBool true ''
|
||||||
Enable hint messages for better commands.
|
Enable hint messages for better commands.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
notification = helpers.defaultNullOpts.mkBool true ''
|
notification = defaultNullOpts.mkBool true ''
|
||||||
Enable notification messages for restricted and disabled keys.
|
Enable notification messages for restricted and disabled keys.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
allowDifferentKey = helpers.defaultNullOpts.mkBool false ''
|
allow_different_key = defaultNullOpts.mkBool false ''
|
||||||
Allow different keys to reset the count.
|
Allow different keys to reset the count.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
enabled = helpers.defaultNullOpts.mkBool true ''
|
enabled = defaultNullOpts.mkBool true ''
|
||||||
Whether the plugin in enabled by default or not.
|
Whether the plugin in enabled by default or not.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
resettingKeys = helpers.defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
resetting_keys = defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
||||||
"1" = [
|
"1" = [
|
||||||
"n"
|
"n"
|
||||||
"x"
|
"x"
|
||||||
|
@ -97,7 +107,7 @@ in
|
||||||
"P" = [ "n" ];
|
"P" = [ "n" ];
|
||||||
} "Keys in what modes that reset the count.";
|
} "Keys in what modes that reset the count.";
|
||||||
|
|
||||||
restrictedKeys = helpers.defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
restricted_keys = defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
||||||
"h" = [
|
"h" = [
|
||||||
"n"
|
"n"
|
||||||
"x"
|
"x"
|
||||||
|
@ -148,8 +158,8 @@ in
|
||||||
];
|
];
|
||||||
} "Keys in what modes triggering the count mechanism.";
|
} "Keys in what modes triggering the count mechanism.";
|
||||||
|
|
||||||
restrictionMode =
|
restriction_mode =
|
||||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
defaultNullOpts.mkEnumFirstDefault
|
||||||
[
|
[
|
||||||
"block"
|
"block"
|
||||||
"hint"
|
"hint"
|
||||||
|
@ -158,7 +168,7 @@ in
|
||||||
The behavior when `restricted_keys` trigger count mechanism.
|
The behavior when `restricted_keys` trigger count mechanism.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
disabledKeys = helpers.defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
disabled_keys = defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
||||||
"<Up>" = [
|
"<Up>" = [
|
||||||
""
|
""
|
||||||
"i"
|
"i"
|
||||||
|
@ -177,7 +187,7 @@ in
|
||||||
];
|
];
|
||||||
} "Keys in what modes are disabled.";
|
} "Keys in what modes are disabled.";
|
||||||
|
|
||||||
disabledFiletypes = helpers.defaultNullOpts.mkListOf types.str [
|
disabled_filetypes = defaultNullOpts.mkListOf types.str [
|
||||||
"qf"
|
"qf"
|
||||||
"netrw"
|
"netrw"
|
||||||
"NvimTree"
|
"NvimTree"
|
||||||
|
@ -186,14 +196,14 @@ in
|
||||||
] "`hardtime.nvim` is disabled under these filetypes.";
|
] "`hardtime.nvim` is disabled under these filetypes.";
|
||||||
|
|
||||||
hints =
|
hints =
|
||||||
helpers.mkNullOrOption
|
lib.nixvim.mkNullOrOption
|
||||||
(
|
(
|
||||||
with types;
|
with types;
|
||||||
attrsOf (submodule {
|
attrsOf (submodule {
|
||||||
options = {
|
options = {
|
||||||
message = lib.mkOption {
|
message = lib.mkOption {
|
||||||
description = "Hint message to be displayed.";
|
description = "Hint message to be displayed.";
|
||||||
type = helpers.nixvimTypes.rawLua;
|
type = types.rawLua;
|
||||||
};
|
};
|
||||||
|
|
||||||
length = lib.mkOption {
|
length = lib.mkOption {
|
||||||
|
@ -208,37 +218,11 @@ in
|
||||||
of hint massage and pattern length.
|
of hint massage and pattern length.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
settingsExample = {
|
||||||
|
max_time = 1500;
|
||||||
|
settings = {
|
||||||
|
showmode = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
config =
|
|
||||||
let
|
|
||||||
setupOptions =
|
|
||||||
with cfg;
|
|
||||||
{
|
|
||||||
inherit
|
|
||||||
hint
|
|
||||||
notification
|
|
||||||
enabled
|
|
||||||
hints
|
|
||||||
;
|
|
||||||
|
|
||||||
max_time = maxTime;
|
|
||||||
max_count = maxCount;
|
|
||||||
disable_mouse = disableMouse;
|
|
||||||
allow_different_key = allowDifferentKey;
|
|
||||||
resetting_keys = resettingKeys;
|
|
||||||
restricted_keys = restrictedKeys;
|
|
||||||
restriction_mode = restrictionMode;
|
|
||||||
disabled_keys = disabledKeys;
|
|
||||||
disabled_filetypes = disabledFiletypes;
|
|
||||||
}
|
|
||||||
// extraOptions;
|
|
||||||
in
|
|
||||||
mkIf cfg.enable {
|
|
||||||
extraPlugins = [ cfg.package ];
|
|
||||||
|
|
||||||
extraConfigLua = ''
|
|
||||||
require("hardtime").setup(${helpers.toLuaObject setupOptions})
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,17 @@
|
||||||
plugins.hardtime = {
|
plugins.hardtime = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
maxTime = 1000;
|
settings = {
|
||||||
maxCount = 2;
|
max_time = 1000;
|
||||||
disableMouse = true;
|
max_count = 2;
|
||||||
|
disable_mouse = true;
|
||||||
hint = true;
|
hint = true;
|
||||||
notification = true;
|
notification = true;
|
||||||
allowDifferentKey = false;
|
allow_different_key = false;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
restrictionMode = "block";
|
restriction_mode = "block";
|
||||||
|
|
||||||
resettingKeys = {
|
resetting_keys = {
|
||||||
"1" = [
|
"1" = [
|
||||||
"n"
|
"n"
|
||||||
"x"
|
"x"
|
||||||
|
@ -64,7 +65,7 @@
|
||||||
"P" = [ "n" ];
|
"P" = [ "n" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
restrictedKeys = {
|
restricted_keys = {
|
||||||
"h" = [
|
"h" = [
|
||||||
"n"
|
"n"
|
||||||
"x"
|
"x"
|
||||||
|
@ -115,7 +116,7 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
disabledKeys = {
|
disabled_keys = {
|
||||||
"<Up>" = [
|
"<Up>" = [
|
||||||
""
|
""
|
||||||
"i"
|
"i"
|
||||||
|
@ -134,7 +135,7 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
disabledFiletypes = [
|
disabled_file_types = [
|
||||||
"qf"
|
"qf"
|
||||||
"netrw"
|
"netrw"
|
||||||
"NvimTree"
|
"NvimTree"
|
||||||
|
@ -474,4 +475,15 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
example = {
|
||||||
|
plugins.hardtime = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
showmode = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue