Skip to content

Commit b994158

Browse files
jahansonNotAShelf
andauthored
utility/multicursors-nvim: init #610)
* feat: add multicursors-nvim plugin multicursors-nvim with hydra dependency and static config. * add most used default options * add more descriptions and refine * disable debug mode * maximal by default * add multicursors addition to changelog * Update modules/plugins/hydra/hydra.nix place hydra plugin in utility folder Co-authored-by: raf <raf@notashelf.dev> * clean up hydra config and implementation * mention hydra dependency addition * update to using npins instead of flake based additions. --------- Co-authored-by: raf <raf@notashelf.dev> Co-authored-by: raf <me@notashelf.dev>
1 parent 5fbc72d commit b994158

File tree

10 files changed

+241
-1
lines changed

10 files changed

+241
-1
lines changed

configuration.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ isMaximal: {
183183
leap.enable = true;
184184
precognition.enable = isMaximal;
185185
};
186-
186+
multicursors.enable = isMaximal;
187187
images = {
188188
image-nvim.enable = false;
189189
};

docs/release-notes/rl-0.8.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@
159159

160160
- Add support for [nixd](https://github.com/nix-community/nixd) language server.
161161

162+
[jahanson](https://github.com/jahanson):
163+
164+
- Add [multicursors.nvim](https://github.com/smoka7/multicursors.nvim) to
165+
available plugins, under `vim.utility.multicursors`.
166+
- Add [hydra.nvim](https://github.com/nvimtools/hydra.nvim) as dependency for
167+
`multicursors.nvim` and lazy loads by default.
162168
[folospior](https://github.com/folospior)
163169

164170
- Fix plugin name for lsp/lspkind.

modules/plugins/hydra/config.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
config,
3+
lib,
4+
...
5+
}: let
6+
inherit (lib.modules) mkIf;
7+
cfg = config.vim.hydra;
8+
in {
9+
config = mkIf cfg.enable {
10+
vim = {
11+
startPlugins = [];
12+
lazy.plugins.hydra = {
13+
package = "hydra.nvim";
14+
setupModule = "hydra";
15+
inherit (cfg) setupOpts;
16+
17+
event = ["DeferredUIEnter"];
18+
cmd = ["MCstart" "MCvisual" "MCclear" "MCpattern" "MCvisualPattern" "MCunderCursor"];
19+
};
20+
};
21+
};
22+
}

modules/plugins/hydra/default.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
imports = [
3+
./hydra.nix
4+
./config.nix
5+
];
6+
}

modules/plugins/hydra/hydra.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{lib, ...}: let
2+
inherit (lib.options) mkEnableOption;
3+
in {
4+
options.vim.utility.hydra = {
5+
enable = mkEnableOption "utility for creating custom submodes and menus [nvimtools/hydra.nvim]";
6+
};
7+
}

modules/plugins/utility/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
./icon-picker
99
./images
1010
./motion
11+
./multicursors
1112
./new-file-template
1213
./outline
1314
./preview
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
config,
3+
lib,
4+
...
5+
}: let
6+
inherit (lib.modules) mkIf;
7+
cfg = config.vim.utility.multicursors;
8+
in {
9+
config = mkIf cfg.enable {
10+
vim = {
11+
startPlugins = ["hydra-nvim"];
12+
lazy.plugins."multicursors-nvim" = {
13+
package = "multicursors-nvim";
14+
setupModule = "multicursors";
15+
inherit (cfg) setupOpts;
16+
17+
event = ["DeferredUIEnter"];
18+
cmd = ["MCstart" "MCvisual" "MCclear" "MCpattern" "MCvisualPattern" "MCunderCursor"];
19+
keys = [
20+
{
21+
mode = ["v" "n"];
22+
key = "<leader>mcs";
23+
action = ":MCstart<cr>";
24+
desc = "Create a selection for selected text or word under the cursor [multicursors.nvim]";
25+
}
26+
{
27+
mode = ["v" "n"];
28+
key = "<leader>mcp";
29+
action = ":MCpattern<cr>";
30+
desc = "Create a selection for pattern entered [multicursors.nvim]";
31+
}
32+
];
33+
};
34+
};
35+
};
36+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
imports = [
3+
./multicursors.nix
4+
./config.nix
5+
];
6+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{lib, ...}: let
2+
inherit (lib.types) bool int str;
3+
inherit (lib.nvim.types) mkPluginSetupOption;
4+
inherit (lib.options) mkOption mkEnableOption;
5+
hintConfig = {lib, ...}: {
6+
options = {
7+
float_opts = mkOption {
8+
description = "The options for the floating hint window";
9+
type = lib.types.submodule {
10+
options = {
11+
border = mkOption {
12+
type = lib.types.str;
13+
default = "none";
14+
description = "The border style for the hint window";
15+
};
16+
};
17+
};
18+
};
19+
position = mkOption {
20+
type = lib.types.str;
21+
default = "bottom";
22+
description = "The position of the hint window";
23+
};
24+
};
25+
};
26+
generateHints = {lib, ...}: {
27+
options = {
28+
normal = mkOption {
29+
type = lib.types.bool;
30+
description = "Generate hints for the normal mode";
31+
default = true;
32+
};
33+
insert = mkOption {
34+
type = lib.types.bool;
35+
description = "Generate hints for the insert mode";
36+
default = true;
37+
};
38+
extend = mkOption {
39+
type = lib.types.bool;
40+
description = "Generate hints for the extend mode";
41+
default = true;
42+
};
43+
config = mkOption {
44+
description = "The configuration for generating hints for multicursors.nvim";
45+
type = lib.types.submodule {
46+
options = {
47+
column_count = mkOption {
48+
type = lib.types.nullOr int;
49+
description = "The number of columns to use for the hint window";
50+
default = null;
51+
};
52+
max_hint_length = mkOption {
53+
type = int;
54+
description = "The maximum length of the hint";
55+
default = 25;
56+
};
57+
};
58+
};
59+
default = {
60+
column_count = null;
61+
max_hint_length = 25;
62+
};
63+
};
64+
};
65+
};
66+
in {
67+
options.vim.utility.multicursors = {
68+
enable = mkEnableOption "multicursors.nvim plugin (vscode like multiple cursors)";
69+
70+
setupOpts = mkPluginSetupOption "multicursors" {
71+
DEBUG_MODE = mkOption {
72+
type = bool;
73+
default = false;
74+
description = "Enable debug mode.";
75+
};
76+
create_commands = mkOption {
77+
type = bool;
78+
default = true;
79+
description = "Create Multicursor user commands";
80+
};
81+
updatetime = mkOption {
82+
type = int;
83+
default = 50;
84+
description = "The time in milliseconds to wait before updating the cursor in insert mode";
85+
};
86+
nowait = mkOption {
87+
type = bool;
88+
description = "Don't wait for the cursor to move before updating the cursor";
89+
default = true;
90+
};
91+
mode_keys = mkOption {
92+
type = lib.types.attrsOf str;
93+
description = "The keys to use for each mode";
94+
default = {
95+
insert = "i";
96+
append = "a";
97+
change = "c";
98+
extend = "e";
99+
};
100+
};
101+
hint_config = mkOption {
102+
type = lib.types.submodule hintConfig;
103+
description = "The configuration for the hint window";
104+
default = {
105+
float_opts = {
106+
border = "none";
107+
};
108+
position = "bottom";
109+
};
110+
};
111+
generate_hints = mkOption {
112+
type = lib.types.submodule generateHints;
113+
description = "The configuration for generating hints";
114+
default = {
115+
normal = true;
116+
insert = true;
117+
extend = true;
118+
config = {
119+
column_count = null;
120+
max_hint_length = 25;
121+
};
122+
};
123+
};
124+
};
125+
};
126+
}

npins/sources.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,21 @@
507507
"url": "https://github.com/phaazon/hop.nvim/archive/1a1eceafe54b5081eae4cb91c723abd1d450f34b.tar.gz",
508508
"hash": "08h18cam2yr57qvfsnf1bra28vbl6013wlchnr5crb757xw8aysa"
509509
},
510+
"hydra-nvim": {
511+
"type": "GitRelease",
512+
"repository": {
513+
"type": "GitHub",
514+
"owner": "nvimtools",
515+
"repo": "hydra.nvim"
516+
},
517+
"pre_releases": false,
518+
"version_upper_bound": null,
519+
"release_prefix": null,
520+
"version": "v1.0.2",
521+
"revision": "8578056a2226ed49fc608167edc143a87f75d809",
522+
"url": "https://api.github.com/repos/nvimtools/hydra.nvim/tarball/v1.0.2",
523+
"hash": "13f04pmqrfl65xx9bfkdak6ll57s94anaw7nqd0fm5hp50b7c6j3"
524+
},
510525
"icon-picker-nvim": {
511526
"type": "Git",
512527
"repository": {
@@ -1202,6 +1217,21 @@
12021217
"url": "https://github.com/mvllow/modes.nvim/archive/c7a4b1b383606832aab150902719bd5eb5cdb2b0.tar.gz",
12031218
"hash": "1hy3ghscf8hfmg487p9b8cwd0y8nsi8j24kq2ir3vhd82gqhl4ja"
12041219
},
1220+
"multicursors-nvim": {
1221+
"type": "GitRelease",
1222+
"repository": {
1223+
"type": "GitHub",
1224+
"owner": "smoka7",
1225+
"repo": "multicursors.nvim"
1226+
},
1227+
"pre_releases": false,
1228+
"version_upper_bound": null,
1229+
"release_prefix": null,
1230+
"version": "v2.0.0",
1231+
"revision": "782820896b1691ed664e4c24f1cd9793dcb33dfb",
1232+
"url": "https://api.github.com/repos/smoka7/multicursors.nvim/tarball/v2.0.0",
1233+
"hash": "171aysqsyapw434xkibxv69p5fkwha4addkqfdssdm0wq9n9cm4q"
1234+
},
12051235
"neo-tree-nvim": {
12061236
"type": "Git",
12071237
"repository": {

0 commit comments

Comments
 (0)