lazy.nvim/docs/packages.md

43 lines
1.5 KiB
Markdown
Raw Normal View History

2024-06-19 13:59:45 +08:00
---
sidebar_position: 4
---
# 📦 Packages
2024-06-23 16:09:41 +08:00
**lazy.nvim** supports three ways for plugins to define their dependencies and configuration.
2024-06-23 22:03:38 +08:00
- **Lazy**: `lazy.lua` file
2024-06-23 16:09:41 +08:00
- **Rockspec**: [luarocks](https://luarocks.org/) `*-scm-1.rockspec` [file](https://github.com/luarocks/luarocks/wiki/Rockspec-format)
- **Packspec**: `pkg.json` (experimental, since the [format](https://github.com/neovim/packspec/issues/41) is not quite there yet)
2024-06-23 16:29:21 +08:00
You can enable/disable package sources with [`config.pkg.sources`](/configuration).
The order of sources is important, as the first source that finds a package will be used.
2024-06-23 16:09:41 +08:00
:::info
Package specs are always loaded in the scope of the plugin (using [specs](/spec#advanced)),
so that when the plugin is disabled, none of the specs are loaded.
:::
## Lazy
2024-06-23 22:03:38 +08:00
Using a `lazy.lua` file is the recommended way to define your plugin dependencies and configuration.
2024-06-23 16:09:41 +08:00
Syntax is the same as any plugin spec.
## Rockspec
2024-06-24 21:11:51 +08:00
When a plugin contains a `*-1.rockspec` file, **lazy.nvim** will automatically build the rock and its dependencies.
2024-06-23 16:09:41 +08:00
2024-06-24 23:13:59 +08:00
A **rockspec** will only be used if one of the following is true:
- the package does not have a `/lua` directory
- the package has a complex build step
- the package has dependencies (excluding `lua`)
2024-06-23 16:09:41 +08:00
## Packspec
Supports the [pkg.json](https://github.com/nvim-lua/nvim-package-specification/issues/41) format,
with a lazy extension in `lazy`.
`lazy` can contain any valid lazy spec fields. They will be added to the plugin's spec.