Skip to content

Commit

Permalink
docs/user-guide: add lazy-loading.md
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Dec 10, 2024
1 parent b752606 commit f6e30be
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/mdbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [Helpers](./user-guide/helpers.md)
- [FAQ](./user-guide/faq.md)
- [Configuration examples](./user-guide/config-examples.md)
- [Lazy Loading](./user-guide/lazy-loading.md)

# Platforms

Expand Down
57 changes: 57 additions & 0 deletions docs/user-guide/lazy-loading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Lazy Loading

> [!WARNING]
> This is an experimental option and may not work as expected with all plugins.
> The API may change without notice. > Please report any issues you encounter.
When the lazy loading functionality is enabled, the plugin's configuration is
routed to the enabled lazy provider. Options mentioned will be in relation to
the `${namespace}.${name}.lazyLoad` context.

## Supported Lazy Loading Providers

It is recommended to become familiar with lazy loading strategies supported by
your provider in their upstream documentation and the corresponding plugin's
support.

- [Lz.n](https://github.com/nvim-neorocks/lz.n?tab=readme-ov-file#plugin-spec)

## Enabling Lazy Loading Per Plugin

You can enable or disable lazy loading for a particular plugin through `enable`.

When a configuration is detected, we will automatically enable the lazy loading
for the plugin with a configuration. If you are just wanting to store potential
configuration without enabling it, you can explicitly disable it using the
`enable` option.

When a plugin has lazy loading enabled, the Lua configuration for your plugin
will be passed along to the corresponding lazy provider instead. This behavior
can be overridden by using the `settings` option that will be passed to the
provider.

## Configuring Triggers

Currently, you need to define the trigger conditions in which a plugin will be
loaded. This is done through the `settings` option.

```nix
plugins.neotest = {
enable = true;
lazyLoad = {
settings = {
cmd = [
"Neotest"
"Neotest summary"
];
keys = [
{
__unkeyed-1 = "<leader>nt";
__unkeyed-3 = "<CMD>Neotest summary<CR>";
desc = "Summary toggle";
}
];
};
};
};
```

0 comments on commit f6e30be

Please sign in to comment.