Skip to content

Commit c382e51

Browse files
bleachedaAlessandro201
authored andcommitted
docs: clarify using opts = {} vs config = function() ... require('plu… (nvim-lua#1316)
* 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. * Update init.lua * remove whitespace
1 parent 1ce07a7 commit c382e51

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

init.lua

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,27 @@ require('lazy').setup({
258258
-- with the first argument being the link and the following
259259
-- keys can be used to configure plugin behavior/loading/etc.
260260
--
261-
-- Use `opts = {}` to force a plugin to be loaded.
261+
-- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.
262262
--
263263
-- This is equivalent to:
264264
-- require('Comment').setup({})
265265

266266
-- "gc" to comment visual regions/lines
267267
{ 'numToStr/Comment.nvim', opts = {} },
268268

269+
-- Alternatively, use `config = function() ... end` for full control over the configuration.
270+
-- If you prefer to call `setup` explicitly, use:
271+
-- {
272+
-- 'lewis6991/gitsigns.nvim',
273+
-- config = function()
274+
-- require('gitsigns').setup({
275+
-- -- Your gitsigns configuration here
276+
-- })
277+
-- end,
278+
-- }
279+
--
269280
-- Here is a more advanced example where we pass configuration
270-
-- options to `gitsigns.nvim`. This is equivalent to the following Lua:
271-
-- require('gitsigns').setup({ ... })
281+
-- options to `gitsigns.nvim`.
272282
--
273283
-- See `:help gitsigns` to understand what the configuration keys do
274284
{ -- Adds git related signs to the gutter, as well as utilities for managing changes

0 commit comments

Comments
 (0)