mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-24 09:48:42 +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,244 +1,228 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.hardtime;
|
||||
inherit (lib.nixvim) defaultNullOpts;
|
||||
inherit (lib) types;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
plugins.hardtime = helpers.neovim-plugin.extraOptionsOptions // {
|
||||
enable = mkEnableOption "hardtime";
|
||||
lib.nixvim.neovim-plugin.mkNeovimPlugin {
|
||||
name = "hardtime";
|
||||
originalName = "hardtime.nvim";
|
||||
package = "hardtime-nvim";
|
||||
|
||||
package = lib.mkPackageOption pkgs "hardtime" {
|
||||
default = [
|
||||
"vimPlugins"
|
||||
"hardtime-nvim"
|
||||
];
|
||||
};
|
||||
maintainers = [ lib.maintainers.refaelsh ];
|
||||
|
||||
maxTime = helpers.defaultNullOpts.mkUnsignedInt 1000 ''
|
||||
Maximum time (in milliseconds) to consider key presses as repeated.
|
||||
'';
|
||||
# TODO: Added 2024-09-07; remove after 24.11
|
||||
deprecateExtraOptions = true;
|
||||
optionsRenamedToSettings = [
|
||||
"hint"
|
||||
"notification"
|
||||
"hints"
|
||||
"maxTime"
|
||||
"maxCount"
|
||||
"disableMouse"
|
||||
"allowDifferentKey"
|
||||
"resettingKeys"
|
||||
"restrictedKeys"
|
||||
"restrictionMode"
|
||||
"disabledKeys"
|
||||
"disabledFiletypes"
|
||||
];
|
||||
|
||||
maxCount = helpers.defaultNullOpts.mkUnsignedInt 2 ''
|
||||
Maximum count of repeated key presses allowed within the `max_time` period.
|
||||
'';
|
||||
settingsOptions = {
|
||||
max_time = defaultNullOpts.mkUnsignedInt 1000 ''
|
||||
Maximum time (in milliseconds) to consider key presses as repeated.
|
||||
'';
|
||||
|
||||
disableMouse = helpers.defaultNullOpts.mkBool true ''
|
||||
Disable mouse support.
|
||||
'';
|
||||
max_count = defaultNullOpts.mkUnsignedInt 2 ''
|
||||
Maximum count of repeated key presses allowed within the `max_time` period.
|
||||
'';
|
||||
|
||||
hint = helpers.defaultNullOpts.mkBool true ''
|
||||
Enable hint messages for better commands.
|
||||
'';
|
||||
disable_mouse = defaultNullOpts.mkBool true ''
|
||||
Disable mouse support.
|
||||
'';
|
||||
|
||||
notification = helpers.defaultNullOpts.mkBool true ''
|
||||
Enable notification messages for restricted and disabled keys.
|
||||
'';
|
||||
hint = defaultNullOpts.mkBool true ''
|
||||
Enable hint messages for better commands.
|
||||
'';
|
||||
|
||||
allowDifferentKey = helpers.defaultNullOpts.mkBool false ''
|
||||
Allow different keys to reset the count.
|
||||
'';
|
||||
notification = defaultNullOpts.mkBool true ''
|
||||
Enable notification messages for restricted and disabled keys.
|
||||
'';
|
||||
|
||||
enabled = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether the plugin in enabled by default or not.
|
||||
'';
|
||||
allow_different_key = defaultNullOpts.mkBool false ''
|
||||
Allow different keys to reset the count.
|
||||
'';
|
||||
|
||||
resettingKeys = helpers.defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
||||
"1" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"2" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"3" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"4" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"5" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"6" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"7" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"8" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"9" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"c" = [ "n" ];
|
||||
"C" = [ "n" ];
|
||||
"d" = [ "n" ];
|
||||
"x" = [ "n" ];
|
||||
"X" = [ "n" ];
|
||||
"y" = [ "n" ];
|
||||
"Y" = [ "n" ];
|
||||
"p" = [ "n" ];
|
||||
"P" = [ "n" ];
|
||||
} "Keys in what modes that reset the count.";
|
||||
enabled = defaultNullOpts.mkBool true ''
|
||||
Whether the plugin in enabled by default or not.
|
||||
'';
|
||||
|
||||
restrictedKeys = helpers.defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
||||
"h" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"j" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"k" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"l" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"-" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"+" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"gj" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"gk" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"<CR>" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"<C-M>" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"<C-N>" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"<C-P>" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
} "Keys in what modes triggering the count mechanism.";
|
||||
resetting_keys = defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
||||
"1" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"2" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"3" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"4" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"5" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"6" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"7" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"8" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"9" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"c" = [ "n" ];
|
||||
"C" = [ "n" ];
|
||||
"d" = [ "n" ];
|
||||
"x" = [ "n" ];
|
||||
"X" = [ "n" ];
|
||||
"y" = [ "n" ];
|
||||
"Y" = [ "n" ];
|
||||
"p" = [ "n" ];
|
||||
"P" = [ "n" ];
|
||||
} "Keys in what modes that reset the count.";
|
||||
|
||||
restrictionMode =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"block"
|
||||
"hint"
|
||||
]
|
||||
''
|
||||
The behavior when `restricted_keys` trigger count mechanism.
|
||||
'';
|
||||
restricted_keys = defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
||||
"h" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"j" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"k" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"l" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"-" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"+" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"gj" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"gk" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"<CR>" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"<C-M>" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"<C-N>" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
"<C-P>" = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
} "Keys in what modes triggering the count mechanism.";
|
||||
|
||||
disabledKeys = helpers.defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
||||
"<Up>" = [
|
||||
""
|
||||
"i"
|
||||
];
|
||||
"<Down>" = [
|
||||
""
|
||||
"i"
|
||||
];
|
||||
"<Left>" = [
|
||||
""
|
||||
"i"
|
||||
];
|
||||
"<Right>" = [
|
||||
""
|
||||
"i"
|
||||
];
|
||||
} "Keys in what modes are disabled.";
|
||||
restriction_mode =
|
||||
defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"block"
|
||||
"hint"
|
||||
]
|
||||
''
|
||||
The behavior when `restricted_keys` trigger count mechanism.
|
||||
'';
|
||||
|
||||
disabledFiletypes = helpers.defaultNullOpts.mkListOf types.str [
|
||||
"qf"
|
||||
"netrw"
|
||||
"NvimTree"
|
||||
"lazy"
|
||||
"mason"
|
||||
] "`hardtime.nvim` is disabled under these filetypes.";
|
||||
disabled_keys = defaultNullOpts.mkAttrsOf (with types; listOf str) {
|
||||
"<Up>" = [
|
||||
""
|
||||
"i"
|
||||
];
|
||||
"<Down>" = [
|
||||
""
|
||||
"i"
|
||||
];
|
||||
"<Left>" = [
|
||||
""
|
||||
"i"
|
||||
];
|
||||
"<Right>" = [
|
||||
""
|
||||
"i"
|
||||
];
|
||||
} "Keys in what modes are disabled.";
|
||||
|
||||
hints =
|
||||
helpers.mkNullOrOption
|
||||
(
|
||||
with types;
|
||||
attrsOf (submodule {
|
||||
options = {
|
||||
message = lib.mkOption {
|
||||
description = "Hint message to be displayed.";
|
||||
type = helpers.nixvimTypes.rawLua;
|
||||
};
|
||||
disabled_filetypes = defaultNullOpts.mkListOf types.str [
|
||||
"qf"
|
||||
"netrw"
|
||||
"NvimTree"
|
||||
"lazy"
|
||||
"mason"
|
||||
] "`hardtime.nvim` is disabled under these filetypes.";
|
||||
|
||||
length = lib.mkOption {
|
||||
description = "The length of actual key strokes that matches this pattern.";
|
||||
type = types.ints.unsigned;
|
||||
};
|
||||
hints =
|
||||
lib.nixvim.mkNullOrOption
|
||||
(
|
||||
with types;
|
||||
attrsOf (submodule {
|
||||
options = {
|
||||
message = lib.mkOption {
|
||||
description = "Hint message to be displayed.";
|
||||
type = types.rawLua;
|
||||
};
|
||||
})
|
||||
)
|
||||
''
|
||||
`key` is a string pattern you want to match, `value` is a table
|
||||
of hint massage and pattern length.
|
||||
'';
|
||||
};
|
||||
|
||||
length = lib.mkOption {
|
||||
description = "The length of actual key strokes that matches this pattern.";
|
||||
type = types.ints.unsigned;
|
||||
};
|
||||
};
|
||||
})
|
||||
)
|
||||
''
|
||||
`key` is a string pattern you want to match, `value` is a table
|
||||
of hint massage and pattern length.
|
||||
'';
|
||||
};
|
||||
|
||||
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})
|
||||
'';
|
||||
settingsExample = {
|
||||
max_time = 1500;
|
||||
settings = {
|
||||
showmode = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue