Nerdtree: Add option to ignore files in VCS ignore file (.gitignore)

Created on 20 Aug 2014  路  17Comments  路  Source: preservim/nerdtree

See the gitignore plugin, which removes files in .gitignore from vim auto complete.

Ideally, NERD tree would read ~/.gitignore_global and any .gitignore file in the current tree root and use this along with whatever is set in NERDTreeIgnore to hide ignored files.

Most helpful comment

Gentlemen,

I have added an API to add custom path filters. In the add_path_filter_api branch here 64a9579c11b63e2fe0242d45ca12455a7a7d2833

I have also created a minimal gitignore filter here: https://gist.github.com/scrooloose/0cdccd1171891caf0e24. This is just a proof of concept really. There are several things missing:

  • We only check for a .gitignore in the nerdtree root
  • We cache the .gitignore content forever - so you have to restart vim if you edit the gitignore file
  • ...

The filter takes a .gitignore and converts it into a regex to match filenames against. It is highly possible that there are cases/syntax that I'm not handling.

Checkout that branch, and chuck that gist file in ~/.vim/nerdtree_plugin/gitignore_filter.vim. Let me know how it goes.

Disclaimer: Its saturday night and I wrote all this code while drinking rum

All 17 comments

:+1:

:thumbsup:
reading the svn ignore list if inside an svn checkout would be cool too.

:+1:

+1

+1

:+1:

:+1:

Gentlemen,

I have added an API to add custom path filters. In the add_path_filter_api branch here 64a9579c11b63e2fe0242d45ca12455a7a7d2833

I have also created a minimal gitignore filter here: https://gist.github.com/scrooloose/0cdccd1171891caf0e24. This is just a proof of concept really. There are several things missing:

  • We only check for a .gitignore in the nerdtree root
  • We cache the .gitignore content forever - so you have to restart vim if you edit the gitignore file
  • ...

The filter takes a .gitignore and converts it into a regex to match filenames against. It is highly possible that there are cases/syntax that I'm not handling.

Checkout that branch, and chuck that gist file in ~/.vim/nerdtree_plugin/gitignore_filter.vim. Let me know how it goes.

Disclaimer: Its saturday night and I wrote all this code while drinking rum

You have an implementation on

https://github.com/scrooloose/nerdtree/pull/443

about ignore files untouched

Adding another evaluator tied to "ignore" event you can ignore files ignored by .gititgnore, .git/info/exclude or whatever.

Indeed, is the next evaluator I'm thinking to implement.

To go further, maybe FileFilter toggle can be refined to activate/deactivate evaluators

  • (fs) toggle filter status
  • (fe) toggle filter exclusions

"s" and "e" will be part of evaluator definition passed on AddEvaluator()

@albfan I am confused. Did you see my comment above yours? We have done almost the same work. I have merged the branch mentioned above into master.

In my comment I also made a start on a gitignore filter. Feel free to take this - this filter is not something I plan to use so I'm probably not the best to maintain it.

I have not made a distinction between path filters (which are what you called Evaluators) and the NERDTreeIgnore option - i.e. the f mapping will disable/enable both.

It was simply a slightly different approach, but it is easily converted to your work. Now it is on master I will rework both plugins (ignore and status)

You can see toggle shorcuts for ignore filters in action in #447. If not defined It simply works as you say

Since this issue is closed, and it looks like @scrooloose merged the functionality based on his comments above, how do you enable the feature in NERDTree?

Opps! All my comments refer to rebased code non existing anymore.

To answer @nhooey, this functionality is for internal NERDTree API. It is intented for thirdparty nerdtree plugins.

e.g: If you can ignore custom keymapping help:

https://github.com/albfan/nerdtree/commit/e9b690723b942db378d3a53b455f37db442b09b0

Here is an working implementation:
https://github.com/albfan/nerdtree-git-plugin/commit/b86c11e8c4adc4e40fa444c21fe3b07075b7b351

which toggle ignore:

  • git exclude files
  • git ignore files
  • git untouched files

Try it with Vundle:

Plugin albfan/nerdtree
Plugin albfan/nerdtree-git-plugin

+1 @albfan 鈥斅爕ou are a lifesaver!

Good to know! I can't live without hide untouched files on NERDTree.

Same here. That's been one of my vim killers!

Was this page helpful?
0 / 5 - 0 ratings