Skip to content

Commit 67c4fb6

Browse files
committed
fix: explicitly load hidden files in git check-ignore, fixes #226
1 parent 18abb91 commit 67c4fb6

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lua/neo-tree/git/ignored.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ local git_utils = require("neo-tree.git.utils")
55
local M = {}
66
local sep = utils.path_separator
77

8-
M.load_ignored_per_directory = function(path)
8+
local load_ignored_per_directory_internal = function(path, pattern)
99
if type(path) ~= "string" then
1010
log.error("load_ignored_per_directory: path must be a string")
1111
return {}
1212
end
1313
local esc_path = vim.fn.shellescape(path)
14-
local cmd = string.format("git -C %s check-ignore %s%s*", esc_path, esc_path, sep)
14+
local cmd = string.format("git -C %s check-ignore %s%s*", esc_path, esc_path, pattern)
1515
local result = vim.fn.systemlist(cmd)
1616
if vim.v.shell_error == 128 then
1717
if type(result) == "table" then
@@ -37,6 +37,14 @@ M.load_ignored_per_directory = function(path)
3737
return result
3838
end
3939

40+
M.load_ignored_per_directory = function(path)
41+
local ignored = load_ignored_per_directory_internal(path, sep)
42+
-- we need to load hidden separately because I can't find a way to get both in one call
43+
local hidden = load_ignored_per_directory_internal(path, sep .. ".")
44+
vim.list_extend(ignored, hidden)
45+
return ignored
46+
end
47+
4048
M.load_ignored = function(path)
4149
local git_root = git_utils.get_repository_root(path)
4250
if not git_root then

lua/neo-tree/sources/common/file-items.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,16 @@ function create_item(context, path, _type)
9090
if f.never_show[name] then
9191
item.filtered_by = item.filtered_by or {}
9292
item.filtered_by.never_show = true
93-
elseif f.hide_by_name[name] then
93+
end
94+
if f.hide_by_name[name] then
9495
item.filtered_by = item.filtered_by or {}
9596
item.filtered_by.name = true
96-
elseif f.hide_dotfiles and string.sub(name, 1, 1) == "." then
97+
end
98+
if f.hide_dotfiles and string.sub(name, 1, 1) == "." then
9799
item.filtered_by = item.filtered_by or {}
98100
item.filtered_by.dotfiles = true
99-
elseif f.hide_gitignored and utils.truthy(state.git_ignored) then
101+
end
102+
if f.hide_gitignored and utils.truthy(state.git_ignored) then
100103
if git.is_ignored(state.git_ignored, path, _type) then
101104
item.filtered_by = item.filtered_by or {}
102105
item.filtered_by.gitignored = true

0 commit comments

Comments
 (0)