Skip to content

Commit 4146915

Browse files
committed
perf(#3257): remove git setup
1 parent a5a17b9 commit 4146915

2 files changed

Lines changed: 15 additions & 20 deletions

File tree

lua/nvim-tree.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ function M.setup(config_user)
288288
require("nvim-tree.appearance").setup()
289289
require("nvim-tree.explorer"):setup(config.g)
290290
require("nvim-tree.explorer.watch").setup(config.g)
291-
require("nvim-tree.git").setup(config.g)
292291
require("nvim-tree.git.utils").setup(config.g)
293292
require("nvim-tree.view").setup(config.g)
294293
require("nvim-tree.renderer.components").setup(config.g)

lua/nvim-tree/git/init.lua

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local log = require("nvim-tree.log")
22
local utils = require("nvim-tree.utils")
3+
local config = require("nvim-tree.config")
34
local git_utils = require("nvim-tree.git.utils")
45

56
local GitRunner = require("nvim-tree.git.runner")
@@ -88,7 +89,7 @@ end
8889

8990
---@return nvim_tree.git.Project[] maybe empty
9091
function 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

@@ -106,7 +107,7 @@ end
106107
function 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)
220221
end
221222

222223
local 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

@@ -259,7 +260,7 @@ end
259260
---@param path string absolute
260261
---@return nvim_tree.git.Project maybe empty
261262
function 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
@@ -403,12 +404,7 @@ end
403404
function 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
412408
end
413409

414410
return M

0 commit comments

Comments
 (0)