From dce3d762d9c060306bcd820e8a5cf30de190f127 Mon Sep 17 00:00:00 2001 From: n3oney Date: Tue, 2 May 2023 22:12:45 +0200 Subject: [PATCH] feat: add gesture.nvim keybindings --- .../utility/gestures/gesture-nvim/config.nix | 21 ++++++++++++------- .../gestures/gesture-nvim/gesture-nvim.nix | 14 ++++++------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/modules/utility/gestures/gesture-nvim/config.nix b/modules/utility/gestures/gesture-nvim/config.nix index e1e1c34..046c062 100644 --- a/modules/utility/gestures/gesture-nvim/config.nix +++ b/modules/utility/gestures/gesture-nvim/config.nix @@ -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 == "") { + "" = {action = "";}; + }) + ]; + vim.luaConfigRC.gesture-nvim = nvim.dag.entryAnywhere '' vim.opt.mouse = "a" - vim.keymap.set("n", "", [[lua require("gesture").draw()]], { silent = true }) - vim.keymap.set("n", "", [[lua require("gesture").finish()]], { silent = true }) - - -- or if you would like to use right click - -- vim.keymap.set("n", "", [[]]) - -- vim.keymap.set("n", "", [[lua require("gesture").draw()]], { silent = true }) - -- vim.keymap.set("n", "", [[lua require("gesture").finish()]], { silent = true }) - local gesture = require("gesture") gesture.register({ name = "scroll to bottom", diff --git a/modules/utility/gestures/gesture-nvim/gesture-nvim.nix b/modules/utility/gestures/gesture-nvim/gesture-nvim.nix index 9c37148..d65f4cb 100644 --- a/modules/utility/gestures/gesture-nvim/gesture-nvim.nix +++ b/modules/utility/gestures/gesture-nvim/gesture-nvim.nix @@ -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]" ""; + finish = mkMappingOption "Finish drawing [gesture.nvim]" ""; + }; }; }