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" "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": { "gitsigns-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -798,6 +814,22 @@
"type": "github" "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": { "nvim-tree-lua": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -983,6 +1015,7 @@
"discord-nvim": "discord-nvim", "discord-nvim": "discord-nvim",
"dressing-nvim": "dressing-nvim", "dressing-nvim": "dressing-nvim",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"gesture-nvim": "gesture-nvim",
"gitsigns-nvim": "gitsigns-nvim", "gitsigns-nvim": "gitsigns-nvim",
"glow-nvim": "glow-nvim", "glow-nvim": "glow-nvim",
"icon-picker-nvim": "icon-picker-nvim", "icon-picker-nvim": "icon-picker-nvim",
@ -1009,6 +1042,7 @@
"nvim-lspconfig": "nvim-lspconfig", "nvim-lspconfig": "nvim-lspconfig",
"nvim-neoclip": "nvim-neoclip", "nvim-neoclip": "nvim-neoclip",
"nvim-notify": "nvim-notify", "nvim-notify": "nvim-notify",
"nvim-session-manager": "nvim-session-manager",
"nvim-tree-lua": "nvim-tree-lua", "nvim-tree-lua": "nvim-tree-lua",
"nvim-treesitter-context": "nvim-treesitter-context", "nvim-treesitter-context": "nvim-treesitter-context",
"nvim-ts-autotag": "nvim-ts-autotag", "nvim-ts-autotag": "nvim-ts-autotag",

View file

@ -173,6 +173,14 @@
copilot.enable = false; 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 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; 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 # Dependencies
plenary-nvim = { plenary-nvim = {
# (required by crates-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" "nui-nvim"
"copilot-lua" "copilot-lua"
"tabnine-nvim" "tabnine-nvim"
"nvim-session-manager"
"gesture-nvim"
]; ];
# You can either use the name of the plugin or a package. # You can either use the name of the plugin or a package.
pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package)); pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package));

View file

@ -30,6 +30,8 @@
./terminal ./terminal
./ui ./ui
./assistant ./assistant
./session
./gestures
]; ];
pkgsModule = {config, ...}: { 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({})
'';
};
}