feat: can declare extra lua packages

main
LeMarsu 2024-06-18 00:19:38 +02:00
parent b5a3526f8a
commit a4cc5d9b9c
3 changed files with 32 additions and 13 deletions

View File

@ -189,6 +189,7 @@ Here's a list of all accepted arguments
| `runtime` | `{}` | Your Runtime configuration (see below) |
| `dependencies` | `[]` | A list of your dependencies (see below) |
| `dependenciesExtraArgs` | `{}` | Extra arguments to load your dependencies in other files |
| `extraLuaPackages` | `null` | Extra lua packages needed for the plugin |
| `viAlias` | `false` | Wether to create a `vi` alias to run neovim |
| `vimAlias` | `false` | Wether to create a `vim` alias to run neovim |
| `vimdiffAlias` | `false` | Wether to create a `vimdiff` alias to run neovim in diff mode |
@ -218,17 +219,18 @@ The dependencies is a list of element of either:
The Plugin configuration object accepts the following properties:
| name | default | description |
|----------------|---------|----------------------------------------------------------------|
| `plugin` | N/A | The plugin to load² **REQUIRED** |
| `init` | `null` | Lua code (as string of path) to call before loading the plugin |
| `config` | `null` | Lua code (as string of path) to call after loading the plugin |
| `dependencies` | `[]` | The plugin dependencies³ |
| `lazy` | `false` | Should the plugin be loaded lazily |
| `cmd` | `[]` | Command to put as place_holder to load the lazy plugin⁴ |
| `ft` | `[]` | Filetype to watch to load the lazy plugin⁴ |
| `events` | `[]` | Events to watch to load the lazy plugin⁴⁵ |
| `keymaps` | `[]` | Keymaps that when press will load the lazy plugin⁴⁶ |
| name | default | description |
|--------------------|---------|----------------------------------------------------------------|
| `plugin` | N/A | The plugin to load² **REQUIRED** |
| `init` | `null` | Lua code (as string of path) to call before loading the plugin |
| `config` | `null` | Lua code (as string of path) to call after loading the plugin |
| `dependencies` | `[]` | The plugin dependencies³ |
| `extraLuaPackages` | `null` | Extra lua packages needed for the plugin |
| `lazy` | `false` | Should the plugin be loaded lazily |
| `cmd` | `[]` | Command to put as place_holder to load the lazy plugin⁴ |
| `ft` | `[]` | Filetype to watch to load the lazy plugin⁴ |
| `events` | `[]` | Events to watch to load the lazy plugin⁴⁵ |
| `keymaps` | `[]` | Keymaps that when press will load the lazy plugin⁴⁶ |
> ² The plugin can be either a nix package or an object with only `name` and
> `src` as properties. The latter will be used to create a nix package of your

View File

@ -6,6 +6,7 @@
package ? pkgs.neovim-unwrapped,
dependencies ? [],
dependenciesExtraArgs ? {},
extraLuaPackages ? (_: []),
runtime ? null,
init ? null,
viAlias ? false,
@ -14,10 +15,10 @@
nvimdiffAlias ? false,
...
} @ config: let
inherit (builtins) map isString isPath;
inherit (builtins) isString isPath map;
inherit (pkgs) callPackage bash lib;
inherit (lib.strings) optionalString;
inherit (lib.lists) optional;
inherit (lib.lists) concatMap optional;
inherit (lib.trivial) flip;
inherit (lib.attrsets) optionalAttrs;
@ -36,6 +37,14 @@
extractPlugin = p: {inherit (p) optional plugin;};
extractPlugins = map extractPlugin;
extractLuaPackageFn = plugin:
optional (plugin ? extraLuaPackages) plugin.extraLuaPackages;
extractLuaPackagesFn = plugins: let
fnList = concatMap extractLuaPackageFn plugins;
concatPackages = ps: fn: fn ps;
in
ps: concatMap (concatPackages ps) fnList;
buildInit = {
init ? null,
postInit ? null,
@ -81,6 +90,8 @@
pkgs.neovimUtils.makeNeovimConfig {
inherit customRC;
plugins = extractPlugins plugins;
extraLuaPackages = ps:
(extractLuaPackagesFn plugins ps) ++ (extraLuaPackages ps);
}
// {luaRcContent = customRC;};
params =

View File

@ -72,6 +72,9 @@ in rec {
# Ensure thoses plugins are loaded before the current one
dependencies = option (list drv);
# Ensure those packages are available
extraLuaPackages = option function;
# Should this plugin be load lazily ?
lazy = option bool;
@ -114,6 +117,9 @@ in rec {
# Extra argument to pass to dependencies files
dependenciesExtraArgs = option (attrs any);
# Ensure those packages are available
extraLuaPackages = option function;
# Runtime configuration
runtime = option runtimeType;