utility/gesture-nvim: convert to vim.options

This commit is contained in:
raf 2025-01-04 16:08:11 +03:00
parent b67759273b
commit 85347de09d
No known key found for this signature in database
GPG key ID: EED98D11B85A2819
2 changed files with 40 additions and 36 deletions

View file

@ -15,43 +15,47 @@
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in {
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>";};
})
];
maps.normal = mkMerge [
(mkSetLuaBinding mappings.draw "require('gesture').draw")
(mkSetLuaBinding mappings.finish "require('gesture').finish")
(mkIf (mappings.draw.value == "<RightDrag>") {
"<RightMouse>" = {action = "<Nop>";};
})
];
vim.pluginRC.gesture-nvim = entryAnywhere ''
vim.opt.mouse = "a"
options.mouse = "a";
pluginRC.gesture-nvim = entryAnywhere ''
local gesture = require("gesture")
gesture.register({
name = "scroll to bottom",
inputs = { gesture.up(), gesture.down() },
action = "normal! G",
})
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)]],
})
'';
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)]],
})
'';
};
};
}

View file

@ -1,4 +1,4 @@
_: {
{
imports = [
./gesture-nvim.nix
./config.nix