Skip to content

#3231 step 1: Move non-setup functions from nvim-tree.lua to another module #3253

@alex-courtis

Description

@alex-courtis

Part of #3231 : Performance: Load Only Necessary Modules On setup and requiring API

Description

nvim-tree.lua Move all functions that do not relate to setup into another module.

Context

User requiring api.lua or executing setup results in most modules being required. This has a cost ~7-11ms.

This step involves moving functions that are not related to setup out of the main nvim-tree.lua module to reduce initial load time.

Notes

  • This is not API so we may refactor at will
  • Should be broken down into small changes to ameliorate risk and allow fast rollback
  • Functions should be moved to core.lua. If that is not possible, create a new module internal.lua
  • This does not advance Multi Instance - Contributors Wanted - Please Take An Issue #2255, we are just moving functions that need to be addressed later

Implementation Plan

  • Move M.change_root
  • Move M.tab_enter
  • Move M.open_on_directory
  • Move M.change_dir

Draft Test Plan, May Be Incomplete

  • Test change_root (update_focused_file functionality)

    • Open nvim-tree
    • Navigate to different files outside the current root
    • Verify that tree root updates correctly based on update_focused_file config
  • Test tab_enter (TabEnter autocmd)

    • Open nvim-tree in one tab
    • Create new tabs and switch between them
    • Verify nvim-tree appears correctly when entering tabs
  • Test open_on_directory (BufEnter/BufNewFile autocmd)

    • Open nvim with a directory path (nvim .)
    • Verify nvim-tree opens automatically based on hijack_directories config
  • Test change_dir (DirChanged autocmd)

    • Use :cd to change directories
    • Verify nvim-tree updates its root accordingly
    • Test with actions.change_dir config options

Metadata

Metadata

Assignees

No one assigned

    Labels

    PR pleasenvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciatedperformanceperformance enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions