@@ -2,16 +2,14 @@ local git = require "nvim-tree.git"
2
2
local notify = require " nvim-tree.notify"
3
3
local watch = require " nvim-tree.explorer.watch"
4
4
local explorer_node = require " nvim-tree.explorer.node"
5
+
5
6
local Filters = require " nvim-tree.explorer.filters"
6
7
local Marks = {} -- circular dependencies
7
8
local LiveFilter = require " nvim-tree.explorer.live-filter"
8
9
local Sorters = require " nvim-tree.explorer.sorters"
9
10
local Clipboard = {} -- circular dependencies
10
11
11
- local M = {}
12
-
13
- M .explore = require (" nvim-tree.explorer.explore" ).explore
14
- M .reload = require (" nvim-tree.explorer.reload" ).reload
12
+ local config
15
13
16
14
--- @class Explorer
17
15
--- @field absolute_path string
@@ -22,13 +20,14 @@ M.reload = require("nvim-tree.explorer.reload").reload
22
20
--- @field sorters Sorter
23
21
--- @field marks Marks
24
22
--- @field clipboard Clipboard
25
-
26
23
local Explorer = {}
27
- Explorer .__index = Explorer
24
+
25
+ Explorer .explore = require (" nvim-tree.explorer.explore" ).explore
26
+ Explorer .reload = require (" nvim-tree.explorer.reload" ).reload
28
27
29
28
--- @param path string | nil
30
29
--- @return Explorer | nil
31
- function Explorer . new (path )
30
+ function Explorer : new (path )
32
31
local err
33
32
34
33
if path then
@@ -42,27 +41,32 @@ function Explorer.new(path)
42
41
end
43
42
44
43
--- @class Explorer
45
- local explorer = setmetatable ({
44
+ local o = setmetatable ({
46
45
absolute_path = path ,
47
46
nodes = {},
48
47
open = true ,
49
- sorters = Sorters :new (M . config ),
48
+ sorters = Sorters :new (config ),
50
49
}, Explorer )
51
- explorer .watcher = watch .create_watcher (explorer )
52
- explorer .filters = Filters :new (M .config , explorer )
53
- explorer .live_filter = LiveFilter :new (M .config , explorer )
54
- explorer .marks = Marks :new (M .config , explorer )
55
- explorer .clipboard = Clipboard :new (M .config , explorer )
56
- explorer :_load (explorer )
57
- return explorer
50
+ setmetatable (o , self )
51
+ self .__index = self
52
+
53
+ o .watcher = watch .create_watcher (o )
54
+ o .filters = Filters :new (config , o )
55
+ o .live_filter = LiveFilter :new (config , o )
56
+ o .marks = Marks :new (config , o )
57
+ o .clipboard = Clipboard :new (config , o )
58
+
59
+ o :_load (o )
60
+
61
+ return o
58
62
end
59
63
60
64
--- @private
61
65
--- @param node Node
62
66
function Explorer :_load (node )
63
67
local cwd = node .link_to or node .absolute_path
64
68
local git_status = git .load_project_status (cwd )
65
- M .explore (node , git_status , self )
69
+ Explorer .explore (node , git_status , self )
66
70
end
67
71
68
72
--- @param node Node
@@ -82,8 +86,8 @@ function Explorer:destroy()
82
86
iterate (self )
83
87
end
84
88
85
- function M .setup (opts )
86
- M . config = opts
89
+ function Explorer .setup (opts )
90
+ config = opts
87
91
require (" nvim-tree.explorer.node" ).setup (opts )
88
92
require (" nvim-tree.explorer.explore" ).setup (opts )
89
93
require (" nvim-tree.explorer.reload" ).setup (opts )
@@ -93,6 +97,4 @@ function M.setup(opts)
93
97
Clipboard = require " nvim-tree.actions.fs.clipboard"
94
98
end
95
99
96
- M .Explorer = Explorer
97
-
98
- return M
100
+ return Explorer
0 commit comments