Skip to content

Instantly share code, notes, and snippets.

@scrooloose

scrooloose/foo.vim

Created Nov 20, 2015
Embed
What would you like to do?
"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
You can’t perform that action at this time.