2021-11-23 19:01:10 +01:00
|
|
|
{
|
2023-02-20 11:42:13 +01:00
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
cfg = config.plugins.comment-nvim;
|
|
|
|
helpers = import ../helpers.nix {inherit lib;};
|
|
|
|
in {
|
2021-11-23 19:01:10 +01:00
|
|
|
options = {
|
2022-09-18 11:19:23 +01:00
|
|
|
plugins.comment-nvim = {
|
2021-11-23 19:01:10 +01:00
|
|
|
enable = mkEnableOption "Enable comment-nvim";
|
2023-01-19 10:45:15 +00:00
|
|
|
|
2023-01-25 19:46:49 +01:00
|
|
|
package = helpers.mkPackageOption "comment-nvim" pkgs.vimPlugins.comment-nvim;
|
2023-01-19 10:45:15 +00:00
|
|
|
|
2021-11-23 19:01:10 +01:00
|
|
|
padding = mkOption {
|
2021-11-24 16:29:57 +01:00
|
|
|
type = types.nullOr types.bool;
|
2021-11-23 19:01:10 +01:00
|
|
|
description = "Add a space b/w comment and the line";
|
2021-11-24 16:29:57 +01:00
|
|
|
default = null;
|
2021-11-23 19:01:10 +01:00
|
|
|
};
|
|
|
|
sticky = mkOption {
|
2021-11-24 16:29:57 +01:00
|
|
|
type = types.nullOr types.bool;
|
2021-11-23 19:01:10 +01:00
|
|
|
description = "Whether the cursor should stay at its position";
|
2021-11-24 16:29:57 +01:00
|
|
|
default = null;
|
2021-11-23 19:01:10 +01:00
|
|
|
};
|
|
|
|
ignore = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
description = "Lines to be ignored while comment/uncomment";
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
toggler = mkOption {
|
2023-02-20 11:42:13 +01:00
|
|
|
type = types.nullOr (types.submodule ({...}: {
|
2021-11-23 19:01:10 +01:00
|
|
|
options = {
|
|
|
|
line = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "line-comment keymap";
|
|
|
|
default = "gcc";
|
|
|
|
};
|
|
|
|
block = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "block-comment keymap";
|
|
|
|
default = "gbc";
|
|
|
|
};
|
|
|
|
};
|
2021-11-24 16:29:57 +01:00
|
|
|
}));
|
2021-11-23 19:01:10 +01:00
|
|
|
description = "LHS of toggle mappings in NORMAL + VISUAL mode";
|
2021-11-24 16:29:57 +01:00
|
|
|
default = null;
|
2021-11-23 19:01:10 +01:00
|
|
|
};
|
|
|
|
opleader = mkOption {
|
2023-02-20 11:42:13 +01:00
|
|
|
type = types.nullOr (types.submodule ({...}: {
|
2021-11-23 19:01:10 +01:00
|
|
|
options = {
|
|
|
|
line = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "line-comment keymap";
|
|
|
|
default = "gc";
|
|
|
|
};
|
|
|
|
block = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "block-comment keymap";
|
|
|
|
default = "gb";
|
|
|
|
};
|
|
|
|
};
|
2021-11-24 16:29:57 +01:00
|
|
|
}));
|
2021-11-23 19:01:10 +01:00
|
|
|
description = "LHS of operator-pending mappings in NORMAL + VISUAL mode";
|
2021-11-24 16:29:57 +01:00
|
|
|
default = null;
|
2021-11-23 19:01:10 +01:00
|
|
|
};
|
|
|
|
mappings = mkOption {
|
2023-02-20 11:42:13 +01:00
|
|
|
type = types.nullOr (types.submodule ({...}: {
|
2021-11-23 19:01:10 +01:00
|
|
|
options = {
|
|
|
|
basic = mkOption {
|
|
|
|
type = types.bool;
|
2022-01-10 19:50:13 +00:00
|
|
|
description = "operator-pending mapping. Includes 'gcc', 'gcb', 'gc[count]{motion}' and 'gb[count]{motion}'";
|
2021-11-23 19:01:10 +01:00
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
extra = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
description = "extra mapping. Includes 'gco', 'gc0', 'gcA'";
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
extended = mkOption {
|
|
|
|
type = types.bool;
|
2022-01-10 19:50:13 +00:00
|
|
|
description = "extended mapping. Includes 'g>', 'g<', 'g>[count]{motion}' and 'g<[count]{motion}'";
|
2021-11-23 19:01:10 +01:00
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
};
|
2021-11-24 16:29:57 +01:00
|
|
|
}));
|
2021-11-23 19:01:10 +01:00
|
|
|
description = "Create basic (operator-pending) and extended mappings for NORMAL + VISUAL mode";
|
2021-11-24 16:29:57 +01:00
|
|
|
default = null;
|
2021-11-23 19:01:10 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
config = let
|
|
|
|
setupOptions = {
|
|
|
|
padding = cfg.padding;
|
|
|
|
sticky = cfg.sticky;
|
|
|
|
ignore = cfg.ignore;
|
|
|
|
toggler = cfg.toggler;
|
|
|
|
opleader = cfg.opleader;
|
|
|
|
mappings = cfg.mappings;
|
|
|
|
};
|
|
|
|
in
|
2022-09-18 11:19:23 +01:00
|
|
|
mkIf cfg.enable {
|
2023-02-20 11:42:13 +01:00
|
|
|
extraPlugins = [cfg.package];
|
|
|
|
extraConfigLua = ''require("Comment").setup${helpers.toLuaObject setupOptions}'';
|
2021-11-23 19:01:10 +01:00
|
|
|
};
|
|
|
|
}
|