Skip to content

Commit ae58d2e

Browse files
committed
docs(#2934): move setup doc from config to quickstart and setup
1 parent 411e3af commit ae58d2e

2 files changed

Lines changed: 30 additions & 44 deletions

File tree

doc/nvim-tree-lua.txt

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ Disabling |netrw| is strongly advised, see |nvim-tree-netrw|
6565
==============================================================================
6666
Quickstart: Setup *nvim-tree-quickstart-setup*
6767

68-
Setup the plugin in your `init.lua`, passing |nvim_tree.config|
69-
e.g. >lua
68+
Setup the plugin in your `init.lua`.
69+
70+
See |nvim-tree-setup| and |nvim-tree-default-config >lua
7071

7172
-- disable netrw at the very start of your init.lua
7273
vim.g.loaded_netrw = 1
@@ -78,8 +79,10 @@ e.g. >lua
7879
-- empty setup using defaults
7980
require("nvim-tree").setup()
8081

81-
-- OR setup with some options
82-
require("nvim-tree").setup({
82+
-- OR setup with a config
83+
84+
---@type nvim_tree.config
85+
local config = {
8386
sort = {
8487
sorter = "case_sensitive",
8588
},
@@ -92,7 +95,8 @@ e.g. >lua
9295
filters = {
9396
dotfiles = true,
9497
},
95-
})
98+
}
99+
require("nvim-tree").setup(config)
96100
<
97101
==============================================================================
98102
Quickstart: Help *nvim-tree-quickstart-help*
@@ -183,11 +187,11 @@ via |nvim_tree.config| {on_attach} e.g. >lua
183187
end
184188

185189
-- pass to setup along with your other options
186-
require("nvim-tree").setup {
190+
require("nvim-tree").setup({
187191
---
188192
on_attach = my_on_attach,
189193
---
190-
}
194+
})
191195
<
192196
==============================================================================
193197
Quickstart: Highlight Groups *nvim-tree-quickstart-highlight*
@@ -311,20 +315,31 @@ Commands *nvim-tree-commands*
311315
==============================================================================
312316
Setup *nvim-tree-setup*
313317

314-
You must run setup() function once to initialise nvim-tree. It may be called
315-
again to apply a change in configuration without restarting Nvim.
318+
You must run the `setup()` function once to initialise nvim-tree. It may be
319+
called again to apply a change in configuration without restarting Nvim.
316320

317-
setup() function takes one optional argument: configuration table. If omitted
318-
nvim-tree will be initialised with default configuration.
321+
The `setup()` function takes one optional argument: |nvim_tree.config|. If
322+
omitted nvim-tree will be initialised with default configuration:
323+
|nvim-tree-default-config|.
319324

320-
See |nvim-tree-default-config| for the default configuration table.
325+
Config can be validated with |lsp| when passed directly e.g. >lua
321326

322-
TODO #2934 move setup call patterns from config to here
327+
require("nvim-tree").setup({
328+
hijack_cursor = true,
329+
})
330+
<
331+
or as a typed variable e.g. >lua
323332

324-
The first setup() call is cheap: it does nothing more than validate / apply
333+
---@type nvim_tree.config
334+
local config = {
335+
hijack_cursor = true,
336+
}
337+
require("nvim-tree").setup(config)
338+
<
339+
The first `setup()` call is cheap: it does nothing more than validate / apply
325340
the configuration. Nothing happens until the tree is first opened.
326341

327-
Subsequent setup() calls are expensive as they tear down the world before
342+
Subsequent `setup()` calls are expensive as they tear down the world before
328343
applying configuration.
329344

330345

@@ -1842,20 +1857,6 @@ Class: config *nvim-tree-config*
18421857

18431858
When a value is not present/nil, the default will be used.
18441859

1845-
They can be validated by |lsp| when passed directly e.g. >lua
1846-
require("nvim-tree").setup({
1847-
hijack_cursor = true,
1848-
})
1849-
<
1850-
1851-
or as a typed variable e.g. >lua
1852-
---@type nvim_tree.config
1853-
local config = {
1854-
hijack_cursor = true,
1855-
}
1856-
require("nvim-tree").setup(config)
1857-
<
1858-
18591860
{on_attach} Runs when creating the nvim-tree buffer. Use this to set your
18601861
|nvim-tree-mappings|. When not a function, |nvim-tree-mappings-default|
18611862
will be used.

lua/nvim-tree/_meta/config.lua

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,6 @@ error("Cannot require a meta file")
1111
---
1212
---When a value is not present/nil, the default will be used.
1313
---
14-
---They can be validated by |lsp| when passed directly e.g.
15-
---```lua
16-
--- require("nvim-tree").setup({
17-
--- hijack_cursor = true,
18-
--- })
19-
---```
20-
---
21-
---or as a typed variable e.g.
22-
---```lua
23-
--- ---@type nvim_tree.config
24-
--- local config = {
25-
--- hijack_cursor = true,
26-
--- }
27-
--- require("nvim-tree").setup(config)
28-
---```
2914
---{on_attach} Runs when creating the nvim-tree buffer. Use this to set your [nvim-tree-mappings]. When not a function, [nvim-tree-mappings-default] will be used.
3015
---
3116
---{hijack_cursor} keep the cursor on the first letter of the filename when moving in the tree.

0 commit comments

Comments
 (0)