-
-
Notifications
You must be signed in to change notification settings - Fork 619
feat: add renderer.highlight_hidden, renderer.icons.show.hidden and renderer.icons.hidden_placement for dotfile icons/highlights #2840
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
feat: add renderer.highlight_hidden, renderer.icons.show.hidden and renderer.icons.hidden_placement for dotfile icons/highlights #2840
Conversation
…th icon and name (this not related to git highlights). Better defaults squashed docs(hidden) docs(hidden) docs(hidden)
… be also a dotfile
These defaults don't stand out very much; the user may think the feature is not working or misconfigured. How about we use -- Hidden
{ group = "NvimTreeHiddenIcon", link = "Conceal" },
{ group = "NvimTreeHiddenFileHL", link = "NvimTreeHiddenIcon" },
{ group = "NvimTreeHiddenFolderHL", link = "NvimTreeHiddenFileHL" }, |
Test cases: highlight_hidden = "none", highlight_hidden = "icon", highlight_hidden = "name", highlight_hidden = "all", hidden_placement = "signcolumn",
show = {
hidden = true, hidden_placement = "before",
show = {
hidden = true, hidden_placement = "after",
show = {
hidden = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great - all working, just some polish needed.
@@ -904,6 +908,13 @@ Requires |nvim-tree.modified.enable| | |||
Value can be `"none"`, `"icon"`, `"name"` or `"all"` | |||
Type: `string`, Default `"none"` | |||
|
|||
*nvim-tree.renderer.highlight_hidden* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please run
make help-update
to add the new entries to the indexes:
https://github.com/nvim-tree/nvim-tree.lua/actions/runs/9958922100/job/27689198158?pr=2840
@@ -442,6 +443,7 @@ function Builder.setup(opts) | |||
DecoratorDiagnostics:new(opts), | |||
DecoratorBookmarks:new(opts), | |||
DecoratorModified:new(opts), | |||
DecoratorHidden:new(opts), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please update
:help nvim-tree.renderer.icons
with this order.
end | ||
-- Inspect(node) | ||
if node.is_dot or (node.name and (node.name:sub(1, 1) == ".")) or M.is_dotfile(node.parent) then | ||
node.is_dot = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
---@param node Node | ||
---@return HighlightedString[]|nil icons | ||
function DecoratorHidden:calculate_icons(node) | ||
if self.enabled and is_dotfile(node) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.enabled and is_dotfile(node) then | |
if self.enabled and node:is_dotfile() then |
You can then remove the require.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated in favor of all sugestions. However, I couldn't use is_dotfile
as a method of node
.
Instead I followed the same style of other decorators by 'requiring' into a variable called explorer_node
and then using explorer_node.is_dotfile(node)
.
Besides that, everything else should be aligned with the change request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I couldn't use
is_dotfile
as a method ofnode
. Instead I followed the same style of other decorators by 'requiring' into a variable calledexplorer_node
and then usingexplorer_node.is_dotfile(node)
.
Right you are; node isn't yet a proper class. Apologies...
}) | ||
---@cast o DecoratorHidden | ||
|
||
if not o.enabled then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This will always be true, we can remove.
lua/nvim-tree/appearance/init.lua
Outdated
-- Hidden | ||
{ group = "NvimTreeHiddenIcon", link = "NvimTreeSignColumn" }, | ||
{ group = "NvimTreeHiddenFileHL", link = "NvimTreeFileName" }, | ||
{ group = "NvimTreeHiddenFolderHL", link = "NvimTreeFolderName" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please add these to help
nvim-tree-highlight-default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Description
This PR introduces the ability to highlight hidden files (dotfiles) by creating three new highlight groups:
It is ensured that if a file has a parent directory that is a dotfile, the file itself is also considered a dotfile. For example, all files within the

.git
or.github
directories are regarded as dotfiles, as below:Backward Compatibility
To ensure backward compatibility, by default:
highlight_hidden
is set to a value other than"none"
.show.hidden
option is set tofalse
by default.Note: This change is not related to highlighting git-ignored files.
Example Setup
Example Result (not generated by the above setup)
Below we show the highlights results produced by

:Inspect
command on a dotfile (hidden folder in this case).