11local uv = vim .loop
22
3- local log = require " nvim-tree.log"
4- local utils = require " nvim-tree.utils"
53local git_utils = require " nvim-tree.git.utils"
64local Runner = require " nvim-tree.git.runner"
7- local Watcher = require (" nvim-tree.watcher" ).Watcher
8- local Iterator = require " nvim-tree.iterators.node-iterator"
95
106local M = {
117 config = {},
@@ -83,40 +79,6 @@ function M.get_project_root(cwd)
8379 return M .cwd_to_project_root [cwd ]
8480end
8581
86- local function reload_tree_at (project_root )
87- if not M .config .git .enable then
88- return nil
89- end
90-
91- log .line (" watcher" , " git event executing '%s'" , project_root )
92- local root_node = utils .get_node_from_path (project_root )
93- if not root_node then
94- return
95- end
96-
97- M .reload_project (project_root )
98- local project = M .get_project (project_root )
99-
100- local project_files = project .files and project .files or {}
101- local project_dirs = project .dirs and project .dirs or {}
102-
103- Iterator .builder (root_node .nodes )
104- :hidden ()
105- :applier (function (node )
106- local parent_ignored = node .parent .git_status == " !!"
107- node .git_status = project_dirs [node .absolute_path ] or project_files [node .absolute_path ]
108- if not node .git_status and parent_ignored then
109- node .git_status = " !!"
110- end
111- end )
112- :recursor (function (node )
113- return node .nodes and # node .nodes > 0 and node .nodes
114- end )
115- :iterate ()
116-
117- require (" nvim-tree.renderer" ).draw ()
118- end
119-
12082function M .load_project_status (cwd )
12183 if not M .config .git .enable then
12284 return {}
@@ -140,26 +102,9 @@ function M.load_project_status(cwd)
140102 timeout = M .config .git .timeout ,
141103 }
142104
143- local watcher = nil
144- if M .config .filesystem_watchers .enable then
145- log .line (" watcher" , " git start" )
146-
147- local callback = function (w )
148- log .line (" watcher" , " git event scheduled '%s'" , w .project_root )
149- utils .debounce (" git:watcher:" .. w .project_root , M .config .filesystem_watchers .debounce_delay , function ()
150- reload_tree_at (w .project_root )
151- end )
152- end
153-
154- watcher = Watcher :new (utils .path_join { project_root , " .git" }, callback , {
155- project_root = project_root ,
156- })
157- end
158-
159105 M .projects [project_root ] = {
160106 files = git_status ,
161107 dirs = git_utils .file_status_to_dir_status (git_status , project_root ),
162- watcher = watcher ,
163108 }
164109 return M .projects [project_root ]
165110end
171116
172117function M .setup (opts )
173118 M .config .git = opts .git
174- M .config .filesystem_watchers = opts .filesystem_watchers
175119end
176120
177121return M
0 commit comments