mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-24 09:48:42 +02:00
lib/{neovim,vim}-plugin: use loc
throughout
This commit is contained in:
parent
eaa2084627
commit
6019ce784c
2 changed files with 27 additions and 31 deletions
|
@ -53,6 +53,10 @@
|
||||||
}@args:
|
}@args:
|
||||||
let
|
let
|
||||||
namespace = if isColorscheme then "colorschemes" else "plugins";
|
namespace = if isColorscheme then "colorschemes" else "plugins";
|
||||||
|
loc = [
|
||||||
|
namespace
|
||||||
|
name
|
||||||
|
];
|
||||||
|
|
||||||
module =
|
module =
|
||||||
{
|
{
|
||||||
|
@ -62,8 +66,8 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.${namespace}.${name};
|
cfg = lib.getAttrFromPath loc config;
|
||||||
opts = options.${namespace}.${name};
|
opts = lib.getAttrFromPath loc options;
|
||||||
|
|
||||||
setupCode = ''
|
setupCode = ''
|
||||||
require('${moduleName}')${setup}(${
|
require('${moduleName}')${setup}(${
|
||||||
|
@ -79,14 +83,11 @@
|
||||||
nixvimInfo = {
|
nixvimInfo = {
|
||||||
inherit description;
|
inherit description;
|
||||||
url = args.url or opts.package.default.meta.homepage;
|
url = args.url or opts.package.default.meta.homepage;
|
||||||
path = [
|
path = loc;
|
||||||
namespace
|
|
||||||
name
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
options.${namespace}.${name} =
|
options = lib.setAttrByPath loc (
|
||||||
{
|
{
|
||||||
enable = lib.mkEnableOption packPathName;
|
enable = lib.mkEnableOption packPathName;
|
||||||
lazyLoad = lib.nixvim.mkLazyLoadOption packPathName;
|
lazyLoad = lib.nixvim.mkLazyLoadOption packPathName;
|
||||||
|
@ -129,7 +130,8 @@
|
||||||
description = "The plugin's lua configuration";
|
description = "The plugin's lua configuration";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// extraOptions;
|
// extraOptions
|
||||||
|
);
|
||||||
|
|
||||||
config =
|
config =
|
||||||
assert lib.assertMsg (
|
assert lib.assertMsg (
|
||||||
|
@ -160,7 +162,7 @@
|
||||||
++ (lib.optionals hasLuaConfig [
|
++ (lib.optionals hasLuaConfig [
|
||||||
|
|
||||||
# Add the plugin setup code `require('foo').setup(...)` to the lua configuration
|
# Add the plugin setup code `require('foo').setup(...)` to the lua configuration
|
||||||
(lib.optionalAttrs callSetup { ${namespace}.${name}.luaConfig.content = setupCode; })
|
(lib.optionalAttrs callSetup (lib.setAttrByPath loc { luaConfig.content = setupCode; }))
|
||||||
|
|
||||||
# When NOT lazy loading, write `luaConfig.content` to `configLocation`
|
# When NOT lazy loading, write `luaConfig.content` to `configLocation`
|
||||||
(lib.mkIf (!cfg.lazyLoad.enable) luaConfigAtLocation)
|
(lib.mkIf (!cfg.lazyLoad.enable) luaConfigAtLocation)
|
||||||
|
@ -203,17 +205,13 @@
|
||||||
{
|
{
|
||||||
imports =
|
imports =
|
||||||
let
|
let
|
||||||
basePluginPath = [
|
settingsPath = loc ++ [ "settings" ];
|
||||||
namespace
|
|
||||||
name
|
|
||||||
];
|
|
||||||
settingsPath = basePluginPath ++ [ "settings" ];
|
|
||||||
in
|
in
|
||||||
imports
|
imports
|
||||||
++ [ module ]
|
++ [ module ]
|
||||||
++ (lib.optional deprecateExtraOptions (
|
++ (lib.optional deprecateExtraOptions (
|
||||||
lib.mkRenamedOptionModule (basePluginPath ++ [ "extraOptions" ]) settingsPath
|
lib.mkRenamedOptionModule (loc ++ [ "extraOptions" ]) settingsPath
|
||||||
))
|
))
|
||||||
++ (lib.nixvim.mkSettingsRenamedOptionModules basePluginPath settingsPath optionsRenamedToSettings);
|
++ (lib.nixvim.mkSettingsRenamedOptionModules loc settingsPath optionsRenamedToSettings);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,10 @@ rec {
|
||||||
}@args:
|
}@args:
|
||||||
let
|
let
|
||||||
namespace = if isColorscheme then "colorschemes" else "plugins";
|
namespace = if isColorscheme then "colorschemes" else "plugins";
|
||||||
|
loc = [
|
||||||
|
namespace
|
||||||
|
name
|
||||||
|
];
|
||||||
|
|
||||||
createSettingsOption = (lib.isString globalPrefix) && (globalPrefix != "");
|
createSettingsOption = (lib.isString globalPrefix) && (globalPrefix != "");
|
||||||
|
|
||||||
|
@ -75,8 +79,8 @@ rec {
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.${namespace}.${name};
|
cfg = lib.getAttrFromPath loc config;
|
||||||
opts = options.${namespace}.${name};
|
opts = lib.getAttrFromPath loc options;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
meta = {
|
meta = {
|
||||||
|
@ -84,14 +88,11 @@ rec {
|
||||||
nixvimInfo = {
|
nixvimInfo = {
|
||||||
inherit description;
|
inherit description;
|
||||||
url = args.url or opts.package.default.meta.homepage;
|
url = args.url or opts.package.default.meta.homepage;
|
||||||
path = [
|
path = loc;
|
||||||
namespace
|
|
||||||
name
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
options.${namespace}.${name} =
|
options = lib.setAttrByPath loc (
|
||||||
{
|
{
|
||||||
enable = lib.mkEnableOption packPathName;
|
enable = lib.mkEnableOption packPathName;
|
||||||
package =
|
package =
|
||||||
|
@ -120,7 +121,8 @@ rec {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// settingsOption
|
// settingsOption
|
||||||
// extraOptions;
|
// extraOptions
|
||||||
|
);
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable (
|
config = lib.mkIf cfg.enable (
|
||||||
lib.mkMerge [
|
lib.mkMerge [
|
||||||
|
@ -146,17 +148,13 @@ rec {
|
||||||
{
|
{
|
||||||
imports =
|
imports =
|
||||||
let
|
let
|
||||||
basePluginPath = [
|
settingsPath = loc ++ [ "settings" ];
|
||||||
namespace
|
|
||||||
name
|
|
||||||
];
|
|
||||||
settingsPath = basePluginPath ++ [ "settings" ];
|
|
||||||
in
|
in
|
||||||
imports
|
imports
|
||||||
++ [ module ]
|
++ [ module ]
|
||||||
++ (lib.optional (deprecateExtraConfig && createSettingsOption) (
|
++ (lib.optional (deprecateExtraConfig && createSettingsOption) (
|
||||||
lib.mkRenamedOptionModule (basePluginPath ++ [ "extraConfig" ]) settingsPath
|
lib.mkRenamedOptionModule (loc ++ [ "extraConfig" ]) settingsPath
|
||||||
))
|
))
|
||||||
++ (lib.nixvim.mkSettingsRenamedOptionModules basePluginPath settingsPath optionsRenamedToSettings);
|
++ (lib.nixvim.mkSettingsRenamedOptionModules loc settingsPath optionsRenamedToSettings);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue