nvim-tree.lua icon indicating copy to clipboard operation
nvim-tree.lua copied to clipboard

feat(show_file_size): optionally show Size Information on right column

Open evertonse opened this issue 1 year ago • 4 comments

Description

This PR make nvim-tree be able to display file size information as a decoration. It uses newly introduced right_align feature to create a column that shows size info. It allows to customization options to display file sizes in a human-readable format (e.g., MB, GB). It also exposes the highlight group NvimTreeFileSize.

Showcase

image

Setup:

require'nvim-tree'.setup {
  renderer = {
    size = {
      enable = true,
      column_width = 12, -- max chars allowed to fill the column
      show_folder_size = false,
      format_unit = "double", -- or "single" or a custom function
    }
  }
}

Improvements that could be made:

  • Conditionally show file size information based on the current nvim-tree width in both floating and normal views.

EDIT: This improvement were made. We now support conditionally hiding size information based on current width and width cutoff setting as shown below.

https://github.com/user-attachments/assets/b22469a0-c021-415d-8088-44dafd7b8948

The hiding is decently fast because it only does a partial redraw of extra marks as opposed to reloading the whole tree everytime the cutoff is triggered.

evertonse avatar Jul 30 '24 07:07 evertonse

This looks great; I'm limited by time however I will get to it.

alex-courtis avatar Aug 03 '24 07:08 alex-courtis

Looks like we might need special handling for dotted files:

20240804_151418

alex-courtis avatar Aug 04 '24 05:08 alex-courtis

Looks like some inconsistency around right_align icons. Every icon right:

Bookmarks go far far right for dotfiles unless there's another icon. They lose the final character of the name, in this case bookmarking .clang-format will remove the t.

20240804_153638

alex-courtis avatar Aug 04 '24 05:08 alex-courtis

This is looking fantastic! You are quite the prolific contributor...

A few bugs, some option tweaking and this should be good.

I'll dogfood this foor a week.

Ty, ty. I'll find some time this week to get to those bugs.

evertonse avatar Aug 04 '24 08:08 evertonse

Closing as this PR is stale. Please reopen if you wish to continue this work.

alex-courtis avatar Jan 27 '25 00:01 alex-courtis