2024-10-31 13:16:46 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
2024-03-24 00:14:39 +00:00
|
|
|
inherit (lib.options) mkOption;
|
2024-10-31 13:16:46 +00:00
|
|
|
inherit (lib.types) bool str;
|
2024-10-06 11:35:07 +00:00
|
|
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
2024-10-31 13:16:46 +00:00
|
|
|
|
|
|
|
cfg = config.vim.utility.surround;
|
|
|
|
vendoredKeybinds = {
|
|
|
|
insert = "<C-g>z";
|
|
|
|
insert_line = "<C-g>Z";
|
|
|
|
normal = "gz";
|
|
|
|
normal_cur = "gZ";
|
|
|
|
normal_line = "gzz";
|
|
|
|
normal_cur_line = "gZZ";
|
|
|
|
visual = "gz";
|
|
|
|
visual_line = "gZ";
|
|
|
|
delete = "gzd";
|
|
|
|
change = "gzr";
|
|
|
|
change_line = "gZR";
|
|
|
|
};
|
|
|
|
|
|
|
|
mkKeymapOption = name: default:
|
|
|
|
mkOption {
|
|
|
|
description = "keymap for ${name}";
|
|
|
|
type = str;
|
|
|
|
default =
|
|
|
|
if cfg.useVendoredKeybindings
|
|
|
|
then vendoredKeybinds.${name}
|
|
|
|
else default;
|
|
|
|
};
|
2023-11-07 00:50:27 +00:00
|
|
|
in {
|
2023-06-07 11:28:27 +00:00
|
|
|
options.vim.utility.surround = {
|
2023-10-17 10:47:44 +00:00
|
|
|
enable = mkOption {
|
2024-03-24 00:14:39 +00:00
|
|
|
type = bool;
|
2023-10-17 10:47:44 +00:00
|
|
|
default = false;
|
2024-10-06 11:35:07 +00:00
|
|
|
description = ''
|
|
|
|
nvim-surround: add/change/delete surrounding delimiter pairs with ease.
|
|
|
|
Note that the default mappings deviate from upstreeam to avoid conflicts
|
|
|
|
with nvim-leap.
|
|
|
|
'';
|
2023-10-17 10:47:44 +00:00
|
|
|
};
|
2024-10-31 13:16:46 +00:00
|
|
|
setupOpts = mkPluginSetupOption "nvim-surround" {
|
|
|
|
keymaps = {
|
|
|
|
insert = mkKeymapOption "insert" "<C-g>s";
|
|
|
|
insert_line = mkKeymapOption "insert_line" "<C-g>S";
|
|
|
|
normal = mkKeymapOption "normal" "ys";
|
|
|
|
normal_cur = mkKeymapOption "normal_cur" "yss";
|
|
|
|
normal_line = mkKeymapOption "normal_line" "yS";
|
|
|
|
normal_cur_line = mkKeymapOption "normal_cur_line" "ySS";
|
|
|
|
visual = mkKeymapOption "visual" "S";
|
|
|
|
visual_line = mkKeymapOption "visual_line" "gS";
|
|
|
|
delete = mkKeymapOption "delete" "ds";
|
|
|
|
change = mkKeymapOption "change" "cs";
|
|
|
|
change_line = mkKeymapOption "change_line" "cS";
|
|
|
|
};
|
|
|
|
};
|
2024-10-06 11:35:07 +00:00
|
|
|
|
2023-10-17 10:47:44 +00:00
|
|
|
useVendoredKeybindings = mkOption {
|
2024-03-24 00:14:39 +00:00
|
|
|
type = bool;
|
2023-10-17 10:47:44 +00:00
|
|
|
default = true;
|
|
|
|
description = "Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap";
|
|
|
|
};
|
|
|
|
};
|
2023-06-07 11:28:27 +00:00
|
|
|
}
|