From 3aabd321817cfcfce14690badf79c9bf1901b58a Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Sat, 1 Feb 2025 13:47:38 -0600 Subject: [PATCH] plugins/cursorline: migrate to mkNeovimPlugin --- plugins/by-name/cursorline/default.nix | 80 +++++++++---------- plugins/by-name/cursorline/deprecations.nix | 29 +++++++ .../plugins/by-name/cursorline/default.nix | 22 ++--- 3 files changed, 78 insertions(+), 53 deletions(-) create mode 100644 plugins/by-name/cursorline/deprecations.nix diff --git a/plugins/by-name/cursorline/default.nix b/plugins/by-name/cursorline/default.nix index 4602e92c..ddb9241d 100644 --- a/plugins/by-name/cursorline/default.nix +++ b/plugins/by-name/cursorline/default.nix @@ -1,61 +1,55 @@ { lib, - helpers, - config, - pkgs, ... }: -with lib; let - cfg = config.plugins.cursorline; + inherit (lib.nixvim) defaultNullOpts; + inherit (lib) types; in -{ - options.plugins.cursorline = lib.nixvim.plugins.neovim.extraOptionsOptions // { - enable = mkEnableOption "nvim-cursorline"; +lib.nixvim.plugins.mkNeovimPlugin { + name = "cursorline"; + moduleName = "nvim-cursorline"; + packPathName = "nvim-cursorline"; + package = "nvim-cursorline"; - package = lib.mkPackageOption pkgs "nvim-cursorline" { - default = [ - "vimPlugins" - "nvim-cursorline" - ]; - }; + maintainers = [ lib.maintainers.khaneliman ]; + description = '' + A Neovim plugin to highlight the cursor line and word under the cursor. + ''; + + settingsOptions = { cursorline = { - enable = helpers.defaultNullOpts.mkBool true "Show / hide cursorline in connection with cursor moving."; - - timeout = helpers.defaultNullOpts.mkInt 1000 "Time (in ms) after which the cursorline appears."; - - number = helpers.defaultNullOpts.mkBool false "Whether to also highlight the line number."; + enable = defaultNullOpts.mkBool true "Show / hide cursorline in connection with cursor moving."; + timeout = defaultNullOpts.mkInt 1000 "Time (in ms) after which the cursorline appears."; + number = defaultNullOpts.mkBool false "Whether to also highlight the line number."; }; cursorword = { - enable = helpers.defaultNullOpts.mkBool true "Underlines the word under the cursor."; - - minLength = helpers.defaultNullOpts.mkInt 3 "Minimum length for underlined words."; - - hl = helpers.defaultNullOpts.mkAttrsOf types.anything { + enable = defaultNullOpts.mkBool true "Underlines the word under the cursor."; + min_length = defaultNullOpts.mkInt 3 "Minimum length for underlined words."; + hl = defaultNullOpts.mkAttrsOf types.anything { underline = true; - } "Highliht definition map for cursorword highlighting."; + } "Highlight definition map for cursorword highlighting."; }; }; - config = - let - options = { - cursorline = with cfg.cursorline; { - inherit enable timeout number; + settingsExample = { + settings = { + cursorline = { + enable = true; + 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; } diff --git a/plugins/by-name/cursorline/deprecations.nix b/plugins/by-name/cursorline/deprecations.nix new file mode 100644 index 00000000..6a52c821 --- /dev/null +++ b/plugins/by-name/cursorline/deprecations.nix @@ -0,0 +1,29 @@ +{ + deprecateExtraOptions = true; + optionsRenamedToSettings = [ + [ + "cursorline" + "enable" + ] + [ + "cursorline" + "timeout" + ] + [ + "cursorline" + "number" + ] + [ + "cursorword" + "enable" + ] + [ + "cursorword" + "minLength" + ] + [ + "cursorword" + "hl" + ] + ]; +} diff --git a/tests/test-sources/plugins/by-name/cursorline/default.nix b/tests/test-sources/plugins/by-name/cursorline/default.nix index 3118c4e0..f85b991c 100644 --- a/tests/test-sources/plugins/by-name/cursorline/default.nix +++ b/tests/test-sources/plugins/by-name/cursorline/default.nix @@ -7,16 +7,18 @@ plugins.cursorline = { enable = true; - cursorline = { - enable = true; - timeout = 1000; - number = false; - }; - cursorword = { - enable = true; - minLength = 3; - hl = { - underline = true; + settings = { + cursorline = { + enable = true; + timeout = 1000; + number = false; + }; + cursorword = { + enable = true; + min_length = 3; + hl = { + underline = true; + }; }; }; };