fix: init function is called before plugin is loaded
parent
3732144c33
commit
2eaecf17a0
25
README.md
25
README.md
|
|
@ -157,29 +157,26 @@ The dependencies is a list of element of either:
|
||||||
|
|
||||||
The Plugin configuration object accepts the following properties:
|
The Plugin configuration object accepts the following properties:
|
||||||
|
|
||||||
| name | default | description |
|
| name | default | description |
|
||||||
|----------------|---------|-----------------------------------------------------------------|
|
|----------------|---------|----------------------------------------------------------------|
|
||||||
| `plugin` | N/A | The plugin to load² **REQUIRED** |
|
| `plugin` | N/A | The plugin to load² **REQUIRED** |
|
||||||
| `init` | `null` | Lua code (as string of path) to call before loading the plugin³ |
|
| `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 |
|
| `config` | `null` | Lua code (as string of path) to call after loading the plugin |
|
||||||
| `dependencies` | `[]` | The plugin dependencies⁴ |
|
| `dependencies` | `[]` | The plugin dependencies³ |
|
||||||
| `lazy` | `false` | Should the plugin be loaded lazily |
|
| `lazy` | `false` | Should the plugin be loaded lazily |
|
||||||
| `cmd` | `[]` | Command to put as place_holder to lazy load the plugin⁵ |
|
| `cmd` | `[]` | Command to put as place_holder to lazy load the plugin⁴ |
|
||||||
| `ft` | `[]` | Filetype to watch to lazy load the plugin⁵ |
|
| `ft` | `[]` | Filetype to watch to lazy load the plugin⁴ |
|
||||||
|
|
||||||
> ² The plugin can be either a nix package or an object with only `name` and
|
> ² 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
|
> `src` as properties. The latter will be used to create a nix package of your
|
||||||
> plugin on the fly.
|
> plugin on the fly.
|
||||||
|
|
||||||
> ³ When the plugin is not lazy, the `init` function is called after the plugin
|
> ³ `nix` handles the installation of your plugin, therefore, this list is
|
||||||
> is loaded as all non lazy plugin are loaded automatically.
|
|
||||||
|
|
||||||
> ⁴ `nix` handles the installation of your plugin, therefore, this list is
|
|
||||||
> **NOT** to declare dependencies that the nix package of the plugin doesn't
|
> **NOT** to declare dependencies that the nix package of the plugin doesn't
|
||||||
> know. This will tell `sloth-flake` in what order your plugins should be
|
> know. This will tell `sloth-flake` in what order your plugins should be
|
||||||
> loaded.
|
> loaded.
|
||||||
|
|
||||||
> ⁵ Setting this property implicitly set `lazy` to `true`.
|
> ⁴ Setting this property implicitly set `lazy` to `true`.
|
||||||
|
|
||||||
### neovim (lua)
|
### neovim (lua)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@
|
||||||
hasCommands = p.cmd != [];
|
hasCommands = p.cmd != [];
|
||||||
hasFileTypes = p.ft != [];
|
hasFileTypes = p.ft != [];
|
||||||
lazy = p.lazy || hasCommands || hasFileTypes;
|
lazy = p.lazy || hasCommands || hasFileTypes;
|
||||||
|
optional = lazy || p.init != null;
|
||||||
};
|
};
|
||||||
|
|
||||||
normalizeOrImportPlugin = dep:
|
normalizeOrImportPlugin = dep:
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,7 @@
|
||||||
normalizedPlugins
|
normalizedPlugins
|
||||||
++ (deps.normalizePlugins [runtimePlugin sloth-flake]);
|
++ (deps.normalizePlugins [runtimePlugin sloth-flake]);
|
||||||
|
|
||||||
extractPlugin = p: {
|
extractPlugin = p: {inherit (p) optional plugin;};
|
||||||
inherit (p) plugin;
|
|
||||||
optional = p.lazy;
|
|
||||||
};
|
|
||||||
extractPlugins = map extractPlugin;
|
extractPlugins = map extractPlugin;
|
||||||
|
|
||||||
customRC = let
|
customRC = let
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue