Skip to content

Commit 8f196b3

Browse files
authored
docs: clarify using opts = {} vs config = function() ... require('plugin').setup({}) .. end
The current documentation mentioning that using "require" is equivalent to using "opts" without detailing the use in the "config = function()" block seems inaccurate. Lower in the configuration the "config = function()" block is used without clarifying why it needed and what it does. This clarification may help new users understand the difference between the two, or how and where to place the "require" statement.
1 parent 5bdde24 commit 8f196b3

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

init.lua

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,22 @@ require('lazy').setup({
234234
-- with the first argument being the link and the following
235235
-- keys can be used to configure plugin behavior/loading/etc.
236236
--
237-
-- Use `opts = {}` to force a plugin to be loaded.
237+
-- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.
238238
--
239-
240-
-- Here is a more advanced example where we pass configuration
241-
-- options to `gitsigns.nvim`. This is equivalent to the following Lua:
242-
-- require('gitsigns').setup({ ... })
239+
-- Alternatively, use `config = function() ... end` for full control over the configuration.
240+
-- If you prefer to call `setup` explicitly, use:
241+
-- {
242+
-- 'lewis6991/gitsigns.nvim',
243+
-- config = function()
244+
-- require('gitsigns').setup({
245+
-- -- Your gitsigns configuration here
246+
-- })
247+
-- end,
248+
-- }
243249
--
250+
-- Here is a more advanced example where we pass configuration
251+
-- options to `gitsigns.nvim`.
252+
--
244253
-- See `:help gitsigns` to understand what the configuration keys do
245254
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
246255
'lewis6991/gitsigns.nvim',

0 commit comments

Comments
 (0)