feat(#2799): filesystem_watchers.ignore_dirs and git.disable_for_dirs may be functions
This commit is contained in:
parent
2086e564c4
commit
8b2c5c678b
@ -1170,8 +1170,9 @@ Only relevant when `git.show_on_dirs` is `true`.
|
|||||||
|
|
||||||
*nvim-tree.git.disable_for_dirs*
|
*nvim-tree.git.disable_for_dirs*
|
||||||
Disable git integration when git top-level matches these paths.
|
Disable git integration when git top-level matches these paths.
|
||||||
May be relative, evaluated via |fnamemodify| `":p"`
|
Strings may be relative, evaluated via |fnamemodify| `":p"`
|
||||||
Type: `table`, Default: `{}`
|
Function is passed an absolute path and returns true for disable.
|
||||||
|
Type: `string[] | fun(path: string): boolean`, Default: `{}`
|
||||||
|
|
||||||
*nvim-tree.git.timeout*
|
*nvim-tree.git.timeout*
|
||||||
Kills the git process after some time if it takes too long.
|
Kills the git process after some time if it takes too long.
|
||||||
@ -1333,10 +1334,12 @@ Idle milliseconds between filesystem change and action.
|
|||||||
Type: `number`, Default: `50` (ms)
|
Type: `number`, Default: `50` (ms)
|
||||||
|
|
||||||
*nvim-tree.filesystem_watchers.ignore_dirs*
|
*nvim-tree.filesystem_watchers.ignore_dirs*
|
||||||
List of vim regex for absolute directory paths that will not be watched.
|
List of vim regex for absolute directory paths that will not be watched or
|
||||||
Backslashes must be escaped e.g. `"my-project/\\.build$"`. See |string-match|.
|
function returning whether a path should be ignored.
|
||||||
|
Strings must be backslash escaped e.g. `"my-proj/\\.build$"`. See |string-match|.
|
||||||
|
Function is passed an absolute path.
|
||||||
Useful when path is not in `.gitignore` or git integration is disabled.
|
Useful when path is not in `.gitignore` or git integration is disabled.
|
||||||
Type: {string}, Default: `{}`
|
Type: `string[] | fun(path: string): boolean`, Default: `{}`
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
5.13 OPTS: ACTIONS *nvim-tree-opts-actions*
|
5.13 OPTS: ACTIONS *nvim-tree-opts-actions*
|
||||||
|
|||||||
@ -632,9 +632,15 @@ local ACCEPTED_TYPES = {
|
|||||||
update_focused_file = {
|
update_focused_file = {
|
||||||
exclude = { "function" },
|
exclude = { "function" },
|
||||||
},
|
},
|
||||||
|
git = {
|
||||||
|
disable_for_dirs = { "function" },
|
||||||
|
},
|
||||||
filters = {
|
filters = {
|
||||||
custom = { "function" },
|
custom = { "function" },
|
||||||
},
|
},
|
||||||
|
filesystem_watchers = {
|
||||||
|
ignore_dirs = { "function" },
|
||||||
|
},
|
||||||
actions = {
|
actions = {
|
||||||
open_file = {
|
open_file = {
|
||||||
window_picker = {
|
window_picker = {
|
||||||
|
|||||||
@ -40,10 +40,14 @@ local function is_folder_ignored(path)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, ignore_dir in ipairs(M.config.filesystem_watchers.ignore_dirs) do
|
if type(M.config.filesystem_watchers.ignore_dirs) == "table" then
|
||||||
if vim.fn.match(path, ignore_dir) ~= -1 then
|
for _, ignore_dir in ipairs(M.config.filesystem_watchers.ignore_dirs) do
|
||||||
return true
|
if vim.fn.match(path, ignore_dir) ~= -1 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
elseif type(M.config.filesystem_watchers.ignore_dirs) == "function" then
|
||||||
|
return M.config.filesystem_watchers.ignore_dirs(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -170,12 +170,18 @@ function M.get_toplevel(path)
|
|||||||
if not toplevel or not git_dir then
|
if not toplevel or not git_dir then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
local toplevel_norm = vim.fn.fnamemodify(toplevel, ":p")
|
||||||
|
|
||||||
-- ignore disabled paths
|
-- ignore disabled paths
|
||||||
for _, disabled_for_dir in ipairs(M.config.git.disable_for_dirs) do
|
if type(M.config.git.disable_for_dirs) == "table" then
|
||||||
local toplevel_norm = vim.fn.fnamemodify(toplevel, ":p")
|
for _, disabled_for_dir in ipairs(M.config.git.disable_for_dirs) do
|
||||||
local disabled_norm = vim.fn.fnamemodify(disabled_for_dir, ":p")
|
local disabled_norm = vim.fn.fnamemodify(disabled_for_dir, ":p")
|
||||||
if toplevel_norm == disabled_norm then
|
if toplevel_norm == disabled_norm then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif type(M.config.git.disable_for_dirs) == "function" then
|
||||||
|
if M.config.git.disable_for_dirs(toplevel_norm) then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user