I was wondering if there is a way to get vim to read .gitignore files and use them to determine options not to present when auto-completing filenames.
For example, working in python, I’d like to not see .pyc files offered for editing. I think vim has its own mechanism for this, I was wondering how to load information from .gitignore into it.
As suggested by @dwc, here’s a vim script:
Take that source and put it in a file in your plugin directory, such as
~/.vim/plugin/gitignore.vim. It will read your.gitignorefile and parse it, transforming its format into one suitable forwildignore, and then set that option.Limitations:
.gitignorefile from the directory where you launch vim. No effort is made to look for other.gitignorefiles and parse them. Alternatively, you could specify an absolute path to a file on the first line.wildignoreoption in vim doesn’t support the notion of negating ignores like you can in a.gitignorefile. That is, you can’t say:set wildignore=*.html,!foo.htmlto have it ignore all html files exceptfoo.html. Therefore,.gitignorelines that start with ! are simply ignored.