plugins/cursorline: migrate to mkNeovimPlugin

This commit is contained in:
Austin Horstman 2025-02-01 13:47:38 -06:00
parent ccd0092988
commit 3aabd32181
No known key found for this signature in database
3 changed files with 78 additions and 53 deletions

View file

@ -1,61 +1,55 @@
{ {
lib, lib,
helpers,
config,
pkgs,
... ...
}: }:
with lib;
let let
cfg = config.plugins.cursorline; inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
in in
{ lib.nixvim.plugins.mkNeovimPlugin {
options.plugins.cursorline = lib.nixvim.plugins.neovim.extraOptionsOptions // { name = "cursorline";
enable = mkEnableOption "nvim-cursorline"; moduleName = "nvim-cursorline";
packPathName = "nvim-cursorline";
package = "nvim-cursorline";
package = lib.mkPackageOption pkgs "nvim-cursorline" { maintainers = [ lib.maintainers.khaneliman ];
default = [
"vimPlugins"
"nvim-cursorline"
];
};
description = ''
A Neovim plugin to highlight the cursor line and word under the cursor.
'';
settingsOptions = {
cursorline = { cursorline = {
enable = helpers.defaultNullOpts.mkBool true "Show / hide cursorline in connection with cursor moving."; enable = defaultNullOpts.mkBool true "Show / hide cursorline in connection with cursor moving.";
timeout = defaultNullOpts.mkInt 1000 "Time (in ms) after which the cursorline appears.";
timeout = helpers.defaultNullOpts.mkInt 1000 "Time (in ms) after which the cursorline appears."; number = defaultNullOpts.mkBool false "Whether to also highlight the line number.";
number = helpers.defaultNullOpts.mkBool false "Whether to also highlight the line number.";
}; };
cursorword = { cursorword = {
enable = helpers.defaultNullOpts.mkBool true "Underlines the word under the cursor."; enable = defaultNullOpts.mkBool true "Underlines the word under the cursor.";
min_length = defaultNullOpts.mkInt 3 "Minimum length for underlined words.";
minLength = helpers.defaultNullOpts.mkInt 3 "Minimum length for underlined words."; hl = defaultNullOpts.mkAttrsOf types.anything {
hl = helpers.defaultNullOpts.mkAttrsOf types.anything {
underline = true; underline = true;
} "Highliht definition map for cursorword highlighting."; } "Highlight definition map for cursorword highlighting.";
}; };
}; };
config = settingsExample = {
let settings = {
options = { cursorline = {
cursorline = with cfg.cursorline; { enable = true;
inherit enable timeout number; timeout = 1000;
number = false;
};
cursorword = {
enable = true;
min_length = 3;
hl = {
underline = true;
}; };
cursorword = with cfg.cursorword; { };
inherit enable;
min_length = minLength;
inherit hl;
};
} // cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require('nvim-cursorline').setup(${lib.nixvim.toLuaObject options})
'';
}; };
};
# TODO: Deprecated in 2025-02-01
inherit (import ./deprecations.nix) deprecateExtraOptions optionsRenamedToSettings;
} }

View file

@ -0,0 +1,29 @@
{
deprecateExtraOptions = true;
optionsRenamedToSettings = [
[
"cursorline"
"enable"
]
[
"cursorline"
"timeout"
]
[
"cursorline"
"number"
]
[
"cursorword"
"enable"
]
[
"cursorword"
"minLength"
]
[
"cursorword"
"hl"
]
];
}

View file

@ -7,16 +7,18 @@
plugins.cursorline = { plugins.cursorline = {
enable = true; enable = true;
cursorline = { settings = {
enable = true; cursorline = {
timeout = 1000; enable = true;
number = false; timeout = 1000;
}; number = false;
cursorword = { };
enable = true; cursorword = {
minLength = 3; enable = true;
hl = { min_length = 3;
underline = true; hl = {
underline = true;
};
}; };
}; };
}; };