@@ -36,7 +36,9 @@ Table of Contents *lazy.nvim-table-of-contents*
36
36
- 📦 Migration Guide | lazy.nvim-🚀-usage-📦-migration-guide |
37
37
- ⚡ Profiling & Debug | lazy.nvim-🚀-usage-⚡-profiling-&-debug |
38
38
- 📂 Structuring Your Plugins| lazy.nvim-🚀-usage-📂-structuring-your-plugins |
39
- 8. 📚 Plugin Developers | lazy.nvim-📚-plugin-developers |
39
+ 8. 🔥 Developers | lazy.nvim-🔥-developers |
40
+ - Best Practices | lazy.nvim-🔥-developers-best-practices |
41
+ - Building | lazy.nvim-🔥-developers-building |
40
42
9. Links | lazy.nvim-links |
41
43
42
44
==============================================================================
@@ -46,19 +48,28 @@ Table of Contents *lazy.nvim-table-of-contents*
46
48
11.X *lazy.nvim-📰-what’s-new?-11.x*
47
49
48
50
- **New Website**: There’s a whole new website with a fresh look and improved
49
- documentation. Check it out at lazy.nvim <https://lazy.folke.io/ >. The GitHub
50
- `README.md` has been updated to point to the new website. The `vimdoc` contains
51
- all the information that is available on the website.
51
+ documentation. Check it out at <https://lazy.folke.io >. The GitHub `README.md`
52
+ has been updated to point to the new website. The `vimdoc` contains all the
53
+ information that is available on the website.
52
54
- **Spec Resolution & Merging**: the code that resolves a final spec from a
53
55
plugin’s fragments has been rewritten. This should be a tiny bit faster, but
54
56
more importantly, fixes some issues and is easier to maintain.
55
- - `rocks` : specs can now specify a list of rocks (luarocks
56
- <https://luarocks.org/ >) that should be installed.
57
57
- Packages <https://lazy.folke.io/packages > can now specify their dependencies
58
58
and configuration using one of:
59
59
- **Lazy**: `lazy.lua ` file
60
60
- **Rockspec**: luarocks <https://luarocks.org/ > `*- scm- 1 .rockspec` file <https://github.com/luarocks/luarocks/wiki/Rockspec-format >
61
61
- **Packspec**: `pkg.json` (experimental, since the format <https://github.com/neovim/packspec/issues/41 > is not quite there yet)
62
+ - Packages are not limited to just Neovim plugins. You can install any
63
+ **luarocks** package, like:
64
+ >lua
65
+ { "https://github.com/lubyk/yaml " }
66
+ <
67
+ Luarocks packages without a `/lua ` directory are never lazy-loaded, since
68
+ it’s just a library.
69
+ - `build` functions or `* .lua ` build files (like `build.lua ` ) now run
70
+ asynchronously. You can use `coroutine.yield (status_msg)` to show progress.
71
+ Yielding will also schedule the next `resume` to run in the next tick, so you
72
+ can do long-running tasks without blocking Neovim.
62
73
63
74
64
75
==============================================================================
@@ -235,9 +246,9 @@ SPEC LOADING *lazy.nvim-🔌-plugin-spec-spec-loading*
235
246
236
247
SPEC SETUP *lazy.nvim-🔌-plugin-spec-spec-setup*
237
248
238
- -----------------------------------------------------------------------------------------------------
249
+ ----------------------------------------------------------------------------------------------------
239
250
Property Type Description
240
- ---------- ----------------------------- ------------------------------------------------------------
251
+ ---------- ----------------------------- -----------------------------------------------------------
241
252
init fun(LazyPlugin) init functions are always executed during startup
242
253
243
254
opts table or opts should be a table (will be merged with parent specs),
@@ -258,15 +269,8 @@ SPEC SETUP *lazy.nvim-🔌-plugin-spec-spec-setup*
258
269
config()
259
270
260
271
build fun(LazyPlugin) or string or build is executed when a plugin is installed or updated.
261
- a list of build commands Before running build, a plugin is first loaded. If it’s a
262
- string it will be run as a shell command. When prefixed with
263
- : it is a Neovim command. You can also specify a list to
264
- executed multiple build commands. Some plugins provide their
265
- own build.lua which is automatically used by lazy. So no
266
- need to specify a build step for those plugins.
267
-
268
- rocks string[]? Add any luarocks dependencies.
269
- -----------------------------------------------------------------------------------------------------
272
+ a list of build commands See Building for more information.
273
+ ----------------------------------------------------------------------------------------------------
270
274
271
275
SPEC LAZY LOADING *lazy.nvim-🔌-plugin-spec-spec-lazy-loading*
272
276
@@ -535,8 +539,8 @@ dependencies and configuration. Syntax is the same as any plugin spec.
535
539
536
540
ROCKSPEC *lazy.nvim-📦-packages-rockspec*
537
541
538
- When a plugin contains a `*- scm - 1 .rockspec` file, **lazy.nvim** will
539
- automatically load its `rocks` </spec#setup> dependencies.
542
+ When a plugin contains a `* -1 .rockspec` file, **lazy.nvim** will automatically
543
+ build the rock and its dependencies.
540
544
541
545
542
546
PACKSPEC *lazy.nvim-📦-packages-packspec*
@@ -1175,17 +1179,49 @@ spec.
1175
1179
1176
1180
1177
1181
==============================================================================
1178
- 8. 📚 Plugin Developers *lazy.nvim-📚-plugin -developers*
1182
+ 8. 🔥 Developers *lazy.nvim-🔥 -developers*
1179
1183
1180
1184
To make it easier for users to install your plugin, you can include a package
1181
1185
spec </packages> in your repo.
1182
1186
1183
- If your plugin needs a build step, you can specify this in your **package
1184
- file**, or create a file `build.lua ` or `build/init.lua ` in the root of your
1185
- repo. This file will be loaded when the plugin is installed or updated.
1186
1187
1187
- This makes it easier for users, as they no longer need to specify a `build`
1188
- command.
1188
+ BEST PRACTICES *lazy.nvim-🔥-developers-best-practices*
1189
+
1190
+ - If your plugin needs `setup ()` , then create a simple `lazy.lua ` file like this:
1191
+ >lua
1192
+ return { "me/my-plugin", opts = {} }
1193
+ <
1194
+ - Plugins that are pure lua libraries should be lazy-loaded with `lazy = true`.
1195
+ >lua
1196
+ { "nvim-lua/plenary.nvim", lazy = true }
1197
+ <
1198
+ - Only use `dependencies` if a plugin needs the dep to be installed **AND**
1199
+ loaded. Lua plugins/libraries are automatically loaded when they are
1200
+ `require ()` d, so they don’t need to be in `dependencies` .
1201
+ - Inside a `build` function or `* .lua ` build file, use
1202
+ `coroutine.yield (status_msg)` to show progress.
1203
+ - Don’t change the `cwd` in your build function, since builds run in parallel
1204
+ and changing the `cwd` will affect other builds.
1205
+
1206
+
1207
+ BUILDING *lazy.nvim-🔥-developers-building*
1208
+
1209
+ The spec **build** property can be one of the following:
1210
+
1211
+ - `fun(plugin: LazyPlugin)`: a function that builds the plugin.
1212
+ - `* .lua ` : a Lua file that builds the plugin (like `build.lua ` )
1213
+ - `" :Command" ` : a Neovim command
1214
+ - `" rockspec" ` : this will run `luarocks make` in the plugin’s directory
1215
+ This is automatically set by the `rockspec` package </packages> source.
1216
+ - any other **string** will be run as a shell command
1217
+ - a `list ` of any of the above to run multiple build steps
1218
+ - if no `build` is specified, but a `build.lua ` file exists, that will be used instead.
1219
+
1220
+ Build functions and `* .lua ` files run asynchronously in a coroutine. Use
1221
+ `coroutine.yield (status_msg)` to show progress. Yielding will also schedule the
1222
+ next `coroutine.resume ()` to run in the next tick, so you can do long-running
1223
+ tasks without blocking Neovim.
1224
+
1189
1225
1190
1226
==============================================================================
1191
1227
9. Links *lazy.nvim-links*
0 commit comments