nvim-tree / nvim-tree/nvim-tree.lua

Cache FileNode Icon And Highlight

Open
#2,984 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance
Dominant language
Lua
Stars
8.6k
Forks
639
Avg merge
1d 14h
Merged PRs (30d)
2

Description

HighlightedString for :highlighted_icon :highlighted_name should not change unless:

  • options change
  • name changes

Options:

  1. Cache these in the Node (preferred)
  2. add a cache around get_icon (will grow large, avoid)

1 is achievable for files as:

  • It doesn't appear that name is set anywhere, hence safe to calculate once during construction.
  • Executable is set once on construction/reload
  • Explorer will be destroyed on config change, clearing cached values

1 is not achievable for directories as the icon changes based on whether the directory is open or grouped.

Plan:

  • Add private members to FileNode that stores the nvim_tree.api.HighlightedString
    • hl_icon
    • hl_name
  • FileNode and FileLinkNode populate members in the constructor, moving logic from:
    • :highlighted_icon
    • :highlighted_name

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the FileNode and FileLinkNode constructors and the highlighted_icon and highlighted_name implementations. Trace how highlighted values are currently produced for files and directories, then verify the intended cache lifetime against option changes, name changes, executable reloads, and directory state. Done means file values are reused while directory highlighting remains dynamic.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
performance
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.