netrw slow hiding with large number of ignored files

60 views
Skip to first unread message

Matthew Hughes

unread,
Mar 8, 2021, 6:05:58 PM3/8/21
to v...@vim.org
Hi all,

I'm encountering very slow (several seconds to respond) behaviour from
netrw when hiding with netrw_gitignore#Hide() and a large number of
gitignore files. I first noticed it when I pulled the 'git' source,
compiled it, and called '$ vim .' in the root directory. For context
here's a basic .vimrc to demonstrate the behaviour:

set nocp
filetype plugin on
let g:netrw_hide = 1
let g:netrw_list_hide = netrw_gitignore#Hide()

With (using runtime/autoload/netrw_gitignore.vim):

function! netrw_gitignore#Hide(...)
return substitute(substitute(system('git ls-files --other --ignored --exclude-standard --directory'), '\n', ',', 'g'), ',$', '', '')
endfunction

I believe the slowdown is due to the number of ignored files, after
compiling git:

/path/to/src/git$ git ls-files --other --ignored --exclude-standard --directory | wc -l
684

The slowdown is more obvious in a repo with more ignored files, e.g.:

$ git init
$ echo '/foo.*' > .gitignore
$ for i in {1..2000}; do touch "foo.$i"; done
$ vim .

Would there happen to be another way to handle ignoring a list of files
with netrw? netrw_list_hide seems geared towards hiding against a list
of match patterns, rather than explicit filenames

Thanks,
Matt
Reply all
Reply to author
Forward
0 new messages