refactor: init module has simler configuration
parent
2816b256d4
commit
c00555d6d8
|
|
@ -51,19 +51,17 @@ in {
|
||||||
}: let
|
}: let
|
||||||
pkg = pkgs.wrapNeovimUnstable config.package config.neovimOptions;
|
pkg = pkgs.wrapNeovimUnstable config.package config.neovimOptions;
|
||||||
|
|
||||||
customLuaRC = modules.init.mkCustomLuaRc config.init;
|
neovimOptions = pkgs.neovimUtils.makeNeovimConfig rec {
|
||||||
|
inherit (config) extraLuaPackages viAlias vimAlias;
|
||||||
|
|
||||||
|
customLuaRC = config.init.finalContent;
|
||||||
|
wrapRc = customLuaRC != null;
|
||||||
|
|
||||||
plugins = concatLists [
|
plugins = concatLists [
|
||||||
(map modules.plugin.extract config.plugins)
|
(map modules.plugin.extract config.plugins)
|
||||||
(optional (! isNull config.runtime) config.runtime.package)
|
(optional (! isNull config.runtime) config.runtime.package)
|
||||||
[config.slothPlugin]
|
[config.slothPlugin]
|
||||||
];
|
];
|
||||||
|
|
||||||
neovimOptions = pkgs.neovimUtils.makeNeovimConfig {
|
|
||||||
inherit (config) extraLuaPackages viAlias vimAlias;
|
|
||||||
inherit customLuaRC plugins;
|
|
||||||
wrapRc = customLuaRC != null;
|
|
||||||
# inherit customRC;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
neovimPackage = pkg.overrideAttrs (final: super: {
|
neovimPackage = pkg.overrideAttrs (final: super: {
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,15 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) isAttrs isPath isString readFile;
|
inherit (builtins) isAttrs isPath isString readFile;
|
||||||
inherit
|
inherit (pkgs.lib) fileContents fix mkOption optionalAttrs optionalString types;
|
||||||
(pkgs.lib)
|
|
||||||
fileContents
|
|
||||||
fix
|
|
||||||
mkOption
|
|
||||||
optionalAttrs
|
|
||||||
optionalString
|
|
||||||
types
|
|
||||||
;
|
|
||||||
|
|
||||||
lua = callModule ../lua.nix {};
|
lua = callModule ../lua.nix {};
|
||||||
|
|
||||||
|
coerceToModule = value:
|
||||||
|
if isAttrs value
|
||||||
|
then value
|
||||||
|
else {finalContent = textOrContent value;};
|
||||||
|
|
||||||
textOrContent = content:
|
textOrContent = content:
|
||||||
if isPath content
|
if isPath content
|
||||||
then fileContents content
|
then fileContents content
|
||||||
|
|
@ -25,6 +22,7 @@
|
||||||
init ? null,
|
init ? null,
|
||||||
postInit ? null,
|
postInit ? null,
|
||||||
config ? null,
|
config ? null,
|
||||||
|
...
|
||||||
}: let
|
}: let
|
||||||
initStr = optionalString (! isNull init) ''
|
initStr = optionalString (! isNull init) ''
|
||||||
(function()
|
(function()
|
||||||
|
|
@ -34,10 +32,10 @@
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postInitContent = optionalAttrs (! isNull postInit) {
|
postInitContent = optionalAttrs (! isNull postInit) {
|
||||||
post_init = lua.lambda [] (textOrContent (lua.raw postInit));
|
post_init = lua.lambda [] (lua.raw (textOrContent postInit));
|
||||||
};
|
};
|
||||||
|
|
||||||
slothCall = "require('sloth-flake').setup ${lua.renderLua {} postInitContent}";
|
slothCall = "require('sloth-flake').setup ${lua.renderLua {} postInitContent};";
|
||||||
|
|
||||||
configStr = optionalString (! isNull config) ''
|
configStr = optionalString (! isNull config) ''
|
||||||
|
|
||||||
|
|
@ -53,7 +51,7 @@
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
fix (self: {
|
fix (self: {
|
||||||
module = types.submodule {
|
module = types.submodule ({config, ...}: {
|
||||||
options = {
|
options = {
|
||||||
init = mkOption {
|
init = mkOption {
|
||||||
type = with types; nullOr (either path str);
|
type = with types; nullOr (either path str);
|
||||||
|
|
@ -78,15 +76,23 @@ in
|
||||||
Lua code called after all plugins are loaded
|
Lua code called after all plugins are loaded
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
finalContent = mkOption {
|
||||||
|
type = with types; nullOr str;
|
||||||
|
default = self.mkCustomLuaRc config;
|
||||||
|
description = ''
|
||||||
|
The resulted init package.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
|
|
||||||
option = mkOption {
|
option = mkOption {
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
init.lua configuration
|
init.lua configuration
|
||||||
'';
|
'';
|
||||||
type = with types; nullOr (oneOf [path str self.module]);
|
type = with types; coercedTo (nullOr (oneOf [path str])) coerceToModule self.module;
|
||||||
example = ./init.lua;
|
example = ./init.lua;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue