neovim-flake/modules/utility/surround/config.nix
Kalle Jepsen 59c23f2855 utility/surround: Add mappings for nvim-surround
The default mappings for nvim-leap and nvim-surround conflict
(i.e. nvim-surround uses `S` in visual mode). This change adds options
to adapt the mappings for nvim-surround directly from the
surround-module.
2023-10-16 11:53:24 +02:00

43 lines
1.4 KiB
Nix

{
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.utility.surround;
self = import ./surround.nix {inherit lib;};
mappingDefinitions = self.options.vim.utility.surround.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = [
"nvim-surround"
];
luaConfigRC.surround = nvim.dag.entryAnywhere ''
require('nvim-surround').setup()
'';
maps = {
insert = mkMerge [
(mkSetBinding mappings.insert "<Plug>(nvim-surround-insert)")
(mkSetBinding mappings.insertLine "<Plug>(nvim-surround-insert-line)")
];
normal = mkMerge [
(mkSetBinding mappings.normal "<Plug>(nvim-surround-normal)")
(mkSetBinding mappings.normalCur "<Plug>(nvim-surround-normal-cur)")
(mkSetBinding mappings.normalLine "<Plug>(nvim-surround-normal-line)")
(mkSetBinding mappings.normalCurLine "<Plug>(nvim-surround-normal-cur-line)")
(mkSetBinding mappings.delete "<Plug>(nvim-surround-delete)")
(mkSetBinding mappings.change "<Plug>(nvim-surround-change)")
];
visualOnly = mkMerge [
(mkSetBinding mappings.visual "<Plug>(nvim-surround-visual)")
(mkSetBinding mappings.visualLine "<Plug>(nvim-surround-visual-line)")
];
};
};
};
}