Skip to content

Instantly share code, notes, and snippets.

@scrooloose
Created November 20, 2015 23:15
Show Gist options
  • Save scrooloose/f832454871d6bcfb52a4 to your computer and use it in GitHub Desktop.
Save scrooloose/f832454871d6bcfb52a4 to your computer and use it in GitHub Desktop.
"project dir filtering for nerdtree (stick in vimrc)
autocmd vimenter * call s:setupPathFilter()
function! s:setupPathFilter() abort
call NERDTreeAddPathFilter("ProjectPathFilter")
let baseDir = "/home/marty/work/playmob/charity_portal/website"
let s:proj = { 'root': g:NERDTreePath.New(baseDir) }
let s:proj['visibleDirs'] = [
\ g:NERDTreePath.New(baseDir . "/public/system/"),
\ g:NERDTreePath.New(baseDir . "/app/views/layouts/") ]
endfunction
function! ProjectPathFilter(params) abort
"bail if not inside the project in question
if !a:params['nerdtree'].getRoot().path.equals(s:proj['root'])
return 0
endif
let p = a:params['path']
for dir in s:proj['visibleDirs']
if p.isUnder(dir) || p.isAncestor(dir)
return 0
endif
endfor
return 1
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment