Skip to content

Commit 876c329

Browse files
authored
docs: clarify lazyloading, mention config types (#1734)
1 parent d9544c7 commit 876c329

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ body:
7878
"MunifTanjim/nui.nvim",
7979
-- { "3rd/image.nvim", opts = {} }, -- Optional image support
8080
},
81+
lazy = false,
82+
---@module "neo-tree"
83+
---@type neotree.Config?
8184
opts = {
8285
-- fill any relevant options here
8386
},

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ so we can fix it.
5656

5757
## Minimal Quickstart
5858

59+
> [!NOTE]
60+
> You do not need to call `require('neo-tree').setup({ ... })` for Neo-tree to work. `setup()` is only used for
61+
> configuration.
62+
5963
#### Minimal Example for Lazy:
6064
```lua
6165
{
@@ -66,7 +70,13 @@ so we can fix it.
6670
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
6771
"MunifTanjim/nui.nvim",
6872
-- {"3rd/image.nvim", opts = {}}, -- Optional image support in preview window: See `# Preview Mode` for more information
69-
}
73+
},
74+
lazy = false, -- neo-tree will lazily load itself
75+
---@module "neo-tree"
76+
---@type neotree.Config?
77+
opts = {
78+
-- fill any relevant options here
79+
},
7080
}
7181
```
7282

@@ -142,12 +152,17 @@ return {
142152
end,
143153
},
144154
},
155+
lazy = false,
156+
-----Instead of using `config`, you can use `opts` instead, if you'd like:
157+
-----@module "neo-tree"
158+
-----@type neotree.Config
159+
--opts = {},
145160
config = function()
146161
-- If you want icons for diagnostic errors, you'll need to define them somewhere:
147-
vim.fn.sign_define("DiagnosticSignError", { text = "", texthl = "DiagnosticSignError" })
148-
vim.fn.sign_define("DiagnosticSignWarn", { text = "", texthl = "DiagnosticSignWarn" })
149-
vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" })
150-
vim.fn.sign_define("DiagnosticSignHint", { text = "󰌵", texthl = "DiagnosticSignHint" })
162+
-- vim.fn.sign_define("DiagnosticSignError", { text = " ", texthl = "DiagnosticSignError" })
163+
-- vim.fn.sign_define("DiagnosticSignWarn", { text = " ", texthl = "DiagnosticSignWarn" })
164+
-- vim.fn.sign_define("DiagnosticSignInfo", { text = " ", texthl = "DiagnosticSignInfo" })
165+
-- vim.fn.sign_define("DiagnosticSignHint", { text = "󰌵", texthl = "DiagnosticSignHint" })
151166

152167
require("neo-tree").setup({
153168
close_if_last_window = false, -- Close Neo-tree if it is the last window left in the tab

doc/neo-tree.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,28 @@ commented default config in your current file. Even if you don't want to use
784784
that config as your starting point, you still may want to dump it to a blank
785785
lua file just to read it as documentation.
786786

787+
NOTE: Neo-tree has type annotations for its configuration. If you have a Lua
788+
language server that supports EmmyLua/LuaCATS annotations, you can use
789+
`neotree.Config`, for example:
790+
791+
>lua
792+
-- if using lazy.nvim:
793+
{
794+
"nvim-neo-tree/neo-tree.nvim",
795+
dependencies = {
796+
"nvim-lua/plenary.nvim",
797+
"nvim-tree/nvim-web-devicons",
798+
"MunifTanjim/nui.nvim",
799+
-- { "3rd/image.nvim", opts = {} }, -- Optional image support
800+
},
801+
lazy = false, -- neo-tree lazy-loads itself
802+
---@module "neo-tree"
803+
---@type neotree.Config?
804+
-- opts = {
805+
-- -- fill any relevant options here
806+
-- },
807+
}
808+
<
787809

788810
SOURCE SELECTOR *neo-tree-source-selector*
789811

0 commit comments

Comments
 (0)