mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 16:39:00 +02:00
107 lines
3.2 KiB
Nix
107 lines
3.2 KiB
Nix
{
|
|
lib,
|
|
helpers,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}:
|
|
with lib; let
|
|
cfg = config.plugins.comment-nvim;
|
|
in {
|
|
options = {
|
|
plugins.comment-nvim = {
|
|
enable = mkEnableOption "comment-nvim";
|
|
|
|
package = helpers.mkPackageOption "comment-nvim" pkgs.vimPlugins.comment-nvim;
|
|
|
|
padding = mkOption {
|
|
type = types.nullOr types.bool;
|
|
description = "Add a space b/w comment and the line";
|
|
default = null;
|
|
};
|
|
sticky = mkOption {
|
|
type = types.nullOr types.bool;
|
|
description = "Whether the cursor should stay at its position";
|
|
default = null;
|
|
};
|
|
ignore = mkOption {
|
|
type = types.nullOr types.str;
|
|
description = "Lines to be ignored while comment/uncomment";
|
|
default = null;
|
|
};
|
|
preHook = helpers.mkNullOrLuaFn "Lua function called before (un)comment.";
|
|
postHook = helpers.mkNullOrLuaFn "Lua function called after (un)comment.";
|
|
toggler = mkOption {
|
|
type = types.nullOr (types.submodule (_: {
|
|
options = {
|
|
line = mkOption {
|
|
type = types.str;
|
|
description = "line-comment keymap";
|
|
default = "gcc";
|
|
};
|
|
block = mkOption {
|
|
type = types.str;
|
|
description = "block-comment keymap";
|
|
default = "gbc";
|
|
};
|
|
};
|
|
}));
|
|
description = "LHS of toggle mappings in NORMAL + VISUAL mode";
|
|
default = null;
|
|
};
|
|
opleader = mkOption {
|
|
type = types.nullOr (types.submodule (_: {
|
|
options = {
|
|
line = mkOption {
|
|
type = types.str;
|
|
description = "line-comment keymap";
|
|
default = "gc";
|
|
};
|
|
block = mkOption {
|
|
type = types.str;
|
|
description = "block-comment keymap";
|
|
default = "gb";
|
|
};
|
|
};
|
|
}));
|
|
description = "LHS of operator-pending mappings in NORMAL + VISUAL mode";
|
|
default = null;
|
|
};
|
|
mappings = mkOption {
|
|
type = types.nullOr (types.submodule (_: {
|
|
options = {
|
|
basic = mkOption {
|
|
type = types.bool;
|
|
description = "operator-pending mapping. Includes 'gcc', 'gcb', 'gc[count]{motion}' and 'gb[count]{motion}'";
|
|
default = true;
|
|
};
|
|
extra = mkOption {
|
|
type = types.bool;
|
|
description = "extra mapping. Includes 'gco', 'gc0', 'gcA'";
|
|
default = true;
|
|
};
|
|
extended = mkOption {
|
|
type = types.bool;
|
|
description = "extended mapping. Includes 'g>', 'g<', 'g>[count]{motion}' and 'g<[count]{motion}'";
|
|
default = false;
|
|
};
|
|
};
|
|
}));
|
|
description = "Create basic (operator-pending) and extended mappings for NORMAL + VISUAL mode";
|
|
default = null;
|
|
};
|
|
};
|
|
};
|
|
|
|
config = let
|
|
setupOptions = {
|
|
inherit (cfg) padding sticky ignore toggler opleader mappings;
|
|
pre_hook = cfg.preHook;
|
|
post_hook = cfg.postHook;
|
|
};
|
|
in
|
|
mkIf cfg.enable {
|
|
extraPlugins = [cfg.package];
|
|
extraConfigLua = ''require("Comment").setup${helpers.toLuaObject setupOptions}'';
|
|
};
|
|
}
|