Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,15 @@ require("neo-tree").setup({
-- then these will never be used.
default = "*",
highlight = "NeoTreeFileIcon",
use_filtered_colors = true, -- Whether to use a different highlight when the file is filtered (hidden, dotfile, etc.).
},
modified = {
symbol = "[+]",
highlight = "NeoTreeModified",
},
name = {
trailing_slash = false,
use_filtered_colors = true, -- Whether to use a different highlight when the file is filtered (hidden, dotfile, etc.).
use_git_status_colors = true,
highlight = "NeoTreeFileName",
},
Expand Down
2 changes: 2 additions & 0 deletions lua/neo-tree/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ local config = {
folder_open = "",
folder_empty = "󰉖",
folder_empty_open = "󰷏",
use_filtered_colors = false, -- Whether to use a different highlight when the file is filtered (hidden, dotfile, etc.).
-- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
-- then these will never be used.
default = "*",
Expand All @@ -237,6 +238,7 @@ local config = {
-- Take values in { false (no highlight), true (only loaded),
-- "all" (both loaded and unloaded)}. For more information,
-- see the `show_unloaded` config of the `buffers` source.
use_filtered_colors = true, -- Whether to use a different highlight when the file is filtered (hidden, dotfile, etc.).
use_git_status_colors = true,
highlight = "NeoTreeFileName",
},
Expand Down
15 changes: 10 additions & 5 deletions lua/neo-tree/sources/common/components.lua
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ end
---@field folder_empty_open string The icon to display to represent an empty but open folder.
---@field folder_open string The icon to display for an open folder.
---@field folder_closed string The icon to display for a closed folder.
---@field use_filtered_colors boolean Whether to use the same highlight as filtered_by when the item is filtered.
---@field provider neotree.IconProvider?

---@param config neotree.Component.Common.Icon
Expand All @@ -412,10 +413,11 @@ M.icon = function(config, node, state)
icon = config.provider(icon, node, state) or icon
end

local filtered_by = M.filtered_by(config, node, state)

icon.text = icon.text .. " " -- add padding
icon.highlight = filtered_by.highlight or icon.highlight -- prioritize filtered highlighting
if config.use_filtered_colors then
local filtered_by = M.filtered_by(config, node, state)
icon.highlight = filtered_by.highlight or icon.highlight -- prioritize filtered highlighting
end

return icon
end
Expand Down Expand Up @@ -443,6 +445,7 @@ end
---@field [1] "name"?
---@field trailing_slash boolean?
---@field use_git_status_colors boolean?
---@field use_filtered_colors boolean? Whether to use the same highlight as filtered_by when the item is filtered.
---@field highlight_opened_files boolean|"all"?
---@field right_padding integer?

Expand All @@ -464,8 +467,10 @@ M.name = function(config, node, state)
text = text .. " " .. icon
end
else
local filtered_by = M.filtered_by(config, node, state)
highlight = filtered_by.highlight or highlight
if config.use_filtered_colors then
local filtered_by = M.filtered_by(config, node, state)
highlight = filtered_by.highlight or highlight
end
if config.use_git_status_colors then
local git_status = state.components.git_status({}, node, state)
if git_status and git_status.highlight then
Expand Down
Loading