mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-07 10:51:36 +00:00
treewide: begin restructuring the module tree
This commit is contained in:
parent
e1835f6c46
commit
7c730a78e5
254 changed files with 749 additions and 664 deletions
57
modules/plugins/utility/gestures/gesture-nvim/config.nix
Normal file
57
modules/plugins/utility/gestures/gesture-nvim/config.nix
Normal file
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
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 = entryAnywhere ''
|
||||
vim.opt.mouse = "a"
|
||||
|
||||
local gesture = require("gesture")
|
||||
gesture.register({
|
||||
name = "scroll to bottom",
|
||||
inputs = { gesture.up(), gesture.down() },
|
||||
action = "normal! G",
|
||||
})
|
||||
gesture.register({
|
||||
name = "next tab",
|
||||
inputs = { gesture.right() },
|
||||
action = "tabnext",
|
||||
})
|
||||
gesture.register({
|
||||
name = "previous tab",
|
||||
inputs = { gesture.left() },
|
||||
action = function(ctx) -- also can use callable
|
||||
vim.cmd.tabprevious()
|
||||
end,
|
||||
})
|
||||
gesture.register({
|
||||
name = "go back",
|
||||
inputs = { gesture.right(), gesture.left() },
|
||||
-- map to `<C-o>` keycode
|
||||
action = [[lua vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<C-o>", true, false, true), "n", true)]],
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./gesture-nvim.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
in {
|
||||
options.vim.gestures.gesture-nvim = {
|
||||
enable = mkEnableOption "gesture-nvim: mouse gestures";
|
||||
|
||||
mappings = {
|
||||
draw = mkMappingOption "Start drawing [gesture.nvim]" "<LeftDrag>";
|
||||
finish = mkMappingOption "Finish drawing [gesture.nvim]" "<LeftRelease>";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue