nerdtree
nerdtree copied to clipboard
Please improve the performance.
Description
My folder has about 2k-3k files. When refreshing, it's very flow, taking about 4-5 seconds (on Windows OS). The refreshing appears to be a sync func. Etc during the refresh, whole vim get freezed, which makes auto fresh unusable, https://superuser.com/questions/1141994/autorefresh-nerdtree.
Also when expanding for the 1st time, it's very slow too.
Other plugin, such https://github.com/lambdalisue/fern.vim, is much faster (on Windows OS)
- Is it possible to improve the perf?
- Is it possible to change the sync mode to async? At least, the vim will not be freezed during the refresh.
Thanks.
@jinleileiking interesting results, May I ask what other plugins are there in your config other than NERDTree? For example vim-devicons or the nerdtree-git-plugin? and may I have your profiling options?
This call takes a bunch of time because of being in a loop and getting called for every child node, I suspect that the actual bulk of the work happens in this line in the lib/nerdtree/path.vim line 664:
" FUNCTION: Path.refreshFlags(nerdtree) {{{1
function! s:Path.refreshFlags(nerdtree)
call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, a:nerdtree, {})
call self.cacheDisplayString()
endfunction
Call to the refreshFlags listeners is for third-party plugins, for example, vim-devicons and nerdtree-git-plugin which update their internal state via this event. So the cost of each extra plugin is O(n).
You can also try using #1362, Setting g:NerdTreeLazyDirRefresh to 1 enables the lazy refresh functionality. In this mode, we don't refresh closed directories, We just mark them as dirty and refresh them once it is necessary.
Plug 'PhilRunninger/nerdtree-buffer-ops'
It seems this plugin cost a lot of CPU. I disable this plugin, works well
@jinleileiking I'm happy to hear that you've found the issue, Since it probably wasn't the original author's problem I'll leave this open.