Skip to content

feat(#2225): add renderer.hidden_display to show a summary of hidden files below the tree #2856

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 18 commits into from
Aug 10, 2024

Conversation

evertonse
Copy link
Collaborator

@evertonse evertonse commented Jul 28, 2024

This PR introduces the rendering of hidden count files per folder, a feature that closes #2225

Option renderer.hidden_display, allows users to customize how hidden files count information are displayed per folder.
It can be either a function or a string. It defaults to "none".

  • "none": Doesn't inform anything about hidden files.
  • "simple": Shows how many hidden files are in a folder.
  • "all": Shows how many files are hidden and the number of hidden files per reason why they're hidden.

Video for Ilustration

The video below show that we can trace the reason for exclusion. Also, shows that it works with live filter and takes into account indent marks and indent width.

2024-07-28.03-00-47.mp4

If a function is provided to renderer.hidden_display, it receives a table hidden_count where keys are reasons and values are the count of hidden files for that reason.

hidden_count = {
  bookmark = <num>,
  buf = <num>,
  custom = <num>,
  dotfile = <num>,
  git = <num>,
  live_filter = <num>,
}

If an error occurs inside this function, we issue a warning:

2024-07-28.03-21-48.mp4

Also exposes the highlight "NvimTreeHiddenDisplay".

Minimal Setup

Setup using custom function

require('nvim-tree').setup {
  renderer = {
    -- hidden_display = 'all',
    hidden_display = function(hidden_count)
      local total_count = 0
      for reason, count in pairs(hidden_count) do
        total_count = total_count + count
      end

      if total_count > 0 then
        return '> ' .. tostring(total_count) .. ' le hidden'
      end
      return nil
    end,
  },
}

evertonse and others added 10 commits July 14, 2024 00:13
… using ext_marks nvim api

feat(icon_placement): Allow right_align icon_placemente for decorator using ext_marks nvim api
…lacement (nvim-tree#2846)

* feat(icon_placement): Allow right_align icon_placemente for decorator using ext_marks nvim api

* feat(icon_placement): Allow right_align icon_placemente for decorator using ext_marks nvim api

feat(icon_placement): Allow right_align icon_placemente for decorator using ext_marks nvim api

* feat(icon_placement): consolidate doc

* fix: extra namespace added to avoid colision between right_align and full_name features

* style: rename namespace_id

---------

Co-authored-by: Alexander Courtis <[email protected]>
@evertonse evertonse force-pushed the feat/hidden_display branch from 737e3a4 to 7021848 Compare July 28, 2024 06:41
@evertonse evertonse force-pushed the feat/hidden_display branch from 7296c8e to 8ef7e48 Compare July 28, 2024 07:16
@evertonse evertonse changed the title feat(#2225): Add renderer Hidden Count Display functionality feat(#2225): add renderer Hidden Count Display functionality Jul 28, 2024
@evertonse evertonse marked this pull request as draft July 28, 2024 07:34
@evertonse
Copy link
Collaborator Author

evertonse commented Jul 28, 2024

DRAFT: Because there's an ordering problem when sorting by depth. Should be usable but I'll try and fix this tomorrow and set it to ready for review.

edit: fixed and simplified, ready for review

@evertonse evertonse marked this pull request as ready for review July 28, 2024 20:29
@evertonse evertonse changed the title feat(#2225): add renderer Hidden Count Display functionality feat(#2225): add renderer Hidden Count Info display functionality Jul 28, 2024
@evertonse evertonse changed the title feat(#2225): add renderer Hidden Count Info display functionality feat(#2225): add rendering of Hidden Count Info display functionality Jul 28, 2024
@evertonse evertonse changed the title feat(#2225): add rendering of Hidden Count Info display functionality feat(#2225): add Hidden Count Info display functionality Jul 28, 2024
Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

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

This is just fantastic! It works, code looks good from a high level, I trust it's solid.

Small nits and codestyle, check etc. needed.

@alex-courtis
Copy link
Member

This opens up the door to an inline hidden count, like the size information. For another day.

Co-authored-by: Alexander Courtis <[email protected]>
@evertonse
Copy link
Collaborator Author

This opens up the door to an inline hidden count, like the size information. For another day.

I thought the same.

@evertonse
Copy link
Collaborator Author

Fixed code style and added a separate namespace for virtual lines.

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

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

Many thanks for your contribution!

@alex-courtis alex-courtis changed the title feat(#2225): add Hidden Count Info display functionality feat(#2225): add renderer.hidden_display to show a summary of hidden files below the tree Aug 10, 2024
@alex-courtis alex-courtis merged commit e25eb7f into nvim-tree:master Aug 10, 2024
6 checks passed
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.

Hidden Item Count
2 participants