mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-30 00:26:45 +00:00
feat: add gesture.nvim keybindings
This commit is contained in:
parent
d5eb3e87ed
commit
dce3d762d9
2 changed files with 20 additions and 15 deletions
|
@ -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",
|
||||||
|
|
|
@ -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>";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue