Skip to content

Commit ea4dc47

Browse files
authored
Merge branch 'master' into master
2 parents 6f5d22d + 74e9462 commit ea4dc47

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

.github/workflows/semantic-pr-subject.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
semantic-pr-subject:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: amannn/action-semantic-pull-request@v5.5.2
17+
- uses: amannn/action-semantic-pull-request@v5.5.3
1818
env:
1919
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

doc/nvim-tree-lua.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,8 +1176,9 @@ Only relevant when `git.show_on_dirs` is `true`.
11761176

11771177
*nvim-tree.git.disable_for_dirs*
11781178
Disable git integration when git top-level matches these paths.
1179-
May be relative, evaluated via |fnamemodify| `":p"`
1180-
Type: `table`, Default: `{}`
1179+
Strings may be relative, evaluated via |fnamemodify| `":p"`
1180+
Function is passed an absolute path and returns true for disable.
1181+
Type: `string[] | fun(path: string): boolean`, Default: `{}`
11811182

11821183
*nvim-tree.git.timeout*
11831184
Kills the git process after some time if it takes too long.
@@ -1339,10 +1340,12 @@ Idle milliseconds between filesystem change and action.
13391340
Type: `number`, Default: `50` (ms)
13401341

13411342
*nvim-tree.filesystem_watchers.ignore_dirs*
1342-
List of vim regex for absolute directory paths that will not be watched.
1343-
Backslashes must be escaped e.g. `"my-project/\\.build$"`. See |string-match|.
1343+
List of vim regex for absolute directory paths that will not be watched or
1344+
function returning whether a path should be ignored.
1345+
Strings must be backslash escaped e.g. `"my-proj/\\.build$"`. See |string-match|.
1346+
Function is passed an absolute path.
13441347
Useful when path is not in `.gitignore` or git integration is disabled.
1345-
Type: {string}, Default: `{}`
1348+
Type: `string[] | fun(path: string): boolean`, Default: `{}`
13461349

13471350
==============================================================================
13481351
5.13 OPTS: ACTIONS *nvim-tree-opts-actions*

lua/nvim-tree.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,15 @@ local ACCEPTED_TYPES = {
638638
update_focused_file = {
639639
exclude = { "function" },
640640
},
641+
git = {
642+
disable_for_dirs = { "function" },
643+
},
641644
filters = {
642645
custom = { "function" },
643646
},
647+
filesystem_watchers = {
648+
ignore_dirs = { "function" },
649+
},
644650
actions = {
645651
open_file = {
646652
window_picker = {

lua/nvim-tree/explorer/watch.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@ local function is_folder_ignored(path)
4040
end
4141
end
4242

43-
for _, ignore_dir in ipairs(M.config.filesystem_watchers.ignore_dirs) do
44-
if vim.fn.match(path, ignore_dir) ~= -1 then
45-
return true
43+
if type(M.config.filesystem_watchers.ignore_dirs) == "table" then
44+
for _, ignore_dir in ipairs(M.config.filesystem_watchers.ignore_dirs) do
45+
if vim.fn.match(path, ignore_dir) ~= -1 then
46+
return true
47+
end
4648
end
49+
elseif type(M.config.filesystem_watchers.ignore_dirs) == "function" then
50+
return M.config.filesystem_watchers.ignore_dirs(path)
4751
end
4852

4953
return false

lua/nvim-tree/git/init.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,18 @@ function M.get_toplevel(path)
170170
if not toplevel or not git_dir then
171171
return nil
172172
end
173+
local toplevel_norm = vim.fn.fnamemodify(toplevel, ":p")
173174

174175
-- ignore disabled paths
175-
for _, disabled_for_dir in ipairs(M.config.git.disable_for_dirs) do
176-
local toplevel_norm = vim.fn.fnamemodify(toplevel, ":p")
177-
local disabled_norm = vim.fn.fnamemodify(disabled_for_dir, ":p")
178-
if toplevel_norm == disabled_norm then
176+
if type(M.config.git.disable_for_dirs) == "table" then
177+
for _, disabled_for_dir in ipairs(M.config.git.disable_for_dirs) do
178+
local disabled_norm = vim.fn.fnamemodify(disabled_for_dir, ":p")
179+
if toplevel_norm == disabled_norm then
180+
return nil
181+
end
182+
end
183+
elseif type(M.config.git.disable_for_dirs) == "function" then
184+
if M.config.git.disable_for_dirs(toplevel_norm) then
179185
return nil
180186
end
181187
end

0 commit comments

Comments
 (0)