* Improve $GIT_DIR handling - Retrieve $GIT_DIR using `git rev-parse --absolute-git-dir` - Move $GIT_DIR ignore in the project exploration part Resolves #1976 * Code review - move norm_path to utils.lua - fix comment #2012 * add comments for utils.norm_path * get_git_directory use norm_path from utils * watcher improvements --------- Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
@@ -4,11 +4,7 @@ local Watcher = require("nvim-tree.watcher").Watcher
|
||||
|
||||
local M = {}
|
||||
|
||||
local function is_git(path)
|
||||
return vim.fn.fnamemodify(path, ":t") == ".git"
|
||||
end
|
||||
|
||||
local IGNORED_PATHS = {
|
||||
M.ignore_dirs = {
|
||||
-- disable watchers on kernel filesystems
|
||||
-- which have a lot of unwanted events
|
||||
"/sys",
|
||||
@@ -16,13 +12,11 @@ local IGNORED_PATHS = {
|
||||
"/dev",
|
||||
}
|
||||
|
||||
local function is_folder_ignored(path)
|
||||
for _, folder in ipairs(IGNORED_PATHS) do
|
||||
if vim.startswith(path, folder) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
function M.ignore_dir(path)
|
||||
table.insert(M.ignore_dirs, path)
|
||||
end
|
||||
|
||||
local function is_folder_ignored(path)
|
||||
for _, ignore_dir in ipairs(M.ignore_dirs) do
|
||||
if vim.fn.match(path, ignore_dir) ~= -1 then
|
||||
return true
|
||||
@@ -44,7 +38,7 @@ function M.create_watcher(node)
|
||||
path = node.absolute_path
|
||||
end
|
||||
|
||||
if is_git(path) or is_folder_ignored(path) then
|
||||
if is_folder_ignored(path) then
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -74,7 +68,7 @@ end
|
||||
function M.setup(opts)
|
||||
M.enabled = opts.filesystem_watchers.enable
|
||||
M.debounce_delay = opts.filesystem_watchers.debounce_delay
|
||||
M.ignore_dirs = opts.filesystem_watchers.ignore_dirs
|
||||
M.ignore_dirs = vim.tbl_extend("force", M.ignore_dirs, opts.filesystem_watchers.ignore_dirs)
|
||||
M.uid = 0
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user