liuchengxu / space-vim

:four_leaf_clover: Lean & mean spacemacs-ish Vim distribution
https://liuchengxu.github.io/space-vim/
MIT License
2.85k stars 255 forks source link

Use glob instead of os.listdir in s:py_init #467

Closed jyscao closed 3 years ago

jyscao commented 3 years ago

Since I began using git to track my personal configuration inside of ~/.space-vim/private/, I'd sometimes run into this weird misbehavior where upon starting $ nvim, it'd be blocked by vim echoing messages like shown in the screenshot below: image

This required me to press enter in order to start using the editor. Functionally it's not a huge deal, but can nonetheless be a bit unpleasant to deal with. And indeed, inside vim, :echo g:spacevim.private showed ['.git'].

The thing that I found really strange was that this problem would only happen occasionally. Upon investigation, it turned to be caused by the slight difference in behavior b/w s:init and s:py_init in the cache.vim script. The former uses globpath to obtain the contents of a given directory, which much like a Unix shell glob, ignores hidden files and dirs; while the latter uses os.listdir, which includes hidden files and dirs as part of its return.

For my purposes of ensuring space-vim ignores the .git directory under private/, it was enough to just do something like: private = [f for f in os.listdir(private_base) if os.path.isdir(os.path.join(private_base, f)) and not f.startswith('.')] (the last conditional checking a file not starting with . would be enough to fix my problem).

But I thought it better to make the behavior of both s:init and s:py_init uniform wrt globbing, hence this PR.

jyscao commented 3 years ago

@liuchengxu gentle ping

And just as a tl;dr, all this change does is to unify file globbing behavior of s:init and s:py_init.

Any suggestions or thoughts?

liuchengxu commented 3 years ago

Merged, thank you!