Skip to content

nvim-tree.git.utils has_cygpath executable check takes ~200ms #2459

Closed
@jtledon

Description

@jtledon

Description

nvim-tree takes roughly 200ms to start.
I have narrowed the issue down to a specific executable check in nvim-tree.git.utils, on line 5:
local has_cygpath = vim.fn.executable "cygpath" == 1

setup.git.enable = false does not resolve the issue

Im wondering if it has something to do with how long it takes to complete to complete external commands in WSL.
I would love to see an additional option that would allow me to disable this check, and default it to 0.

nvt-startuptime.mp4

Neovim version

NVIM v0.9.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Operating system and version

Windows 10 Vesion 22H2 OS Build 19045.3448 - WSL2 - Ubuntu 22.04.3 LTS

nvim-tree version

53b0bca

Clean room replication

Clean room replication:
I was unable to even see nvim-tree in the startup logs when using the cleanroom replication. If there is something I am doing wrong, please let me know and I can update my Issue.
Command I used: `nvim -n -u nvt-min.lua --startuptime time.log test.txt`

nvt-min.lua:

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup {
    {
      "wbthomason/packer.nvim",
      "nvim-tree/nvim-tree.lua",
      "nvim-tree/nvim-web-devicons",
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
      "dstein64/vim-startuptime",
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  }
end
if vim.fn.isdirectory(install_path) == 0 then
  print "Installing nvim-tree and dependencies."
  vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true
vim.opt.cursorline = true

-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
  require("nvim-tree").setup({
            git = {
                enable = false,
            },
            renderer = {
                icons = {
                    glyphs = {
                        git = {
                            unstaged = "!",
                            staged = "+",
                            unmerged = "^",
                            renamed = "#",
                            untracked = "?",
                            deleted = "d",
                            ignored = "-",
                        },
                    },
                },
            },
            filters = {
                git_ignored = false,
            },

            actions = {
                open_file = {
                    quit_on_open = true,
                    window_picker = {
                        enable = false,
                    },
                },
                expand_all = {
                    exclude = { ".git", "target", "build", "node_modules" },
                },
            },

            view = {
                width = {
                    min = 15,
                    max = 45,
                },
            },
            log = {
                enable = true,
                truncate = true,
                types = {
                    diagnostics = true,
                    git = true,
                    profile = true,
                    watcher = true,
                },
            },
        })
end


Profile logs:
[2023-10-08 21:36:42] [profile] START change dir /home/jl/.dotfiles/.nvim
[2023-10-08 21:36:42] [profile] START core init /home/jl/.dotfiles/.nvim
[2023-10-08 21:36:42] [watcher] Watcher:new '/home/jl/.dotfiles/.nvim' nil
[2023-10-08 21:36:42] [watcher] Event:new '/home/jl/.dotfiles/.nvim'
[2023-10-08 21:36:42] [watcher] Event:start '/home/jl/.dotfiles/.nvim'
[2023-10-08 21:36:42] [profile] START git toplevel git_dir /home/jl/.dotfiles/.nvim
[2023-10-08 21:36:42] [git] git -C /home/jl/.dotfiles/.nvim rev-parse --show-toplevel --absolute-git-dir
/home/jl/.dotfiles
/home/jl/.dotfiles/.git
[2023-10-08 21:36:42] [profile] END   git toplevel git_dir /home/jl/.dotfiles/.nvim 1ms
[2023-10-08 21:36:42] [profile] START git untracked /home/jl/.dotfiles
[2023-10-08 21:36:42] [git] git -C /home/jl/.dotfiles config status.showUntrackedFiles
[2023-10-08 21:36:42] [profile] END   git untracked /home/jl/.dotfiles 1ms
[2023-10-08 21:36:42] [profile] START git sync job /home/jl/.dotfiles nil
[2023-10-08 21:36:42] [git] running job with timeout 400ms
[2023-10-08 21:36:42] [git] git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u
 M .bash/.bashrc
 M .nvim/lua/ledon/plugins/nvim-tree.lua
!! .history/
[2023-10-08 21:36:42] [git] done
[2023-10-08 21:36:42] [profile] END   git sync job /home/jl/.dotfiles nil 57ms
[2023-10-08 21:36:42] [git] job success    /home/jl/.dotfiles nil
[2023-10-08 21:36:42] [watcher] git start
[2023-10-08 21:36:42] [watcher] Watcher:new '/home/jl/.dotfiles/.git' { "FETCH_HEAD", "HEAD", "HEAD.lock", "config", "index" }
[2023-10-08 21:36:42] [watcher] Event:new '/home/jl/.dotfiles/.git'
[2023-10-08 21:36:42] [watcher] Event:start '/home/jl/.dotfiles/.git'
[2023-10-08 21:36:42] [profile] START explore init /home/jl/.dotfiles/.nvim
[2023-10-08 21:36:42] [profile] START explore populate_children /home/jl/.dotfiles/.nvim/HowToBuildNvimManutally.txt
[2023-10-08 21:36:42] [profile] END   explore populate_children /home/jl/.dotfiles/.nvim/HowToBuildNvimManutally.txt 0ms
[2023-10-08 21:36:42] [profile] START explore populate_children /home/jl/.dotfiles/.nvim/README.md
[2023-10-08 21:36:42] [profile] END   explore populate_children /home/jl/.dotfiles/.nvim/README.md 0ms
[2023-10-08 21:36:42] [profile] START explore populate_children /home/jl/.dotfiles/.nvim/after
[2023-10-08 21:36:42] [watcher] Watcher:new '/home/jl/.dotfiles/.nvim/after' nil
[2023-10-08 21:36:42] [watcher] Event:new '/home/jl/.dotfiles/.nvim/after'
[2023-10-08 21:36:42] [watcher] Event:start '/home/jl/.dotfiles/.nvim/after'
[2023-10-08 21:36:42] [profile] END   explore populate_children /home/jl/.dotfiles/.nvim/after 0ms
[2023-10-08 21:36:42] [profile] START explore populate_children /home/jl/.dotfiles/.nvim/ftdetect
[2023-10-08 21:36:42] [watcher] Watcher:new '/home/jl/.dotfiles/.nvim/ftdetect' nil
[2023-10-08 21:36:42] [watcher] Event:new '/home/jl/.dotfiles/.nvim/ftdetect'
[2023-10-08 21:36:42] [watcher] Event:start '/home/jl/.dotfiles/.nvim/ftdetect'
[2023-10-08 21:36:42] [profile] END   explore populate_children /home/jl/.dotfiles/.nvim/ftdetect 0ms
[2023-10-08 21:36:42] [profile] START explore populate_children /home/jl/.dotfiles/.nvim/init.lua
[2023-10-08 21:36:42] [profile] END   explore populate_children /home/jl/.dotfiles/.nvim/init.lua 0ms
[2023-10-08 21:36:42] [profile] START explore populate_children /home/jl/.dotfiles/.nvim/lazy-lock.json
[2023-10-08 21:36:42] [profile] END   explore populate_children /home/jl/.dotfiles/.nvim/lazy-lock.json 0ms
[2023-10-08 21:36:42] [profile] START explore populate_children /home/jl/.dotfiles/.nvim/lua
[2023-10-08 21:36:42] [watcher] Watcher:new '/home/jl/.dotfiles/.nvim/lua' nil
[2023-10-08 21:36:42] [watcher] Event:new '/home/jl/.dotfiles/.nvim/lua'
[2023-10-08 21:36:42] [watcher] Event:start '/home/jl/.dotfiles/.nvim/lua'
[2023-10-08 21:36:42] [profile] END   explore populate_children /home/jl/.dotfiles/.nvim/lua 0ms
[2023-10-08 21:36:42] [profile] END   explore init /home/jl/.dotfiles/.nvim 0ms
[2023-10-08 21:36:42] [profile] END   core init /home/jl/.dotfiles/.nvim 61ms
[2023-10-08 21:36:42] [profile] START draw
[2023-10-08 21:36:42] [profile] END   draw 0ms
[2023-10-08 21:36:42] [profile] END   change dir /home/jl/.dotfiles/.nvim 67ms

Steps to reproduce

Opening neovim

Expected behavior

nvim-tree would have a minimal startup time

Actual behavior

nvim-tree has a significant startup time, far longer than anything else in my neovim config

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions