Skip to content

Commit 181dab8

Browse files
committed
perf(#3253): move all setup requires inside the function
1 parent 400839b commit 181dab8

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lua/nvim-tree.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
local config = require("nvim-tree.config")
2-
31
local M = {}
42

53
---`require("nvim-tree").setup` must be called once to initialise nvim-tree.
@@ -10,7 +8,13 @@ local M = {}
108
---
119
---@param config_user? nvim_tree.config subset, uses defaults when nil
1210
function M.setup(config_user)
11+
local api = require("nvim-tree.api")
12+
local api_impl = require("nvim-tree.api.impl")
13+
local appearance = require("nvim-tree.appearance")
14+
local autocmd = require("nvim-tree.autocmd")
15+
local config = require("nvim-tree.config")
1316
local log = require("nvim-tree.log")
17+
local view_state = require("nvim-tree.view-state")
1418

1519
-- Nvim version check
1620
if vim.fn.has("nvim-0.9") == 0 then
@@ -31,21 +35,21 @@ function M.setup(config_user)
3135
end
3236

3337
-- idempotent highlight definition
34-
require("nvim-tree.appearance").highlight()
38+
appearance.highlight()
3539

3640
-- set the initial view state based on config
37-
require("nvim-tree.view-state").initialize()
41+
view_state.initialize()
3842

3943
-- idempotent au (re)definition
40-
require("nvim-tree.autocmd").global()
44+
autocmd.global()
4145

4246
-- subsequent calls to setup clear all state
4347
if vim.g.NvimTreeSetup == 1 then
4448
require("nvim-tree.core").purge_all_state()
4549
end
4650

4751
-- hydrate post setup API
48-
require("nvim-tree.api.impl").hydrate_post_setup(require("nvim-tree.api"))
52+
api_impl.hydrate_post_setup(api)
4953

5054
vim.g.NvimTreeSetup = 1
5155
vim.api.nvim_exec_autocmds("User", { pattern = "NvimTreeSetup" })

0 commit comments

Comments
 (0)