docs: prefer opts over config

This commit is contained in:
Folke Lemaitre 2024-07-05 09:30:56 +02:00
parent 5a681c3e31
commit 78db53118c
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 55 additions and 9 deletions

View file

@ -1,6 +1,7 @@
---
sidebar_position: 7
---
# 🔥 Developers
To make it easier for users to install your plugin, you can include a [package spec](/packages) in your repo.
@ -19,6 +20,29 @@ To make it easier for users to install your plugin, you can include a [package s
{ "nvim-lua/plenary.nvim", lazy = true }
```
- Always use `opts` instead of `config` when possible. `config` is almost never needed.
:::tip[GOOD]
```lua
{ "folke/todo-comments.nvim", opts = {} },
```
:::
:::danger[BAD]
```lua
{
"folke/todo-comments.nvim",
config = function()
require("todo-comments").setup({})
end,
},
```
:::
- Only use `dependencies` if a plugin needs the dep to be installed **AND** loaded.
Lua plugins/libraries are automatically loaded when they are `require()`d,
so they don't need to be in `dependencies`.
@ -163,4 +187,3 @@ Then run it with:
```sh
nvim -u repro.lua
```