nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slowness when setting update_cwd to true on windows

kishikaisei opened this issue · comments

So the title says it all, for some reason, when I am setting update_cwd to true makes nvim-tree slow, movement, expanding nodes, and the first couple of seconds of opening a file, movement in that file is slow as well (moving up and down for instance, takes a moment to register).

OS: Windows 11 (21H2) (but had the same issue on Windows 10)
NVIM: v0.6.0-dev+156

Settings: nvim-tree.lua

local g   = vim.g
local cmd = vim.cmd

g.nvim_tree_gitignore = 1               -- 0 by default
g.nvim_tree_indent_markers = 0          -- 0 by default, this option shows indent markers when folders are open
g.nvim_tree_git_hl = 1                  -- 0 by default, will enable file highlight for git attributes (can be used without the icons).
g.nvim_tree_highlight_opened_files = 0  -- 0 by default, will enable folder and file icon highlight for opened files/directories.
g.nvim_tree_root_folder_modifier = ':t' -- This is the default. See :help filename-modifiers for more options
g.nvim_tree_add_trailing = 1            -- 0 by default, append a trailing slash to folder names
g.nvim_tree_group_empty = 0             -- 0 by default, compact folders that only contain a single folder into one node in the file tree
g.nvim_tree_disable_window_picker = 0   -- 0 by default, will disable the window picker.
g.nvim_tree_icon_padding = ' '          -- one space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font.
g.nvim_tree_symlink_arrow = ' ➛ '      -- defaults to ' ➛ '. used as a separator between symlinks' source and target.
g.nvim_tree_respect_buf_cwd = 1         -- 0 by default, will change cwd of nvim-tree to that of new buffer's when opening nvim-tree. -- set to 1
g.nvim_tree_create_in_closed_folder = 1 -- 1 by default, When creating files, sets the path of a file when cursor is on a closed folder to the parent folder when 0, and inside the folder when 1.
g.nvim_tree_refresh_wait = 500          -- 1000 by default, control how often the tree can be refreshed, 1000 means the tree can be refresh once per 1000ms.
g.nvim_tree_window_picker_exclude = {
	['filetype'] = {
		'notify',
		'packer',
		'qf'
	},
	['buftype'] = {
		'terminal'
	}
}
-- default shows no icon by default
g.nvim_tree_show_icons = {
  git = 1,
  folders = 1, -- or 0,
  files = 1, -- or 0,
  folder_arrows = 1 -- or 0
}

--  Dictionary of buffer option names mapped to a list of option values that
--  indicates to the window picker that the buffer's window should not be
--  selectable.
--  List of filenames that gets highlighted with NvimTreeSpecialFile
g.nvim_tree_special_files = {
	['README.md'] = 1,
	['Makefile']  = 1,
	['MAKEFILE']  = 1
}

g.nvim_tree_icons = {
  ['default']= '',
  ['symlink']= '',
  ['git']= {
    ['unstaged']  = "○",
    ['staged']    = "●",
    ['unmerged']  = "",
    ['renamed']   = "",
    ['untracked'] = "",
    ['deleted']   = "",
    ['ignored']   = ""
    },
  ['folder']= {
    ['arrow_open']   = "",
    ['arrow_closed'] = "",
    ['default']      = "",
    ['open']         = "",
    ['empty']        = "",
    ['empty_open']   = "",
    ['symlink']      = "",
    ['symlink_open'] = "",
  },
  ['lsp']= {
    ['hint']    = "",
    ['info']    = "",
    ['warning'] = "",
    ['error']   = "",
  }
}

