feat: mouse gestures & nvim-session-manager

This commit is contained in:
NotAShelf 2023-02-06 05:26:52 +03:00
parent 306d63f9d6
commit 1c8d224775
No known key found for this signature in database
GPG Key ID: 5B5C8895F28445F1
8 changed files with 146 additions and 0 deletions

View File

@ -320,6 +320,22 @@
"type": "github"
}
},
"gesture-nvim": {
"flake": false,
"locked": {
"lastModified": 1675384642,
"narHash": "sha256-HxVWZopV3wx6ANefuowrdbSQpQriYHV43r187t7UJXQ=",
"owner": "notomo",
"repo": "gesture.nvim",
"rev": "902a97219e126a08aea6016994c50eea485bcd79",
"type": "github"
},
"original": {
"owner": "notomo",
"repo": "gesture.nvim",
"type": "github"
}
},
"gitsigns-nvim": {
"flake": false,
"locked": {
@ -798,6 +814,22 @@
"type": "github"
}
},
"nvim-session-manager": {
"flake": false,
"locked": {
"lastModified": 1675414961,
"narHash": "sha256-dHFhZtBvU6sc6XR49oL3TW0sUwAOwLf4S5q+m8u76c8=",
"owner": "Shatur",
"repo": "neovim-session-manager",
"rev": "e7a2cbf56b5fd3a223f2774b535499fc62eca6ef",
"type": "github"
},
"original": {
"owner": "Shatur",
"repo": "neovim-session-manager",
"type": "github"
}
},
"nvim-tree-lua": {
"flake": false,
"locked": {
@ -983,6 +1015,7 @@
"discord-nvim": "discord-nvim",
"dressing-nvim": "dressing-nvim",
"flake-utils": "flake-utils",
"gesture-nvim": "gesture-nvim",
"gitsigns-nvim": "gitsigns-nvim",
"glow-nvim": "glow-nvim",
"icon-picker-nvim": "icon-picker-nvim",
@ -1009,6 +1042,7 @@
"nvim-lspconfig": "nvim-lspconfig",
"nvim-neoclip": "nvim-neoclip",
"nvim-notify": "nvim-notify",
"nvim-session-manager": "nvim-session-manager",
"nvim-tree-lua": "nvim-tree-lua",
"nvim-treesitter-context": "nvim-treesitter-context",
"nvim-ts-autotag": "nvim-ts-autotag",

View File

@ -173,6 +173,14 @@
copilot.enable = false;
tabnine.enable = false; # FIXME: this is not working because the plugin depends on an internal script to be ran by the package manager
};
vim.session = {
nvim-session-manager.enable = false;
};
vim.gestures = {
gesture-nvim.enable = false;
};
};
};
@ -582,6 +590,19 @@
flake = false;
};
# Session management
nvim-session-manager = {
url = "github:Shatur/neovim-session-manager";
flake = false;
};
# Mouse Gestures
gesture-nvim = {
url = "github:notomo/gesture.nvim";
flake = false;
};
# Dependencies
plenary-nvim = {
# (required by crates-nvim)

View File

@ -0,0 +1,5 @@
_: {
imports = [
./gesture-nvim.nix
];
}

View File

@ -0,0 +1,55 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.gestures.gesture-nvim;
in {
options.vim.gestures.gesture-nvim = {
enable = mkEnableOption "Enable GitHub Copilot";
};
config = mkIf cfg.enable {
vim.startPlugins = ["gesture-nvim"];
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",
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)]],
})
'';
};
}

View File

@ -64,6 +64,8 @@ with lib; let
"nui-nvim"
"copilot-lua"
"tabnine-nvim"
"nvim-session-manager"
"gesture-nvim"
];
# You can either use the name of the plugin or a package.
pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package));

View File

@ -30,6 +30,8 @@
./terminal
./ui
./assistant
./session
./gestures
];
pkgsModule = {config, ...}: {

View File

@ -0,0 +1,5 @@
_: {
imports = [
./nvim-session-manager.nix
];
}

View File

@ -0,0 +1,22 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.session.nvim-session-manager;
in {
options.vim.session.nvim-session-manager = {
enable = mkEnableOption "Enable nvim-session-manager";
};
config = mkIf cfg.enable {
vim.startPlugins = ["nvim-session-manager"];
vim.luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere ''
require('session_manager').setup({})
'';
};
}