@@ -2,7 +2,6 @@ local log = require "nvim-tree.log"
22local utils = require " nvim-tree.utils"
33local git_utils = require " nvim-tree.git.utils"
44local Runner = require " nvim-tree.git.runner"
5- local Watch = require " nvim-tree.explorer.watch"
65local Watcher = require (" nvim-tree.watcher" ).Watcher
76local Iterator = require " nvim-tree.iterators.node-iterator"
87local explorer_node = require " nvim-tree.explorer.node"
@@ -165,34 +164,22 @@ function M.load_project_status(cwd)
165164 }
166165
167166 local watcher = nil
168-
169167 if M .config .filesystem_watchers .enable then
170168 log .line (" watcher" , " git start" )
171169
172- local git_directory = git_utils .get_git_directory (project_root )
173-
174- if git_directory == nil then
175- log .line (" watcher" , " could not found the location of .git folder" )
176- else
177- local callback = function (w )
178- log .line (" watcher" , " git event scheduled '%s'" , w .project_root )
179- utils .debounce (" git:watcher:" .. w .project_root , M .config .filesystem_watchers .debounce_delay , function ()
180- if w .destroyed then
181- return
182- end
183- reload_tree_at (w .project_root )
184- end )
185- end
186-
187- -- Add GIT_DIR to the list of directory to ignore
188- -- local base_gitdir = utils.path_basename(git_directory)
189- -- Watch.ignore_dir(base_gitdir)
190- Watch .ignore_dir (git_directory )
191-
192- watcher = Watcher :new (git_directory , WATCHED_FILES , callback , {
193- project_root = project_root ,
194- })
170+ local callback = function (w )
171+ log .line (" watcher" , " git event scheduled '%s'" , w .project_root )
172+ utils .debounce (" git:watcher:" .. w .project_root , M .config .filesystem_watchers .debounce_delay , function ()
173+ if w .destroyed then
174+ return
175+ end
176+ reload_tree_at (w .project_root )
177+ end )
195178 end
179+
180+ watcher = Watcher :new (utils .path_join { project_root , " .git" }, WATCHED_FILES , callback , {
181+ project_root = project_root ,
182+ })
196183 end
197184
198185 M .projects [project_root ] = {
0 commit comments