treewide: migrate to vim.keymaps

This commit is contained in:
Ching Pei Yang 2026-06-12 14:44:46 +02:00 committed by Ching Pei Yang
commit 55a96f83b4
13 changed files with 218 additions and 162 deletions

View file

@ -4,26 +4,33 @@
options,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
inherit (lib.modules) mkIf;
inherit (lib.lists) optional;
inherit (lib.nvim.binds) mkKeymap;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.gestures.gesture-nvim;
mappingDefinitions = options.vim.gestures.gesture-nvim.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
inherit (options.vim.gestures.gesture-nvim) mappings;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["gesture-nvim"];
maps.normal = mkMerge [
(mkSetLuaBinding mappings.draw "require('gesture').draw")
(mkSetLuaBinding mappings.finish "require('gesture').finish")
(mkIf (mappings.draw.value == "<RightDrag>") {
"<RightMouse>" = {action = "<Nop>";};
})
];
keymaps =
[
(mkKeymap "n" cfg.mappings.draw "require('gesture').draw" {
desc = mappings.draw.description;
lua = true;
})
(mkKeymap "n" cfg.mappings.finish "require('gesture').finish" {
desc = mappings.finish.description;
lua = true;
})
]
++ optional
(cfg.mappings.draw == "<RightDrag>")
(mkKeymap "n" "<RightMouse>" "<Nop>" {desc = "Disable right mouse";});
options.mouse = "a";
pluginRC.gesture-nvim = entryAnywhere ''

View file

@ -5,20 +5,21 @@
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.binds) mkKeymap;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.motion.hop;
mappingDefinitions = options.vim.utility.motion.hop.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
inherit (options.vim.utility.motion.hop) mappings;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["hop.nvim"];
config.vim = mkIf cfg.enable {
startPlugins = ["hop.nvim"];
vim.maps.normal = mkSetBinding mappings.hop "<cmd> HopPattern<CR>";
keymaps = [
(mkKeymap "n" cfg.mappings.hop "<cmd>HopPattern<CR>" {desc = mappings.hop.description;})
];
vim.pluginRC.hop-nvim = entryAnywhere ''
pluginRC.hop-nvim = entryAnywhere ''
require('hop').setup()
'';
};

View file

@ -5,25 +5,25 @@
options,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkBinding pushDownDefault;
inherit (lib.modules) mkIf;
inherit (lib.nvim.binds) mkKeymap pushDownDefault;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.preview.glow;
inherit (options.vim.utility.preview.glow) mappings;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["glow-nvim"];
config.vim = mkIf cfg.enable {
startPlugins = ["glow-nvim"];
vim.maps.normal = mkMerge [
(mkBinding cfg.mappings.openPreview ":Glow<CR>" mappings.openPreview.description)
keymaps = [
(mkKeymap "n" cfg.mappings.openPreview ":Glow<CR>" {desc = mappings.openPreview.description;})
];
vim.binds.whichKey.register = pushDownDefault {
binds.whichKey.register = pushDownDefault {
"<leader>pm" = "+Preview Markdown";
};
vim.pluginRC.glow = entryAnywhere ''
pluginRC.glow = entryAnywhere ''
require('glow').setup({
glow_path = "${pkgs.glow}/bin/glow"
});