local tree_cb = require'nvim-tree.config'.nvim_tree_callback-- following options are the default
-- each of these are documented in `:help nvim-tree.OPTION_NAME`
require'nvim-tree'.setup {
  disable_netrw       = false,
  hijack_netrw        = false,
  open_on_setup       = false,
  ignore_ft_on_setup  = {},
  auto_close          = true,
  open_on_tab         = false,
  hijack_cursor       = false,
  update_cwd          = true,
  update_to_buf_dir   = {
    enable = true,
    auto_open = true,
  },
  diagnostics = {
    enable = true,
    icons = {
      hint    = "",
      info    = "",
      warning = "",
      error   = "",
    }
  },
  update_focused_file = {
    enable      = true,
    update_cwd  = false,
    ignore_list = {}
  },
  system_open = {
    cmd  = nil,
    args = {}
  },
  filters = {
    dotfiles = true,
    custom = {}
  },
  view = {
    width = 45,
    height = 45,
    hide_root_folder = true,
    side = 'left',
    auto_resize = true,
    mappings = {
      custom_only = false,
      list = {
        { key = "<BS>",                         cb = tree_cb("dir_up") },
        { key = {"q", "<Esc>"},                 cb = tree_cb("close") },
        { key = {"<2-RightMouse>", "<CR>"},     cb = tree_cb("cd") },
        { key = "<Tab>",                        cb = tree_cb("preview") },
        { key = "R",                            cb = tree_cb("refresh") },
        { key = "h",                            cb = tree_cb("close_node") },
        
        { key = "l",                            cb = tree_cb("edit") },
        { key = "v",                            cb = tree_cb("vsplit") },
        { key = "s",                            cb = tree_cb("split") },
        { key = "t",                            cb = tree_cb("tabnew") },
        
        { key = "a",                            cb = tree_cb("create") },
        { key = "d",                            cb = tree_cb("remove") },
        { key = "r",                            cb = tree_cb("rename") },
        { key = "x",                            cb = tree_cb("cut") },
        { key = "c",                            cb = tree_cb("copy") },
        { key = "p",                            cb = tree_cb("paste") },
        
        { key = "G",                           cb = tree_cb("prev_git_item") },
        { key = "g",                           cb = tree_cb("next_git_item") },
        { key = "?",                           cb = tree_cb("toggle_help") },
        
        { key = "<",                            cb = tree_cb("prev_sibling") },
        { key = ">",                            cb = tree_cb("next_sibling") },
        { key = "P",                            cb = tree_cb("parent_node") },
        { key = "K",                            cb = tree_cb("first_sibling") },
        { key = "J",                            cb = tree_cb("last_sibling") },
        { key = "I",                            cb = tree_cb("toggle_ignored") },
        { key = "H",                            cb = tree_cb("toggle_dotfiles") },
        { key = "<C-r>",                        cb = tree_cb("full_rename") },
        { key = "y",                            cb = tree_cb("copy_name") },
        { key = "Y",                            cb = tree_cb("copy_path") },
        { key = "gy",                           cb = tree_cb("copy_absolute_path") },
        { key = "s",                            cb = tree_cb("system_open") },
      }
    }
  }
}

Reproducible with

vim.g.nvim_tree_respect_buf_cwd = 1
require'nvim-tree'.setup {
  update_cwd = true,
}

I have experienced the same of Mac. Commenting out updated_cwd = true has made everything 1000x faster. I am on latest Mac OS X, zsh, tmux, Alacritty, Neovim an nvim-tree.

commented

I cannot test on windows and macos unfortunately. Can you maybe provide more information ?

What more info can we provide? I would love to make this work as smooth as possible.

commented

well i cannot reproduce the slowness on my end, maybe detecting why is it slow, like if it's git that takes time, or the refresh action, or too many events maybe

commented

Is there someone willing to debug this on windows ? Since i've made a lot of changes these last weeks, is this issue still relevant @kishikaisei ?

It seems that it is still slow, and I am not savvy enough to investigate or to profile commands :(

Some profiling has been added #1108

Please wait for merge or use the branch update to latest master then enable logging and profiling via:

		log = {
			enable = true,
			truncate = true,
			types = {
				git = true,
				profile = true,
			},
		},

Please attach the logs along with a description of the operations you were performing, as well as some information around the size of the directories as well as whether they contain git repos.

@kosayoda what are the results of the profiling?

Please update to latest nvim-tree.lua, enable profiling and attach the logs.

@kosayoda what are the results of the profiling?

Please update to latest nvim-tree.lua, enable profiling and attach the logs.

Hello, I think you mentioned the wrong person.

Please accept my apologies @kosayoda

@kishikaisei what are the results of the profiling?

Please update to latest nvim-tree.lua, enable profiling and attach the logs.

I think the issue got resolved, there is still a second delay when expanding folder structure, but once that is cached, it isn't as slow.

commented

still if the first run is slow, we might need to understand why.

still if the first run is slow, we might need to understand why.

Yes. I would be very interested in the logs.

Closing due to inactivity.