Skip to content

Commit d69601f

Browse files
committed
feat(files): add option to use plenary for gitignore checks, fixes #147
1 parent ec13f39 commit d69601f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lua/neo-tree/defaults.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ local config = {
153153
filters = {
154154
show_hidden = false,
155155
respect_gitignore = true,
156+
gitignore_source = "git", -- or "plenary", which may be faster in a slow repo but less accurate
156157
},
157158
bind_to_cwd = true, -- true creates a 2-way binding between vim's cwd and neo-tree's root
158159
-- The renderer section provides the renderers that will be used to render the tree.

lua/neo-tree/sources/filesystem/lib/fs_scan.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ local function do_scan(context, path_to_scan)
1818
local paths_to_load = context.paths_to_load
1919
local folders = context.folders
2020
local filters = state.filters or {}
21+
local use_gitignore_table = filters.respect_gitignore and filters.gitignore_source == "git"
2122

2223
scan.scan_dir_async(path_to_scan, {
2324
hidden = filters.show_hidden or false,
2425
search_pattern = state.search_pattern or nil,
26+
respect_gitignore = filters.respect_gitignore and filters.gitignore_source == "plenary",
2527
add_dirs = true,
2628
depth = 1,
2729
on_insert = function(path, _type)
28-
if not filters.respect_gitignore or not git.is_ignored(state.git_ignored, path, _type) then
30+
if not use_gitignore_table or not git.is_ignored(state.git_ignored, path, _type) then
2931
local success, _ = pcall(file_items.create_item, context, path, _type)
3032
if not success then
3133
log.error("error creating item for ", path)
@@ -126,8 +128,8 @@ M.get_items_async = function(state, parent_id, path_to_reveal, callback)
126128
context.paths_to_load = {}
127129
if parent_id == nil then
128130
if utils.truthy(state.force_open_folders) then
129-
for _, path in ipairs(state.force_open_folders) do
130-
table.insert(context.paths_to_load, path)
131+
for _, f in ipairs(state.force_open_folders) do
132+
table.insert(context.paths_to_load, f)
131133
end
132134
elseif state.tree then
133135
context.paths_to_load = renderer.get_expanded_nodes(state.tree, state.path)
@@ -148,7 +150,11 @@ M.get_items_async = function(state, parent_id, path_to_reveal, callback)
148150
context.paths_to_load = utils.unique(context.paths_to_load)
149151
end
150152

151-
state.git_ignored = state.filters.respect_gitignore and git.load_ignored(state.path) or {}
153+
if state.filters.respect_gitignore and state.filters.gitignore_source == "git" then
154+
state.git_ignored = git.load_ignored(state.path) or {}
155+
else
156+
state.git_ignored = {}
157+
end
152158
end
153159
do_scan(context, parent_id or state.path)
154160
end

0 commit comments

Comments
 (0)