Skip to content

feat(#2369): Add webdev_colors_folder option #2375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
},
icons = {
webdev_colors = true,
webdev_colors_folder = false,
git_placement = "before",
modified_placement = "after",
padding = " ",
Expand Down
5 changes: 2 additions & 3 deletions lua/nvim-tree/renderer/builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,10 @@ end
---@return HighlightedString icon, HighlightedString name
function Builder:_build_folder(node)
local has_children = #node.nodes ~= 0 or node.has_children
local icon = icons.get_folder_icon(node.open, node.link_to ~= nil, has_children)
local icon, icon_hl = icons.get_folder_icon(node, has_children)
local foldername = get_folder_name(node) .. self.trailing_slash

local icon_hl
if #icon > 0 then
if #icon > 0 and icon_hl == nil then
if node.open then
icon_hl = "NvimTreeOpenedFolderIcon"
else
Expand Down
16 changes: 12 additions & 4 deletions lua/nvim-tree/renderer/components/icons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ local function empty()
return ""
end

local function get_folder_icon(open, is_symlink, has_children)
local function get_folder_icon(node, has_children)
if M.config.webdev_colors_folder then
local icon, icon_hl = M.devicons.get_icon(node.name, node.extension)
if icon ~= nil then
return icon, icon_hl
end
end

local is_symlink = node.links_to ~= nil
local n
if is_symlink and open then
if is_symlink and node.open then
n = M.config.glyphs.folder.symlink_open
elseif is_symlink then
n = M.config.glyphs.folder.symlink
elseif open then
elseif node.open then
if has_children then
n = M.config.glyphs.folder.open
else
Expand All @@ -28,7 +36,7 @@ local function get_folder_icon(open, is_symlink, has_children)
n = M.config.glyphs.folder.empty
end
end
return n
return n, nil
end

local function get_file_icon_default()
Expand Down