feat: add multicursors-nvim plugin

multicursors-nvim with hydra dependency and static config.
This commit is contained in:
Joseph Hanson 2025-02-07 20:24:46 -06:00
commit 09695f4fd4
No known key found for this signature in database
11 changed files with 326 additions and 0 deletions

View file

@ -181,6 +181,12 @@ isMaximal: {
leap.enable = true;
precognition.enable = isMaximal;
};
multicursors = {
enable = true;
setupOpts = {
DEBUG_MODE = true;
};
};
images = {
image-nvim.enable = false;

34
flake.lock generated
View file

@ -727,6 +727,22 @@
"type": "github"
}
},
"plugin-hydra-nvim": {
"flake": false,
"locked": {
"lastModified": 1735234935,
"narHash": "sha256-kgwkxeHcJfh0+I9cMix2M83Cp289sJX/BO81+VOp/sU=",
"owner": "nvimtools",
"repo": "hydra.nvim",
"rev": "983852960cd4e4e9a1b272df0bd1447495aae755",
"type": "github"
},
"original": {
"owner": "nvimtools",
"repo": "hydra.nvim",
"type": "github"
}
},
"plugin-icon-picker-nvim": {
"flake": false,
"locked": {
@ -1624,6 +1640,22 @@
"type": "github"
}
},
"plugin-multicursors-nvim": {
"flake": false,
"locked": {
"lastModified": 1723130615,
"narHash": "sha256-t5FKPwRx1PsU6HboZPx2sMVjU46AKb0nMfoFMpqesss=",
"owner": "smoka7",
"repo": "multicursors.nvim",
"rev": "562809aaf203b4c65482a75199166d360f2b9298",
"type": "github"
},
"original": {
"owner": "smoka7",
"repo": "multicursors.nvim",
"type": "github"
}
},
"plugin-neo-tree-nvim": {
"flake": false,
"locked": {
@ -2823,6 +2855,7 @@
"plugin-haskell-tools-nvim": "plugin-haskell-tools-nvim",
"plugin-highlight-undo": "plugin-highlight-undo",
"plugin-hop-nvim": "plugin-hop-nvim",
"plugin-hydra-nvim": "plugin-hydra-nvim",
"plugin-icon-picker-nvim": "plugin-icon-picker-nvim",
"plugin-image-nvim": "plugin-image-nvim",
"plugin-indent-blankline": "plugin-indent-blankline",
@ -2879,6 +2912,7 @@
"plugin-mini-visits": "plugin-mini-visits",
"plugin-minimap-vim": "plugin-minimap-vim",
"plugin-modes-nvim": "plugin-modes-nvim",
"plugin-multicursors-nvim": "plugin-multicursors-nvim",
"plugin-neo-tree-nvim": "plugin-neo-tree-nvim",
"plugin-neocord": "plugin-neocord",
"plugin-neodev-nvim": "plugin-neodev-nvim",

View file

@ -965,5 +965,15 @@
url = "github:echasnovski/mini.visits";
flake = false;
};
plugin-hydra-nvim = {
url = "github:nvimtools/hydra.nvim";
flake = false;
};
plugin-multicursors-nvim = {
url = "github:smoka7/multicursors.nvim";
flake = false;
};
};
}

View file

@ -0,0 +1,50 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
cfg = config.vim.hydra;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = [];
lazy.plugins.hydra = {
package = "hydra-nvim";
setupModule = "hydra";
#inherit (cfg) setupOpts;
setupOpts = {
debug = false;
exit = false;
foreign_keys = null;
color = "red";
timeout = false;
invoke_on_body = false;
hint = {
show_name = true;
position = "bottom";
offset = 0;
float_opts = {};
};
on_enter = null;
on_exit = null;
on_key = null;
};
after = ''
-- custom lua code to run after plugin is loaded
print('multicursors loaded')
'';
event = ["DeferredUIEnter"];
cmd = ["MCstart" "MCvisual" "MCclear" "MCpattern" "MCvisualPattern" "MCunderCursor"];
};
#keys = [
# (mkKeymap "n" mappings.mcStart "<cmd>MCstart<cr>" {desc = "Create a selection for selected text or word under the cursor [multicursors.nvim]";})
#];
# dependencies = [
# config.vim.lazy.plugins.hydra # hydra.nvim - Create custom submodes and menus
# ];
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./hydra.nix
./config.nix
];
}

View file

@ -0,0 +1,8 @@
{lib, ...}: let
#inherit (lib) types;
inherit (lib.options) mkEnableOption;
in {
options.vim.hydra = {
enable = mkEnableOption "Creating custom submodes and menus [nvimtools/hydra.nvim]";
};
}

