plugins/spider: migrate to mkNeovimPlugin

Signed-off-by: saygo-png <saygo.mail@proton.me>
This commit is contained in:
saygo-png 2025-07-13 12:46:10 +02:00 committed by Gaétan Lepage
parent d80d42f066
commit 82271c28ef
2 changed files with 49 additions and 50 deletions

View file

@ -1,36 +1,26 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
pluginName = "spider";
cfg = config.plugins.${pluginName};
inherit (lib) types;
in
{
options.plugins.${pluginName} = lib.nixvim.plugins.neovim.extraOptionsOptions // {
enable = mkEnableOption pluginName;
package = lib.mkPackageOption pkgs pluginName {
default = [
"vimPlugins"
"nvim-spider"
];
};
skipInsignificantPunctuation = helpers.defaultNullOpts.mkBool true "Whether to skip insignificant punctuation.";
lib.nixvim.plugins.mkNeovimPlugin {
name = "spider";
packPathName = "nvim-spider";
package = "nvim-spider";
maintainers = [ lib.maintainers.saygo-png ];
description = "Use the w, e, b motions like a spider. Move by subwords and skip insignificant punctuation.";
extraOptions = {
keymaps = {
silent = mkOption {
type = types.bool;
description = "Whether ${pluginName} keymaps should be silent.";
silent = lib.mkOption {
type = lib.types.bool;
description = "Whether spider keymaps should be silent.";
default = false;
};
motions = mkOption {
motions = lib.mkOption {
type = types.attrsOf types.str;
description = ''
Mappings for spider motions.
@ -48,13 +38,13 @@ in
};
};
config =
let
setupOptions = {
inherit (cfg) skipInsignificantPunctuation;
} // cfg.extraOptions;
# TODO: introduced 2025-07-13: remove after 25.11
inherit (import ./deprecations.nix lib) deprecateExtraOptions imports;
mappings = mapAttrsToList (motion: key: {
extraConfig = cfg: {
extraLuaPackages = luaPkgs: [ luaPkgs.luautf8 ];
keymaps = lib.mapAttrsToList (motion: key: {
mode = [
"n"
"o"
@ -67,15 +57,5 @@ in
desc = "Spider-${motion}";
};
}) cfg.keymaps.motions;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraLuaPackages = luaPkgs: [ luaPkgs.luautf8 ];
keymaps = mappings;
extraConfigLua = ''
require("${pluginName}").setup(${lib.nixvim.toLuaObject setupOptions})
'';
};
}

View file

@ -0,0 +1,19 @@
lib: {
deprecateExtraOptions = true;
imports =
let
basePluginPath = [
"plugins"
"spider"
];
in
[
(lib.mkRenamedOptionModule (basePluginPath ++ [ "skipInsignificantPunctuation" ]) (
basePluginPath
++ [
"settings"
"skipInsignificantPunctuation"
]
))
];
}