Skip to content

Commit 68c67ad

Browse files
perf(commands): defer module loading (#3210)
1 parent 64e2192 commit 68c67ad

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

lua/nvim-tree/commands.lua

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
local api = require("nvim-tree.api")
2-
local view = require("nvim-tree.view")
3-
41
local M = {}
52

63
local CMDS = {
@@ -12,7 +9,7 @@ local CMDS = {
129
complete = "dir",
1310
},
1411
command = function(c)
15-
api.tree.open({ path = c.args })
12+
require("nvim-tree.api").tree.open({ path = c.args })
1613
end,
1714
},
1815
{
@@ -22,7 +19,7 @@ local CMDS = {
2219
bar = true,
2320
},
2421
command = function()
25-
api.tree.close()
22+
require("nvim-tree.api").tree.close()
2623
end,
2724
},
2825
{
@@ -33,7 +30,7 @@ local CMDS = {
3330
complete = "dir",
3431
},
3532
command = function(c)
36-
api.tree.toggle({
33+
require("nvim-tree.api").tree.toggle({
3734
find_file = false,
3835
focus = true,
3936
path = c.args,
@@ -48,7 +45,7 @@ local CMDS = {
4845
bar = true,
4946
},
5047
command = function()
51-
api.tree.open()
48+
require("nvim-tree.api").tree.open()
5249
end,
5350
},
5451
{
@@ -58,7 +55,7 @@ local CMDS = {
5855
bar = true,
5956
},
6057
command = function()
61-
api.tree.reload()
58+
require("nvim-tree.api").tree.reload()
6259
end,
6360
},
6461
{
@@ -68,7 +65,7 @@ local CMDS = {
6865
bar = true,
6966
},
7067
command = function()
71-
api.fs.print_clipboard()
68+
require("nvim-tree.api").fs.print_clipboard()
7269
end,
7370
},
7471
{
@@ -79,7 +76,7 @@ local CMDS = {
7976
bar = true,
8077
},
8178
command = function(c)
82-
api.tree.find_file({
79+
require("nvim-tree.api").tree.find_file({
8380
open = true,
8481
focus = true,
8582
update_root = c.bang,
@@ -95,7 +92,7 @@ local CMDS = {
9592
complete = "dir",
9693
},
9794
command = function(c)
98-
api.tree.toggle({
95+
require("nvim-tree.api").tree.toggle({
9996
find_file = true,
10097
focus = true,
10198
path = c.args,
@@ -111,7 +108,7 @@ local CMDS = {
111108
bar = true,
112109
},
113110
command = function(c)
114-
view.resize(c.args)
111+
require("nvim-tree.view").resize(c.args)
115112
end,
116113
},
117114
{
@@ -121,7 +118,7 @@ local CMDS = {
121118
bar = true,
122119
},
123120
command = function()
124-
api.tree.collapse_all(false)
121+
require("nvim-tree.api").tree.collapse_all(false)
125122
end,
126123
},
127124
{
@@ -131,15 +128,17 @@ local CMDS = {
131128
bar = true,
132129
},
133130
command = function()
134-
api.tree.collapse_all(true)
131+
require("nvim-tree.api").tree.collapse_all(true)
135132
end,
136133
},
137134
{
138135
name = "NvimTreeHiTest",
139136
opts = {
140137
desc = "nvim-tree: highlight test",
141138
},
142-
command = api.diagnostics.hi_test,
139+
command = function()
140+
require("nvim-tree.api").diagnostics.hi_test()
141+
end,
143142
},
144143
}
145144

0 commit comments

Comments
 (0)