add a path filter API
Add an API to allow custom "path filter callbacks" to be added. Previously we allowed one path filtering function to exist called `NERDTreeCustomIgnoreFilter`. This has been removed and replaced with an API to allow any number of such functions to exist - via the new `NERDTreeAddPathFilter()`
This commit is contained in:
parent
09e1dbec10
commit
64a9579c11
@ -3,6 +3,11 @@
|
|||||||
let s:NERDTree = {}
|
let s:NERDTree = {}
|
||||||
let g:NERDTree = s:NERDTree
|
let g:NERDTree = s:NERDTree
|
||||||
|
|
||||||
|
"FUNCTION: s:NERDTree.AddPathFilter() {{{1
|
||||||
|
function! s:NERDTree.AddPathFilter(callback)
|
||||||
|
call add(s:NERDTree.PathFilters(), a:callback)
|
||||||
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:NERDTree.Close() {{{1
|
"FUNCTION: s:NERDTree.Close() {{{1
|
||||||
"Closes the primary NERD tree window for this tab
|
"Closes the primary NERD tree window for this tab
|
||||||
function! s:NERDTree.Close()
|
function! s:NERDTree.Close()
|
||||||
@ -116,6 +121,15 @@ function! s:NERDTree.New(path)
|
|||||||
return newObj
|
return newObj
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: s:NERDTree.PathFilters() {{{1
|
||||||
|
function! s:NERDTree.PathFilters()
|
||||||
|
if !exists('s:NERDTree._PathFilters')
|
||||||
|
let s:NERDTree._PathFilters = []
|
||||||
|
endif
|
||||||
|
return s:NERDTree._PathFilters
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
"FUNCTION: s:NERDTree.render() {{{1
|
"FUNCTION: s:NERDTree.render() {{{1
|
||||||
"A convenience function - since this is called often
|
"A convenience function - since this is called often
|
||||||
function! s:NERDTree.render()
|
function! s:NERDTree.render()
|
||||||
|
@ -392,6 +392,12 @@ function! s:Path.ignore()
|
|||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
for callback in g:NERDTree.PathFilters()
|
||||||
|
if {callback}({'path': self, 'nerdtree': b:NERDTree})
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"dont show hidden files unless instructed to
|
"dont show hidden files unless instructed to
|
||||||
@ -403,10 +409,6 @@ function! s:Path.ignore()
|
|||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists("*NERDTreeCustomIgnoreFilter") && NERDTreeCustomIgnoreFilter(self)
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -196,6 +196,11 @@ function! NERDTreeCWD()
|
|||||||
call NERDTreeFocus()
|
call NERDTreeFocus()
|
||||||
call nerdtree#ui_glue#chRootCwd()
|
call nerdtree#ui_glue#chRootCwd()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! NERDTreeAddPathFilter(callback)
|
||||||
|
call g:NERDTree.AddPathFilter(a:callback)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" SECTION: Post Source Actions {{{1
|
" SECTION: Post Source Actions {{{1
|
||||||
call nerdtree#postSourceActions()
|
call nerdtree#postSourceActions()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user