Skip to content

Commit 8652cd1

Browse files
committed
refactor(wrapperModules.neovim): make generated code prettier
1 parent 62700f5 commit 8652cd1

File tree

2 files changed

+41
-43
lines changed

2 files changed

+41
-43
lines changed

wrapperModules/n/neovim/normalize.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
opt-dir,
3-
start-dir,
2+
opt_dir,
3+
start_dir,
44
specs,
55
specMaps,
66
info_plugin_name,
@@ -235,12 +235,12 @@ in
235235
buildPackDir = lib.pipe allPlugins [
236236
(map (
237237
v:
238-
"ln -s ${lib.escapeShellArg v.data} ${lib.escapeShellArg "${if v.lazy then opt-dir else start-dir}/${v.name}"}"
238+
"ln -s ${lib.escapeShellArg v.data} ${lib.escapeShellArg "${if v.lazy then opt_dir else start_dir}/${v.name}"}"
239239
))
240240
(builtins.concatStringsSep "\n")
241241
];
242242

243-
plugins4lua = lib.pipe allPlugins (
243+
plugins = lib.pipe allPlugins (
244244
let
245245
foldplugins = (builtins.foldl' (acc: v: acc // { ${v.name} = v.data; }) { });
246246
in

wrapperModules/n/neovim/packDir.nix

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@
66
...
77
}:
88
let
9-
inherit
10-
(pkgs.callPackage ./normalize.nix {
11-
inherit (config.settings) info_plugin_name;
12-
inherit wlib opt-dir start-dir;
13-
inherit (config) specs specMaps;
14-
})
15-
plugins4lua
16-
hasFennel
17-
infoPluginInitMain
18-
buildPackDir
19-
mappedSpecs
20-
;
219
inherit
2210
(
2311
let
@@ -44,7 +32,7 @@ let
4432
];
4533
in
4634
{
47-
collectedHosts = lib.pipe initial [
35+
hosts = lib.pipe initial [
4836
(map (v: {
4937
name = v.attrname;
5038
value = {
@@ -83,14 +71,26 @@ let
8371
];
8472
}
8573
)
86-
collectedHosts
74+
hosts
8775
hostLuaCmd
8876
hostLinkCmd
8977
;
90-
final-packdir = "${placeholder "out"}/${config.binName}-packdir";
91-
start-dir = "${final-packdir}/pack/myNeovimPackages/start";
92-
opt-dir = "${final-packdir}/pack/myNeovimPackages/opt";
93-
info-plugin-path = "${start-dir}/${config.settings.info_plugin_name}";
78+
inherit
79+
(pkgs.callPackage ./normalize.nix {
80+
inherit (config.settings) info_plugin_name;
81+
inherit wlib opt_dir start_dir;
82+
inherit (config) specs specMaps;
83+
})
84+
plugins
85+
hasFennel
86+
infoPluginInitMain
87+
buildPackDir
88+
mappedSpecs
89+
;
90+
vim_pack_dir = "${placeholder "out"}/${config.binName}-packdir";
91+
start_dir = "${vim_pack_dir}/pack/myNeovimPackages/start";
92+
opt_dir = "${vim_pack_dir}/pack/myNeovimPackages/opt";
93+
info_plugin_path = "${start_dir}/${config.settings.info_plugin_name}";
9494
in
9595
{
9696
config.drv.manifestLua = hostLuaCmd;
@@ -100,27 +100,25 @@ in
100100
config.drv.buildPackDir = buildPackDir;
101101
config.specCollect = fn: first: builtins.foldl' fn first mappedSpecs;
102102
config.drv.infoPluginText = /* lua */ ''
103-
return setmetatable({
104-
plugins = ${lib.generators.toLua { } plugins4lua},
105-
settings = ${
106-
lib.generators.toLua { } (
107-
lib.filterAttrsRecursive (_: v: !builtins.isFunction v) config.settings
108-
// {
109-
nvim_lua_env =
110-
(config.package.lua.withPackages or pkgs.luajit.withPackages)
111-
config.settings.nvim_lua_env;
112-
}
113-
)
114-
},
115-
wrapper_drv = ${builtins.toJSON "${placeholder "out"}"},
116-
binName = ${builtins.toJSON config.binName},
117-
info = ${lib.generators.toLua { } config.info},
118-
hosts = ${lib.generators.toLua { } collectedHosts},
119-
info_plugin_path = ${builtins.toJSON info-plugin-path},
120-
vim_pack_dir = ${builtins.toJSON final-packdir},
121-
start_dir = ${builtins.toJSON start-dir},
122-
opt_dir = ${builtins.toJSON opt-dir},
123-
progpath = ${builtins.toJSON "${placeholder "out"}/bin/${config.binName}"},
103+
return setmetatable(${
104+
lib.generators.toLua { } {
105+
settings = lib.filterAttrsRecursive (_: v: !builtins.isFunction v) config.settings // {
106+
nvim_lua_env =
107+
(config.package.lua.withPackages or pkgs.luajit.withPackages)
108+
config.settings.nvim_lua_env;
109+
};
110+
wrapper_drv = placeholder "out";
111+
progpath = "${placeholder "out"}/bin/${config.binName}";
112+
inherit (config) info binName;
113+
inherit
114+
plugins
115+
hosts
116+
info_plugin_path
117+
vim_pack_dir
118+
start_dir
119+
opt_dir
120+
;
121+
}
124122
}, {
125123
__call = function(self, default, ...)
126124
if select('#', ...) == 0 then return default end

0 commit comments

Comments
 (0)