Skip to content

Commit 3aabd32

Browse files
committed
plugins/cursorline: migrate to mkNeovimPlugin
1 parent ccd0092 commit 3aabd32

File tree

3 files changed

+78
-53
lines changed

3 files changed

+78
-53
lines changed
Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,55 @@
11
{
22
lib,
3-
helpers,
4-
config,
5-
pkgs,
63
...
74
}:
8-
with lib;
95
let
10-
cfg = config.plugins.cursorline;
6+
inherit (lib.nixvim) defaultNullOpts;
7+
inherit (lib) types;
118
in
12-
{
13-
options.plugins.cursorline = lib.nixvim.plugins.neovim.extraOptionsOptions // {
14-
enable = mkEnableOption "nvim-cursorline";
15-
16-
package = lib.mkPackageOption pkgs "nvim-cursorline" {
17-
default = [
18-
"vimPlugins"
19-
"nvim-cursorline"
20-
];
21-
};
9+
lib.nixvim.plugins.mkNeovimPlugin {
10+
name = "cursorline";
11+
moduleName = "nvim-cursorline";
12+
packPathName = "nvim-cursorline";
13+
package = "nvim-cursorline";
2214

23-
cursorline = {
24-
enable = helpers.defaultNullOpts.mkBool true "Show / hide cursorline in connection with cursor moving.";
15+
maintainers = [ lib.maintainers.khaneliman ];
2516

26-
timeout = helpers.defaultNullOpts.mkInt 1000 "Time (in ms) after which the cursorline appears.";
17+
description = ''
18+
A Neovim plugin to highlight the cursor line and word under the cursor.
19+
'';
2720

28-
number = helpers.defaultNullOpts.mkBool false "Whether to also highlight the line number.";
21+
settingsOptions = {
22+
cursorline = {
23+
enable = defaultNullOpts.mkBool true "Show / hide cursorline in connection with cursor moving.";
24+
timeout = defaultNullOpts.mkInt 1000 "Time (in ms) after which the cursorline appears.";
25+
number = defaultNullOpts.mkBool false "Whether to also highlight the line number.";
2926
};
3027
cursorword = {
31-
enable = helpers.defaultNullOpts.mkBool true "Underlines the word under the cursor.";
32-
33-
minLength = helpers.defaultNullOpts.mkInt 3 "Minimum length for underlined words.";
34-
35-
hl = helpers.defaultNullOpts.mkAttrsOf types.anything {
28+
enable = defaultNullOpts.mkBool true "Underlines the word under the cursor.";
29+
min_length = defaultNullOpts.mkInt 3 "Minimum length for underlined words.";
30+
hl = defaultNullOpts.mkAttrsOf types.anything {
3631
underline = true;
37-
} "Highliht definition map for cursorword highlighting.";
32+
} "Highlight definition map for cursorword highlighting.";
3833
};
3934
};
4035

41-
config =
42-
let
43-
options = {
44-
cursorline = with cfg.cursorline; {
45-
inherit enable timeout number;
46-
};
47-
cursorword = with cfg.cursorword; {
48-
inherit enable;
49-
min_length = minLength;
50-
inherit hl;
36+
settingsExample = {
37+
settings = {
38+
cursorline = {
39+
enable = true;
40+
timeout = 1000;
41+
number = false;
42+
};
43+
cursorword = {
44+
enable = true;
45+
min_length = 3;
46+
hl = {
47+
underline = true;
5148
};
52-
} // cfg.extraOptions;
53-
in
54-
mkIf cfg.enable {
55-
extraPlugins = [ cfg.package ];
56-
57-
extraConfigLua = ''
58-
require('nvim-cursorline').setup(${lib.nixvim.toLuaObject options})
59-
'';
49+
};
6050
};
51+
};
52+
53+
# TODO: Deprecated in 2025-02-01
54+
inherit (import ./deprecations.nix) deprecateExtraOptions optionsRenamedToSettings;
6155
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
deprecateExtraOptions = true;
3+
optionsRenamedToSettings = [
4+
[
5+
"cursorline"
6+
"enable"
7+
]
8+
[
9+
"cursorline"
10+
"timeout"
11+
]
12+
[
13+
"cursorline"
14+
"number"
15+
]
16+
[
17+
"cursorword"
18+
"enable"
19+
]
20+
[
21+
"cursorword"
22+
"minLength"
23+
]
24+
[
25+
"cursorword"
26+
"hl"
27+
]
28+
];
29+
}

tests/test-sources/plugins/by-name/cursorline/default.nix

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@
77
plugins.cursorline = {
88
enable = true;
99

10-
cursorline = {
11-
enable = true;
12-
timeout = 1000;
13-
number = false;
14-
};
15-
cursorword = {
16-
enable = true;
17-
minLength = 3;
18-
hl = {
19-
underline = true;
10+
settings = {
11+
cursorline = {
12+
enable = true;
13+
timeout = 1000;
14+
number = false;
15+
};
16+
cursorword = {
17+
enable = true;
18+
min_length = 3;
19+
hl = {
20+
underline = true;
21+
};
2022
};
2123
};
2224
};

0 commit comments

Comments
 (0)