mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-20 02:18:06 +00:00
surround-nvim: lazy load
This commit is contained in:
parent
6ae18403a8
commit
4701bb15c5
1 changed files with 38 additions and 13 deletions
|
@ -8,25 +8,50 @@
|
|||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
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";
|
||||
};
|
||||
mkLznKey = mode: key: {
|
||||
inherit key mode;
|
||||
};
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["nvim-surround"];
|
||||
pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})";
|
||||
|
||||
utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings {
|
||||
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";
|
||||
};
|
||||
lazy.plugins = [
|
||||
{
|
||||
package = "nvim-surround";
|
||||
setupModule = "nvim-surround";
|
||||
inherit (cfg) setupOpts;
|
||||
|
||||
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
|
||||
]);
|
||||
}
|
||||
];
|
||||
|
||||
utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings vendoredKeybinds;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue