nvf/modules/plugins/utility/surround/config.nix

56 lines
1.3 KiB
Nix
Raw Normal View History

2023-06-07 11:28:27 +00:00
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
2024-03-24 00:14:39 +00:00
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
2023-06-07 11:28:27 +00:00
cfg = config.vim.utility.surround;
2024-10-06 18:13:39 +00:00
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";
};
mkLznKey = mode: key: {
inherit key mode;
};
2023-06-07 11:28:27 +00:00
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["nvim-surround"];
pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})";
2023-06-07 11:28:27 +00:00
2024-10-17 15:17:18 +00:00
lazy.plugins.nvim-surround = {
package = "nvim-surround";
setupModule = "nvim-surround";
inherit (cfg) setupOpts;
2024-10-06 18:13:39 +00:00
2024-10-17 15:17:18 +00:00
keys =
map (mkLznKey ["i"]) (with vendoredKeybinds; [insert insert_line])
++ map (mkLznKey ["x"]) (with vendoredKeybinds; [visual visual_line])
++ map (mkLznKey ["n"]) (with vendoredKeybinds; [
normal
normal_cur
normal_line
normal_cur_line
delete
change
change_line
]);
};
2024-10-06 18:13:39 +00:00
utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings vendoredKeybinds;
};
2023-06-07 11:28:27 +00:00
};
}