1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-09 03:56:05 +01:00

lib/plugins: infer packPathName

Signed-off-by: saygo-png <saygo.mail@proton.me>
This commit is contained in:
saygo-png 2025-09-27 17:58:36 +02:00 committed by Matt Sturgeon
parent c4b27080a6
commit 4cec67651a
3 changed files with 12 additions and 13 deletions

View file

@ -20,7 +20,6 @@
# For example, they might just be configured through some other mean, like global variables # For example, they might just be configured through some other mean, like global variables
hasLuaConfig ? true, hasLuaConfig ? true,
# options # options
packPathName ? name,
# Can be a string, a list of strings, or a module option: # Can be a string, a list of strings, or a module option:
# - A string will be intrpreted as `pkgs.vimPlugins.${package}` # - A string will be intrpreted as `pkgs.vimPlugins.${package}`
# - A list will be interpreted as a "pkgs path", e.g. `pkgs.${elem1}.${elem2}.${etc...}` # - A list will be interpreted as a "pkgs path", e.g. `pkgs.${elem1}.${elem2}.${etc...}`
@ -66,9 +65,9 @@ let
{ {
options = lib.setAttrByPath loc ( options = lib.setAttrByPath loc (
{ {
enable = lib.mkEnableOption packPathName; enable = lib.mkEnableOption name;
autoLoad = lib.nixvim.mkAutoLoadOption cfg packPathName; autoLoad = lib.nixvim.mkAutoLoadOption cfg name;
lazyLoad = lib.nixvim.mkLazyLoadOption packPathName; lazyLoad = lib.nixvim.mkLazyLoadOption name;
} }
// lib.optionalAttrs hasSettings { // lib.optionalAttrs hasSettings {
settings = lib.nixvim.mkSettingsOption { settings = lib.nixvim.mkSettingsOption {
@ -114,7 +113,7 @@ let
assertions = [ assertions = [
{ {
assertion = (isColorscheme && colorscheme != null) || cfg.lazyLoad.settings != { }; assertion = (isColorscheme && colorscheme != null) || cfg.lazyLoad.settings != { };
message = "You have enabled lazy loading for ${packPathName} but have not provided any configuration."; message = "You have enabled lazy loading for ${name} but have not provided any configuration.";
} }
]; ];
@ -122,7 +121,8 @@ let
plugins = [ plugins = [
( (
{ {
__unkeyed-1 = packPathName; # The packpath name is always the derivation name
__unkeyed-1 = lib.getName cfg.package;
# Use provided after, otherwise fallback to normal function wrapped lua content # Use provided after, otherwise fallback to normal function wrapped lua content
after = after =
let let
@ -162,7 +162,7 @@ in
imports imports
++ [ ++ [
module module
(utils.mkPluginPackageModule { inherit loc packPathName package; }) (utils.mkPluginPackageModule { inherit loc name package; })
(utils.mkMetaModule { (utils.mkMetaModule {
inherit inherit
loc loc

View file

@ -15,7 +15,6 @@
isColorscheme ? false, isColorscheme ? false,
colorscheme ? name, colorscheme ? name,
# options # options
packPathName ? name,
# Can be a string, a list of strings, or a module option: # Can be a string, a list of strings, or a module option:
# - A string will be intrpreted as `pkgs.vimPlugins.${package}` # - A string will be intrpreted as `pkgs.vimPlugins.${package}`
# - A list will be interpreted as a "pkgs path", e.g. `pkgs.${elem1}.${elem2}.${etc...}` # - A list will be interpreted as a "pkgs path", e.g. `pkgs.${elem1}.${elem2}.${etc...}`
@ -59,8 +58,8 @@ let
{ {
options = lib.setAttrByPath loc ( options = lib.setAttrByPath loc (
{ {
enable = lib.mkEnableOption packPathName; enable = lib.mkEnableOption name;
autoLoad = lib.nixvim.mkAutoLoadOption cfg packPathName; autoLoad = lib.nixvim.mkAutoLoadOption cfg name;
} }
// settingsOption // settingsOption
// extraOptions // extraOptions
@ -93,7 +92,7 @@ in
imports imports
++ [ ++ [
module module
(lib.nixvim.plugins.utils.mkPluginPackageModule { inherit loc packPathName package; }) (lib.nixvim.plugins.utils.mkPluginPackageModule { inherit loc name package; })
(lib.nixvim.plugins.utils.mkMetaModule { (lib.nixvim.plugins.utils.mkMetaModule {
inherit inherit
loc loc

View file

@ -35,7 +35,7 @@
mkPluginPackageModule = mkPluginPackageModule =
{ {
loc, loc,
packPathName, name,
package, package,
}: }:
# Return a module # Return a module
@ -49,7 +49,7 @@
if lib.isOption package then if lib.isOption package then
package package
else else
lib.mkPackageOption pkgs packPathName { lib.mkPackageOption pkgs name {
default = default =
if builtins.isList package then if builtins.isList package then
package package