Skip to content

Commit 581aa42

Browse files
committed
feat: allow lazy loading via vim.g.nvim_tree_config
1 parent b8b44b6 commit 581aa42

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ require("nvim-tree").setup({
7676
dotfiles = true,
7777
},
7878
})
79+
80+
-- OR use the following variable and nvim-tree will call setup lazily
81+
vim.g.NvimTreeConfig = {
82+
on_attach = my_on_attach
83+
}
7984
```
8085

8186
### Help

lua/nvim-tree/api.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ local Api = {
5050
---@return fun(...): any
5151
local function wrap(fn)
5252
return function(...)
53-
if vim.g.NvimTreeSetup == 1 then
53+
if vim.g.NvimTreeSetup == 1 or vim.g.NvimTreeConfig then
54+
if vim.g.NvimTreeSetup ~= 1 then
55+
require("nvim-tree").setup(vim.g.NvimTreeConfig)
56+
end
57+
5458
return fn(...)
5559
else
5660
notify.error("nvim-tree setup not called")

0 commit comments

Comments
 (0)