From 10ea28fff49ec4f0452b4544a0003b187d38d5f4 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Sat, 1 Feb 2025 17:37:51 -0600 Subject: [PATCH] plugins/lastplace: migrate to mkNeovimPlugin --- plugins/by-name/lastplace/default.nix | 63 ++++++++++--------- plugins/by-name/lastplace/deprecations.nix | 28 +++++++++ .../plugins/by-name/lastplace/default.nix | 26 ++++---- 3 files changed, 74 insertions(+), 43 deletions(-) create mode 100644 plugins/by-name/lastplace/deprecations.nix diff --git a/plugins/by-name/lastplace/default.nix b/plugins/by-name/lastplace/default.nix index 29a42f56..42437846 100644 --- a/plugins/by-name/lastplace/default.nix +++ b/plugins/by-name/lastplace/default.nix @@ -1,54 +1,55 @@ { lib, - helpers, - config, - pkgs, ... }: let - cfg = config.plugins.lastplace; + inherit (lib.nixvim) defaultNullOpts; + inherit (lib) types; in -with lib; -{ - options.plugins.lastplace = lib.nixvim.plugins.neovim.extraOptionsOptions // { - enable = mkEnableOption "lastplace"; +lib.nixvim.plugins.mkNeovimPlugin { + name = "lastplace"; + moduleName = "nvim-lastplace"; + packPathName = "nvim-lastplace"; + package = "nvim-lastplace"; - package = lib.mkPackageOption pkgs "lastplace" { - default = [ - "vimPlugins" - "nvim-lastplace" - ]; - }; + maintainers = [ lib.maintainers.khaneliman ]; - ignoreBuftype = helpers.defaultNullOpts.mkListOf types.str [ + description = '' + A Neovim plugin that automatically opens files at your last edit position. + ''; + + settingsOptions = { + lastplace_ignore_buftype = defaultNullOpts.mkListOf types.str [ "quickfix" "nofix" "help" ] "The list of buffer types to ignore by lastplace."; - ignoreFiletype = helpers.defaultNullOpts.mkListOf types.str [ + lastplace_ignore_filetype = defaultNullOpts.mkListOf types.str [ "gitcommit" "gitrebase" "svn" "hgcommit" ] "The list of file types to ignore by lastplace."; - openFolds = helpers.defaultNullOpts.mkBool true "Whether closed folds are automatically opened when jumping to the last edit position."; + lastplace_open_folds = defaultNullOpts.mkBool true "Whether closed folds are automatically opened when jumping to the last edit position."; }; - config = - let - options = { - lastplace_ignore_buftype = cfg.ignoreBuftype; - lastplace_ignore_filetype = cfg.ignoreFiletype; - lastplace_open_folds = cfg.openFolds; - } // cfg.extraOptions; - in - mkIf cfg.enable { - extraPlugins = [ cfg.package ]; - - extraConfigLua = '' - require('nvim-lastplace').setup(${lib.nixvim.toLuaObject options}) - ''; + settingsExample = { + settings = { + lastplace_ignore_buftype = [ + "help" + ]; + lastplace_ignore_filetype = [ + "svn" + ]; + lastplace_open_folds = false; }; + }; + + # TODO: Deprecated 2025-02-01 + inherit (import ./deprecations.nix { inherit lib; }) + imports + deprecateExtraOptions + ; } diff --git a/plugins/by-name/lastplace/deprecations.nix b/plugins/by-name/lastplace/deprecations.nix new file mode 100644 index 00000000..82acb628 --- /dev/null +++ b/plugins/by-name/lastplace/deprecations.nix @@ -0,0 +1,28 @@ +{ lib }: +{ + imports = + let + basePath = [ + "plugins" + "lastplace" + ]; + + settingsPath = basePath ++ [ "settings" ]; + in + lib.nixvim.mkSettingsRenamedOptionModules basePath settingsPath [ + { + old = "ignoreBuftype"; + new = "lastplace_ignore_buftype"; + } + { + old = "ignoreFiletype"; + new = "lastplace_ignore_filetype"; + } + { + old = "openFolds"; + new = "lastplace_open_folds"; + } + ]; + + deprecateExtraOptions = true; +} diff --git a/tests/test-sources/plugins/by-name/lastplace/default.nix b/tests/test-sources/plugins/by-name/lastplace/default.nix index 60f2add0..05f9beb7 100644 --- a/tests/test-sources/plugins/by-name/lastplace/default.nix +++ b/tests/test-sources/plugins/by-name/lastplace/default.nix @@ -7,18 +7,20 @@ plugins.lastplace = { enable = true; - ignoreBuftype = [ - "quickfix" - "nofix" - "help" - ]; - ignoreFiletype = [ - "gitcommit" - "gitrebase" - "svn" - "hgcommit" - ]; - openFolds = true; + settings = { + lastplace_ignore_buftype = [ + "quickfix" + "nofix" + "help" + ]; + lastplace_ignore_filetype = [ + "gitcommit" + "gitrebase" + "svn" + "hgcommit" + ]; + lastplace_open_folds = true; + }; }; }; }