View file

@ -8,6 +8,7 @@
./icon-picker
./images
./motion
./multicursors
./new-file-template
./outline
./preview

View file

@ -0,0 +1,68 @@
{
options,
config,
lib,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkKeymap;
inherit (lib.nvim.binds) addDescriptionsToMappings; # mkSetLuaBinding;
cfg = config.vim.utility.multicursors;
mappingDefinitions = options.vim.utility.multicursors.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["hydra-nvim"];
lazy.plugins.multicursors-nvim = {
package = "multicursors-nvim";
setupModule = "multicursors";
#inherit (cfg) setupOpts;
setupOpts = {
DEBUG_MODE = true;
create_commands = true;
updatetime = 50;
nowait = true;
mode_keys = {
append = "a";
change = "c";
extend = "e";
insert = "i";
};
hint_config = {
float_opts = {
border = "none";
};
position = "bottom";
};
generate_hints = {
normal = true;
insert = true;
extend = true;
config = {
column_count = null;
max_hint_length = 25;
};
};
};
event = ["DeferredUIEnter"];
cmd = ["MCstart" "MCvisual" "MCclear" "MCpattern" "MCvisualPattern" "MCunderCursor"];
keys = [
{
mode = ["v" "n"];
key = "<leader>mcs";
action = ":MCstart<cr>";
desc = "Create a selection for selected text or word under the cursor [multicursors.nvim]";
}
{
mode = ["v" "n"];
key = "<leader>mcp";
action = ":MCpattern<cr>";
desc = "Create a selection for pattern entered [multicursors.nvim]";
}
];
};
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./multicursors.nix
./config.nix
];
}

View file

@ -0,0 +1,17 @@
{lib, ...}: let
inherit (lib.types) bool int str;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.utility.multicursors = {
enable = mkEnableOption "multicursors.nvim plugin (vscode like multiple cursors)";
setupOpts = mkPluginSetupOption "multicursors" {
DEBUG_MODE = mkOption {
type = bool;
default = false;
};
};
};
}

View file

@ -0,0 +1,120 @@
{lib, ...}: let
inherit (lib.types) bool int str;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
hintConfig = {
float_opts = {
border = mkOption {
type = lib.types.str;
default = "none";
example = "rounded";
description = "The border style for the hint window";
};
};
position = mkOption {
default = "bottom";
type = lib.types.str;
description = "The position of the hint window";
example = "bottom";
};
};
generateHints = {
normal = mkOption {
type = bool;
default = true;
};
insert = mkOption {
type = bool;
default = true;
};
extend = mkOption {
type = bool;
default = true;
};
config = mkOption {
type = lib.types.attrsOf lib.types.str;
default = {
column_count = "nil";
max_hint_length = "25";
};
};
};
in {
options.vim.utility.multicursors = {
enable = mkEnableOption "multicursors.nvim plugin (vscode like multiple cursors)";
#mappings = {
# mcStart = mkOption {
# type = lib.types.nullOr str;
# description = "Create a selection for selected text or word under the cursor [multicursors.nvim]";
# default = "<leader>ms";
#};
#mcStart = mkMappingOption "Create a selection for selected text or word under the cursor [multicursors.nvim]" "<leader>ms";
#};
setupOpts = mkPluginSetupOption "multicursors" {
DEBUG_MODE = mkOption {
type = bool;
default = false;
};
create_commands = mkOption {
type = bool;
default = true;
description = "Create Multicursor user commands";
};
updatetime = mkOption {
type = int;
default = 50;
description = "The time in milliseconds to wait before updating the cursor in insert mode";
};
nowait = mkOption {
type = bool;
default = true;
};
mode_keys = mkOption {
type = lib.types.attrsOf str;
description = "The keys to use for each mode";
default = {
insert = "i";
append = "a";
change = "c";
extend = "e";
};
};
normal_keys = mkOption {
type = lib.types.str;
default = "normal_keys";
};
insert_keys = mkOption {
type = lib.types.str;
default = "insert_keys";
};
extend_keys = mkOption {
type = lib.types.str;
default = "extend_keys";
};
hint_config = mkOption {
type = lib.types.submodule hintConfig;
description = "The configuration for the hint window";
default = {
float_opts = {
border = "none";
};
position = "bottom";
};
};
generate_hints = mkOption {
type = lib.types.submodule generateHints;
description = "The configuration for generating hints";
default = {
normal = true;
insert = true;
extend = true;
config = {
column_count = null;
max_hint_length = 25;
};
};
};
};
};
}