feat: add exclude filter list (#878)
This commit is contained in:
parent
a896a2b5a2
commit
9e2f6b6f25
@ -338,6 +338,11 @@ Here is a list of the options available in the setup call:
|
|||||||
type: `{string}`
|
type: `{string}`
|
||||||
default: `{}`
|
default: `{}`
|
||||||
|
|
||||||
|
- |filters.exclude|: list of directories or files to exclude from filtering
|
||||||
|
(will always be shown)
|
||||||
|
type: `{string}`
|
||||||
|
default: `{}`
|
||||||
|
|
||||||
*nvim-tree.trash*
|
*nvim-tree.trash*
|
||||||
|trash|: configuration options for trashing
|
|trash|: configuration options for trashing
|
||||||
|
|
||||||
|
|||||||
@ -441,7 +441,8 @@ local DEFAULT_OPTS = {
|
|||||||
},
|
},
|
||||||
filters = {
|
filters = {
|
||||||
dotfiles = false,
|
dotfiles = false,
|
||||||
custom_filter = {}
|
custom_filter = {},
|
||||||
|
exclude = {}
|
||||||
},
|
},
|
||||||
git = {
|
git = {
|
||||||
enable = true,
|
enable = true,
|
||||||
|
|||||||
@ -5,6 +5,7 @@ local utils = require'nvim-tree.utils'
|
|||||||
|
|
||||||
local M = {
|
local M = {
|
||||||
ignore_list = {},
|
ignore_list = {},
|
||||||
|
exclude_list = {},
|
||||||
is_windows = vim.fn.has('win32') == 1
|
is_windows = vim.fn.has('win32') == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +123,12 @@ end
|
|||||||
local function should_ignore(path)
|
local function should_ignore(path)
|
||||||
local basename = utils.path_basename(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 M.config.filter_dotfiles then
|
||||||
if basename:sub(1, 1) == '.' then
|
if basename:sub(1, 1) == '.' then
|
||||||
return true
|
return true
|
||||||
@ -353,6 +360,8 @@ function M.setup(opts)
|
|||||||
filter_dotfiles = opts.filters.dotfiles,
|
filter_dotfiles = opts.filters.dotfiles,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
M.exclude_list = opts.filters.exclude
|
||||||
|
|
||||||
local custom_filter = opts.filters.custom
|
local custom_filter = opts.filters.custom
|
||||||
if custom_filter and #custom_filter > 0 then
|
if custom_filter and #custom_filter > 0 then
|
||||||
for _, entry in pairs(custom_filter) do
|
for _, entry in pairs(custom_filter) do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user