mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 13:20:44 +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 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",
|
||||
|
|
|
@ -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>";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue