Skip to content

fix(#1720): remove .git watcher #1725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions lua/nvim-tree/git/init.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
local log = require "nvim-tree.log"
local utils = require "nvim-tree.utils"
local git_utils = require "nvim-tree.git.utils"
local Runner = require "nvim-tree.git.runner"
local Watcher = require("nvim-tree.watcher").Watcher
local Iterator = require "nvim-tree.iterators.node-iterator"

local M = {
config = {},
Expand Down Expand Up @@ -81,40 +77,6 @@ function M.get_project_root(cwd)
return M.cwd_to_project_root[cwd]
end

local function reload_tree_at(project_root)
if not M.config.git.enable then
return nil
end

log.line("watcher", "git event executing '%s'", project_root)
local root_node = utils.get_node_from_path(project_root)
if not root_node then
return
end

M.reload_project(project_root)
local project = M.get_project(project_root)

local project_files = project.files and project.files or {}
local project_dirs = project.dirs and project.dirs or {}

Iterator.builder(root_node.nodes)
:hidden()
:applier(function(node)
local parent_ignored = node.parent.git_status == "!!"
node.git_status = project_dirs[node.absolute_path] or project_files[node.absolute_path]
if not node.git_status and parent_ignored then
node.git_status = "!!"
end
end)
:recursor(function(node)
return node.nodes and #node.nodes > 0 and node.nodes
end)
:iterate()

require("nvim-tree.renderer").draw()
end

function M.load_project_status(cwd)
if not M.config.git.enable then
return {}
Expand All @@ -138,26 +100,9 @@ function M.load_project_status(cwd)
timeout = M.config.git.timeout,
}

local watcher = nil
if M.config.filesystem_watchers.enable then
log.line("watcher", "git start")

local callback = function(w)
log.line("watcher", "git event scheduled '%s'", w.project_root)
utils.debounce("git:watcher:" .. w.project_root, M.config.filesystem_watchers.debounce_delay, function()
reload_tree_at(w.project_root)
end)
end

watcher = Watcher:new(utils.path_join { project_root, ".git" }, callback, {
project_root = project_root,
})
end

M.projects[project_root] = {
files = git_status,
dirs = git_utils.file_status_to_dir_status(git_status, project_root),
watcher = watcher,
}
return M.projects[project_root]
end
Expand All @@ -169,7 +114,6 @@ end

function M.setup(opts)
M.config.git = opts.git
M.config.filesystem_watchers = opts.filesystem_watchers
end

return M