11local log = require (" nvim-tree.log" )
22local utils = require (" nvim-tree.utils" )
3+ local config = require (" nvim-tree.config" )
34local git_utils = require (" nvim-tree.git.utils" )
45
56local GitRunner = require (" nvim-tree.git.runner" )
8889
8990--- @return nvim_tree.git.Project[] maybe empty
9091function M .reload_all_projects ()
91- if not M . config .git .enable then
92+ if not config . g .git .enable then
9293 return {}
9394 end
9495
106107function M .reload_project (toplevel , path , callback )
107108 local project = M ._projects_by_toplevel [toplevel ] --[[ @as nvim_tree.git.Project]]
108109
109- if not toplevel or not project or not M . config .git .enable then
110+ if not toplevel or not project or not config . g .git .enable then
110111 if callback then
111112 callback ()
112113 end
@@ -126,7 +127,7 @@ function M.reload_project(toplevel, path, callback)
126127 path = path ,
127128 list_untracked = git_utils .should_show_untracked (toplevel ),
128129 list_ignored = true ,
129- timeout = M . config .git .timeout ,
130+ timeout = config . g .git .timeout ,
130131 }
131132
132133 if callback then
@@ -161,7 +162,7 @@ function M.get_toplevel(path)
161162 return nil
162163 end
163164
164- if not M . config .git .enable then
165+ if not config . g .git .enable then
165166 return nil
166167 end
167168
@@ -194,15 +195,15 @@ function M.get_toplevel(path)
194195 local toplevel_norm = vim .fn .fnamemodify (toplevel , " :p" )
195196
196197 -- ignore disabled paths
197- if type (M . config .git .disable_for_dirs ) == " table" then
198- for _ , disabled_for_dir in ipairs (M . config .git .disable_for_dirs ) do
198+ if type (config . g .git .disable_for_dirs ) == " table" then
199+ for _ , disabled_for_dir in ipairs (config .g . git .disable_for_dirs --[[ @as string[] ]] ) do
199200 local disabled_norm = vim .fn .fnamemodify (disabled_for_dir , " :p" )
200201 if toplevel_norm == disabled_norm then
201202 return nil
202203 end
203204 end
204- elseif type (M . config .git .disable_for_dirs ) == " function" then
205- if M . config .git .disable_for_dirs (toplevel_norm ) then
205+ elseif type (config . g .git .disable_for_dirs ) == " function" then
206+ if config . g .git .disable_for_dirs (toplevel_norm ) then
206207 return nil
207208 end
208209 end
@@ -220,7 +221,7 @@ function M.get_toplevel(path)
220221end
221222
222223local function reload_tree_at (toplevel )
223- if not M . config .git .enable or not toplevel then
224+ if not config . g .git .enable or not toplevel then
224225 return nil
225226 end
226227
259260--- @param path string absolute
260261--- @return nvim_tree.git.Project maybe empty
261262function M .load_project (path )
262- if not M . config .git .enable then
263+ if not config . g .git .enable then
263264 return {}
264265 end
265266
@@ -278,17 +279,17 @@ function M.load_project(path)
278279 toplevel = toplevel ,
279280 list_untracked = git_utils .should_show_untracked (toplevel ),
280281 list_ignored = true ,
281- timeout = M . config .git .timeout ,
282+ timeout = config . g .git .timeout ,
282283 })
283284
284285 local watcher = nil
285- if M . config .filesystem_watchers .enable then
286+ if config . g .filesystem_watchers .enable then
286287 log .line (" watcher" , " git start" )
287288
288289 --- @param w Watcher
289290 local callback = function (w )
290291 log .line (" watcher" , " git event scheduled '%s'" , w .data .toplevel )
291- utils .debounce (" git:watcher:" .. w .data .toplevel , M . config .filesystem_watchers .debounce_delay , function ()
292+ utils .debounce (" git:watcher:" .. w .data .toplevel , config . g .filesystem_watchers .debounce_delay , function ()
292293 if w .destroyed then
293294 return
294295 end
403404function M .disable_git_integration ()
404405 log .line (" git" , " disabling git integration" )
405406 M .purge_state ()
406- M .config .git .enable = false
407- end
408-
409- function M .setup (opts )
410- M .config .git = opts .git
411- M .config .filesystem_watchers = opts .filesystem_watchers
407+ config .g .git .enable = false
412408end
413409
414410return M
0 commit comments