add dir and file flags to NERDTreeIgnore regexes

This allows users to specify whether each regex in NERDTreeIgnore should
apply to only files or only dirs.
This commit is contained in:
Martin Grenfell 2012-01-05 11:41:51 +00:00
parent 4337022524
commit 54fab2f2e5
2 changed files with 29 additions and 4 deletions

View File

@ -780,6 +780,14 @@ For example if you put the following line in your vimrc: >
<
then all files ending in .vim or ~ will be ignored.
There are 2 magic flags that can be appended to the end of each regular
expression to specify that the regex should match only files or only dirs.
These flags are "[[dir]]" and "[[file]]". Example: >
let NERDTreeIgnore=['.d$[[dir]]', '.o$[[file]]']
<
This will cause all dirs ending in ".d" to be ignored and all files ending in
".o" to be ignored.
Note: to tell the NERD tree not to ignore any files you must use the following
line: >
let NERDTreeIgnore=[]
@ -1129,6 +1137,7 @@ The latest dev versions are on github
Next
- add 'scope' argument to the key map API
- add NERDTreeCustomIgnoreFilter hook - needs doc
- add magic [[dir]] and [[file]] flags to NERDTreeIgnore
4.2.0
- Add NERDTreeDirArrows option to make the UI use pretty arrow chars

View File

@ -2291,19 +2291,17 @@ endfunction
"FUNCTION: Path.ignore() {{{3
"returns true if this path should be ignored
function! s:Path.ignore()
let lastPathComponent = self.getLastPathComponent(0)
"filter out the user specified paths to ignore
if b:NERDTreeIgnoreEnabled
for i in g:NERDTreeIgnore
if lastPathComponent =~# i
if self._ignorePatternMatches(i)
return 1
endif
endfor
endif
"dont show hidden files unless instructed to
if b:NERDTreeShowHidden ==# 0 && lastPathComponent =~# '^\.'
if b:NERDTreeShowHidden ==# 0 && self.getLastPathComponent(0) =~# '^\.'
return 1
endif
@ -2318,6 +2316,24 @@ function! s:Path.ignore()
return 0
endfunction
"FUNCTION: Path._ignorePatternMatches(pattern) {{{3
"returns true if this path matches the given ignore pattern
function! s:Path._ignorePatternMatches(pattern)
let pat = a:pattern
if strpart(pat,len(pat)-7) == '[[dir]]'
if !self.isDirectory
return 0
endif
let pat = strpart(pat,0, len(pat)-7)
elseif strpart(pat,len(pat)-8) == '[[file]]'
if self.isDirectory
return 0
endif
let pat = strpart(pat,0, len(pat)-8)
endif
return self.getLastPathComponent(0) =~# pat
endfunction
"FUNCTION: Path.isUnder(path) {{{3
"return 1 if this path is somewhere under the given path in the filesystem.
"