Skip to content

Commit 10ea28f

Browse files
committed
plugins/lastplace: migrate to mkNeovimPlugin
1 parent a3eed84 commit 10ea28f

File tree

3 files changed

+74
-43
lines changed

3 files changed

+74
-43
lines changed

plugins/by-name/lastplace/default.nix

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,55 @@
11
{
22
lib,
3-
helpers,
4-
config,
5-
pkgs,
63
...
74
}:
85
let
9-
cfg = config.plugins.lastplace;
6+
inherit (lib.nixvim) defaultNullOpts;
7+
inherit (lib) types;
108
in
11-
with lib;
12-
{
13-
options.plugins.lastplace = lib.nixvim.plugins.neovim.extraOptionsOptions // {
14-
enable = mkEnableOption "lastplace";
9+
lib.nixvim.plugins.mkNeovimPlugin {
10+
name = "lastplace";
11+
moduleName = "nvim-lastplace";
12+
packPathName = "nvim-lastplace";
13+
package = "nvim-lastplace";
1514

16-
package = lib.mkPackageOption pkgs "lastplace" {
17-
default = [
18-
"vimPlugins"
19-
"nvim-lastplace"
20-
];
21-
};
15+
maintainers = [ lib.maintainers.khaneliman ];
2216

23-
ignoreBuftype = helpers.defaultNullOpts.mkListOf types.str [
17+
description = ''
18+
A Neovim plugin that automatically opens files at your last edit position.
19+
'';
20+
21+
settingsOptions = {
22+
lastplace_ignore_buftype = defaultNullOpts.mkListOf types.str [
2423
"quickfix"
2524
"nofix"
2625
"help"
2726
] "The list of buffer types to ignore by lastplace.";
2827

29-
ignoreFiletype = helpers.defaultNullOpts.mkListOf types.str [
28+
lastplace_ignore_filetype = defaultNullOpts.mkListOf types.str [
3029
"gitcommit"
3130
"gitrebase"
3231
"svn"
3332
"hgcommit"
3433
] "The list of file types to ignore by lastplace.";
3534

36-
openFolds = helpers.defaultNullOpts.mkBool true "Whether closed folds are automatically opened when jumping to the last edit position.";
35+
lastplace_open_folds = defaultNullOpts.mkBool true "Whether closed folds are automatically opened when jumping to the last edit position.";
3736
};
3837

39-
config =
40-
let
41-
options = {
42-
lastplace_ignore_buftype = cfg.ignoreBuftype;
43-
lastplace_ignore_filetype = cfg.ignoreFiletype;
44-
lastplace_open_folds = cfg.openFolds;
45-
} // cfg.extraOptions;
46-
in
47-
mkIf cfg.enable {
48-
extraPlugins = [ cfg.package ];
49-
50-
extraConfigLua = ''
51-
require('nvim-lastplace').setup(${lib.nixvim.toLuaObject options})
52-
'';
38+
settingsExample = {
39+
settings = {
40+
lastplace_ignore_buftype = [
41+
"help"
42+
];
43+
lastplace_ignore_filetype = [
44+
"svn"
45+
];
46+
lastplace_open_folds = false;
5347
};
48+
};
49+
50+
# TODO: Deprecated 2025-02-01
51+
inherit (import ./deprecations.nix { inherit lib; })
52+
imports
53+
deprecateExtraOptions
54+
;
5455
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{ lib }:
2+
{
3+
imports =
4+
let
5+
basePath = [
6+
"plugins"
7+
"lastplace"
8+
];
9+
10+
settingsPath = basePath ++ [ "settings" ];
11+
in
12+
lib.nixvim.mkSettingsRenamedOptionModules basePath settingsPath [
13+
{
14+
old = "ignoreBuftype";
15+
new = "lastplace_ignore_buftype";
16+
}
17+
{
18+
old = "ignoreFiletype";
19+
new = "lastplace_ignore_filetype";
20+
}
21+
{
22+
old = "openFolds";
23+
new = "lastplace_open_folds";
24+
}
25+
];
26+
27+
deprecateExtraOptions = true;
28+
}

tests/test-sources/plugins/by-name/lastplace/default.nix

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77
plugins.lastplace = {
88
enable = true;
99

10-
ignoreBuftype = [
11-
"quickfix"
12-
"nofix"
13-
"help"
14-
];
15-
ignoreFiletype = [
16-
"gitcommit"
17-
"gitrebase"
18-
"svn"
19-
"hgcommit"
20-
];
21-
openFolds = true;
10+
settings = {
11+
lastplace_ignore_buftype = [
12+
"quickfix"
13+
"nofix"
14+
"help"
15+
];
16+
lastplace_ignore_filetype = [
17+
"gitcommit"
18+
"gitrebase"
19+
"svn"
20+
"hgcommit"
21+
];
22+
lastplace_open_folds = true;
23+
};
2224
};
2325
};
2426
}

0 commit comments

Comments
 (0)