plugins/lastplace: migrate to mkNeovimPlugin

This commit is contained in:
Austin Horstman 2025-02-01 17:37:51 -06:00
parent a3eed84e1e
commit 10ea28fff4
No known key found for this signature in database
3 changed files with 74 additions and 43 deletions

View file

@ -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
;
}

View file

@ -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;
}

View file

@ -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;
};
};
};
}