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 lib;
with builtins; let with builtins; let
cfg = config.vim.gestures.gesture-nvim; 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 { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["gesture-nvim"]; 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.luaConfigRC.gesture-nvim = nvim.dag.entryAnywhere ''
vim.opt.mouse = "a" 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") local gesture = require("gesture")
gesture.register({ gesture.register({
name = "scroll to bottom", name = "scroll to bottom",

View file

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