nix-community.nixvim/plugins/by-name/cursorline/default.nix

62 lines
1.5 KiB
Nix
Raw Normal View History

2023-06-13 09:39:54 +02:00
{
lib,
helpers,
config,
pkgs,
2023-06-13 09:39:54 +02:00
...
}:
2024-05-05 19:39:35 +02:00
with lib;
let
2023-06-13 09:39:54 +02:00
cfg = config.plugins.cursorline;
2024-05-05 19:39:35 +02:00
in
{
options.plugins.cursorline = lib.nixvim.neovim-plugin.extraOptionsOptions // {
2024-05-05 19:39:35 +02:00
enable = mkEnableOption "nvim-cursorline";
2023-06-13 09:39:54 +02:00
package = lib.mkPackageOption pkgs "nvim-cursorline" {
default = [
"vimPlugins"
"nvim-cursorline"
];
};
2023-06-13 09:39:54 +02:00
2024-05-05 19:39:35 +02:00
cursorline = {
enable = helpers.defaultNullOpts.mkBool true "Show / hide cursorline in connection with cursor moving.";
2023-06-13 09:39:54 +02:00
2024-05-05 19:39:35 +02:00
timeout = helpers.defaultNullOpts.mkInt 1000 "Time (in ms) after which the cursorline appears.";
2023-06-13 09:39:54 +02:00
2024-05-05 19:39:35 +02:00
number = helpers.defaultNullOpts.mkBool false "Whether to also highlight the line number.";
};
cursorword = {
enable = helpers.defaultNullOpts.mkBool true "Underlines the word under the cursor.";
2023-06-13 09:39:54 +02:00
2024-05-05 19:39:35 +02:00
minLength = helpers.defaultNullOpts.mkInt 3 "Minimum length for underlined words.";
2023-06-13 09:39:54 +02:00
hl = helpers.defaultNullOpts.mkAttrsOf types.anything {
underline = true;
} "Highliht definition map for cursorword highlighting.";
2023-06-13 09:39:54 +02:00
};
2024-05-05 19:39:35 +02:00
};
2023-06-13 09:39:54 +02:00
2024-05-05 19:39:35 +02:00
config =
let
options = {
2023-06-13 09:39:54 +02:00
cursorline = with cfg.cursorline; {
inherit enable timeout number;
};
cursorword = with cfg.cursorword; {
inherit enable;
min_length = minLength;
inherit hl;
};
2024-05-05 19:39:35 +02:00
} // cfg.extraOptions;
in
2023-06-13 09:39:54 +02:00
mkIf cfg.enable {
2024-05-05 19:39:35 +02:00
extraPlugins = [ cfg.package ];
2023-06-13 09:39:54 +02:00
extraConfigLua = ''
require('nvim-cursorline').setup(${lib.nixvim.toLuaObject options})
2023-06-13 09:39:54 +02:00
'';
};
}