From ab14d8bbb32eceb622d8e6407456181b690d3aba Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 27 Mar 2022 17:08:23 +1100 Subject: [PATCH 1/4] #618 filters.custom can specify regex --- doc/nvim-tree-lua.txt | 2 +- lua/nvim-tree/explorer/filters.lua | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 5704878c036..097711b6dc0 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -411,7 +411,7 @@ Here is a list of the options available in the setup call: type: `boolean` default: `false` - - |filters.custom|: custom list of string that will not be shown. + - |filters.custom|: custom list of file/directory name regex that will not be shown. type: `{string}` default: `{}` diff --git a/lua/nvim-tree/explorer/filters.lua b/lua/nvim-tree/explorer/filters.lua index 958a9a9bccc..a181265c03d 100644 --- a/lua/nvim-tree/explorer/filters.lua +++ b/lua/nvim-tree/explorer/filters.lua @@ -35,8 +35,14 @@ function M.should_ignore(path) end local relpath = utils.path_relative(path, vim.loop.cwd()) - if M.ignore_list[relpath] == true or M.ignore_list[basename] == true then - return true + for pat, _ in pairs(M.ignore_list) do + if pat == relpath or pat == basename then + return true + end + pat = "^" .. pat .. "$" + if relpath:match(pat) or basename:match(pat) then + return true + end end local idx = path:match ".+()%.[^.]+$" From f330335cecba215cfec6882dbce21eda7cbd0b6e Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 2 Apr 2022 13:48:20 +1100 Subject: [PATCH 2/4] #618 filters.custom uses vim regex --- doc/nvim-tree-lua.txt | 3 ++- lua/nvim-tree/explorer/filters.lua | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 097711b6dc0..0ce474b50c3 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -411,7 +411,8 @@ Here is a list of the options available in the setup call: type: `boolean` default: `false` - - |filters.custom|: custom list of file/directory name regex that will not be shown. + - |filters.custom|: custom list of vim regex for file/directory names that will not be shown. + Backslashes must be escaped e.g. "^\\.git". See |string-match|. type: `{string}` default: `{}` diff --git a/lua/nvim-tree/explorer/filters.lua b/lua/nvim-tree/explorer/filters.lua index a181265c03d..8ec661e2e7f 100644 --- a/lua/nvim-tree/explorer/filters.lua +++ b/lua/nvim-tree/explorer/filters.lua @@ -36,11 +36,7 @@ function M.should_ignore(path) local relpath = utils.path_relative(path, vim.loop.cwd()) for pat, _ in pairs(M.ignore_list) do - if pat == relpath or pat == basename then - return true - end - pat = "^" .. pat .. "$" - if relpath:match(pat) or basename:match(pat) then + if vim.fn.match(relpath, pat) ~= -1 or vim.fn.match(basename, pat) ~= -1 then return true end end From 12de691add60b92feb0b2d7a5562be7ba2a0a5a3 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 2 Apr 2022 13:50:16 +1100 Subject: [PATCH 3/4] #618 filters.custom uses vim regex --- doc/nvim-tree-lua.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 0ce474b50c3..ec770554717 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -411,7 +411,7 @@ Here is a list of the options available in the setup call: type: `boolean` default: `false` - - |filters.custom|: custom list of vim regex for file/directory names that will not be shown. + - |filters.custom|: custom list of regex for file/directory names that will not be shown. Backslashes must be escaped e.g. "^\\.git". See |string-match|. type: `{string}` default: `{}` From 126277f1e15c1b010d5942a008ac573f1da442be Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 2 Apr 2022 13:53:40 +1100 Subject: [PATCH 4/4] #618 filters.custom uses vim regex --- doc/nvim-tree-lua.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 2c16ec877cb..78f0f7dd007 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -405,7 +405,7 @@ Here is a list of the options available in the setup call: type: `boolean` default: `false` - - |filters.custom|: custom list of regex for file/directory names that will not be shown. + - |filters.custom|: custom list of vim regex for file/directory names that will not be shown. Backslashes must be escaped e.g. "^\\.git". See |string-match|. type: `{string}` default: `{}`