docs: added section on lazy loading

This commit is contained in:
Folke Lemaitre 2022-12-18 14:23:02 +01:00
parent c0d3617e0b
commit 78b284c065
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 19 additions and 0 deletions

View File

@ -97,6 +97,25 @@ require("lazy").setup({
| **ft** | `string?` or `string[]` | Lazy-load on filetype | | **ft** | `string?` or `string[]` | Lazy-load on filetype |
| **keys** | `string?` or `string[]` | Lazy-load on key mapping | | **keys** | `string?` or `string[]` | Lazy-load on key mapping |
### Lazy Loading
**lazy.nvim** automagically lazy-loads Lua modules, so it is not needed to
specify `module=...` everywhere in your plugin specification. This mean that if
you have a plugin `A` that is lazy-loaded and a plugin `B` that requires a
module of plugin `A`, then plugin `A` will be loaded on demand as expected.
You can configure **lazy.nvim** to lazy-load all plugins by default with `config.defaults.lazy = true`.
Additionally, you can also lazy-load on **events**, **commands**,
**file types** and **key mappings**.
Plugins will be lazy-loaded when one of the following is `true`:
- the plugin only exists as a dependency in your spec
- it has an `event`, `cmd`, `ft` or `cmd` key
- it defines an `init` method
- `config.defaults.lazy == true`
<!-- spec:start --> <!-- spec:start -->
```lua ```lua