Skip to content

#1172 add renderer.icons.webdev_colors default true #1175

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 1 commit into from
Apr 18, 2022

Conversation

alex-courtis
Copy link
Member

Closes #1172

Allows user to ignore webdev icon colours, optionally using NvimTreeFileIcon.

An option could have been avoided by detecting :hi NvimTreeFileIcon and using that, however there is no API to do this. Executing :hi NvimTreeFileIcon via pcall is error prone and slow. It also results in false positives as that group is cleared after rendering a non-webdev icon.

Most of this is a refactor. The change is commented.

local icon, hl_group = web_devicons.get_icon(fname, extension)
if not M.config.icons.webdev_colors then
hl_group = "NvimTreeFileIcon"
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the key change.

-- If there are more extensions to the file, try to grab the icon for them recursively
return get_file_icon(fname, string.match(extension, "%.(.*)"), line, depth)
else
return #icon_state.icons.default > 0 and icon_state.icons.default .. icon_padding or ""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been replaced by get_file_icon_default, so that we get the hl group colour on files that do not have a web dev icon.

@Diaoul
Copy link

Diaoul commented Apr 18, 2022

I can confirm it is working.
image

Copy link
Member

@kyazdani42 kyazdani42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm :) small refactoring like this is very welcome too :)

@kyazdani42 kyazdani42 merged commit cdbc210 into master Apr 18, 2022
@kyazdani42 kyazdani42 deleted the #1172-non-coloured-webdev-file-icons branch April 30, 2022 12:33
Almo7aya pushed a commit to Almo7aya/nvim-tree.lua that referenced this pull request Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non colored file icons
3 participants