feat: add exclude filter list (#878)

This commit is contained in:
Michael 2022-01-21 11:48:58 +02:00 committed by GitHub
parent a896a2b5a2
commit 9e2f6b6f25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -338,6 +338,11 @@ Here is a list of the options available in the setup call:
type: `{string}`
default: `{}`
- |filters.exclude|: list of directories or files to exclude from filtering
(will always be shown)
type: `{string}`
default: `{}`
*nvim-tree.trash*
|trash|: configuration options for trashing

View File

@ -441,7 +441,8 @@ local DEFAULT_OPTS = {
},
filters = {
dotfiles = false,
custom_filter = {}
custom_filter = {},
exclude = {}
},
git = {
enable = true,

View File

@ -5,6 +5,7 @@ local utils = require'nvim-tree.utils'
local M = {
ignore_list = {},
exclude_list = {},
is_windows = vim.fn.has('win32') == 1
}
@ -122,6 +123,12 @@ end
local function should_ignore(path)
local basename = utils.path_basename(path)
for _, entry in ipairs(M.exclude_list) do
if path:match(entry) then
return false
end
end
if M.config.filter_dotfiles then
if basename:sub(1, 1) == '.' then
return true
@ -353,6 +360,8 @@ function M.setup(opts)
filter_dotfiles = opts.filters.dotfiles,
}
M.exclude_list = opts.filters.exclude
local custom_filter = opts.filters.custom
if custom_filter and #custom_filter > 0 then
for _, entry in pairs(custom_filter) do