feat: add gesture.nvim keybindings

This commit is contained in:
n3oney 2023-05-02 22:12:45 +02:00
parent d5eb3e87ed
commit dce3d762d9
No known key found for this signature in database
GPG Key ID: C786693DE727850E
2 changed files with 20 additions and 15 deletions

View File

@ -6,21 +6,26 @@
with lib;
with builtins; let
cfg = config.vim.gestures.gesture-nvim;
self = import ./gesture-nvim.nix {inherit lib;};
mappingDefinitions = self.options.vim.gestures.gesture-nvim.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["gesture-nvim"];
vim.maps.normal = mkMerge [
(mkSetLuaBinding mappings.draw "require('gesture').draw")
(mkSetLuaBinding mappings.finish "require('gesture').finish")
(mkIf (mappings.draw.value == "<RightDrag>") {
"<RightMouse>" = {action = "<Nop>";};
})
];
vim.luaConfigRC.gesture-nvim = nvim.dag.entryAnywhere ''
vim.opt.mouse = "a"
vim.keymap.set("n", "<LeftDrag>", [[<Cmd>lua require("gesture").draw()<CR>]], { silent = true })
vim.keymap.set("n", "<LeftRelease>", [[<Cmd>lua require("gesture").finish()<CR>]], { silent = true })
-- or if you would like to use right click
-- vim.keymap.set("n", "<RightMouse>", [[<Nop>]])
-- vim.keymap.set("n", "<RightDrag>", [[<Cmd>lua require("gesture").draw()<CR>]], { silent = true })
-- vim.keymap.set("n", "<RightRelease>", [[<Cmd>lua require("gesture").finish()<CR>]], { silent = true })
local gesture = require("gesture")
gesture.register({
name = "scroll to bottom",

View File

@ -1,11 +1,11 @@
{
config,
lib,
...
}:
with lib;
with builtins; {
{lib, ...}:
with lib; {
options.vim.gestures.gesture-nvim = {
enable = mkEnableOption "Enable gesture-nvim plugin";
mappings = {
draw = mkMappingOption "Start drawing [gesture.nvim]" "<LeftDrag>";
finish = mkMappingOption "Finish drawing [gesture.nvim]" "<LeftRelease>";
};
};
}