mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
add some class methods to wrap the NERDTreeCreator public methods
This is needed because some versions of vim dont let you chain method calls together. So do the work in NERDTreeCreator instead of forcing all callers to break the New().createXXX() calls out onto 2 lines with an intermediate variable. Fixes #226.
This commit is contained in:
@@ -149,11 +149,11 @@ runtime plugin/nerdtree/creator.vim
|
||||
" SECTION: Commands {{{1
|
||||
"============================================================
|
||||
"init the command that users start the nerd tree with
|
||||
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.New().createPrimary('<args>')
|
||||
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.New().togglePrimary('<args>')
|
||||
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('<args>')
|
||||
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('<args>')
|
||||
command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen()
|
||||
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.New().createPrimary('<args>')
|
||||
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.New().createMirror()
|
||||
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('<args>')
|
||||
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
|
||||
command! -n=0 -bar NERDTreeFind call nerdtree#findAndRevealPath()
|
||||
command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
|
||||
command! -n=0 -bar NERDTreeCWD call NERDTreeCWD()
|
||||
@@ -201,7 +201,7 @@ function! NERDTreeFocus()
|
||||
if nerdtree#isTreeOpen()
|
||||
call nerdtree#putCursorInTreeWin()
|
||||
else
|
||||
call g:NERDTreeCreator.New().togglePrimary("")
|
||||
call g:NERDTreeCreator.TogglePrimary("")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -27,6 +27,12 @@ function! s:Creator._broadcastInitEvent()
|
||||
silent doautocmd User NERDTreeInit
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.CreatePrimary(a:name) {{{1
|
||||
function! s:Creator.CreatePrimary(name)
|
||||
let creator = s:Creator.New()
|
||||
call creator.createPrimary(a:name)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.createPrimary(a:name) {{{1
|
||||
"name: the name of a bookmark or a directory
|
||||
function! s:Creator.createPrimary(name)
|
||||
@@ -63,6 +69,12 @@ function! s:Creator.createPrimary(name)
|
||||
call self._broadcastInitEvent()
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.CreateSecondary(dir) {{{1
|
||||
function! s:Creator.CreateSecondary(dir)
|
||||
let creator = s:Creator.New()
|
||||
call creator.createSecondary(a:dir)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.createSecondary(dir) {{{1
|
||||
function! s:Creator.createSecondary(dir)
|
||||
try
|
||||
@@ -94,6 +106,12 @@ function! s:Creator.createSecondary(dir)
|
||||
call self._broadcastInitEvent()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator.CreateMirror() {{{1
|
||||
function! s:Creator.CreateMirror()
|
||||
let creator = s:Creator.New()
|
||||
call creator.createMirror()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator.createMirror() {{{1
|
||||
function! s:Creator.createMirror()
|
||||
"get the names off all the nerd tree buffers
|
||||
@@ -248,6 +266,12 @@ function! s:Creator._setupStatusline()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.TogglePrimary(dir) {{{1
|
||||
function! s:Creator.TogglePrimary(dir)
|
||||
let creator = s:Creator.New()
|
||||
call creator.togglePrimary(a:dir)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.togglePrimary(dir) {{{1
|
||||
"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is
|
||||
"closed it is restored or initialized (if it doesnt exist)
|
||||
|
||||
@@ -185,7 +185,7 @@ endfunction
|
||||
function! s:Opener._openDirectory(node)
|
||||
if self._treetype ==# "secondary"
|
||||
call self._gotoTargetWin()
|
||||
call g:NERDTreeCreator.New().createSecondary(a:node.path.str())
|
||||
call g:NERDTreeCreator.CreateSecondary(a:node.path.str())
|
||||
else
|
||||
call self._gotoTargetWin()
|
||||
if empty(self._where)
|
||||
@@ -193,9 +193,9 @@ function! s:Opener._openDirectory(node)
|
||||
call nerdtree#renderView()
|
||||
call a:node.putCursorHere(0, 0)
|
||||
elseif self._where == 't'
|
||||
call g:NERDTreeCreator.New().createPrimary(a:node.path.str())
|
||||
call g:NERDTreeCreator.CreatePrimary(a:node.path.str())
|
||||
else
|
||||
call g:NERDTreeCreator.New().createSecondary(a:node.path.str())
|
||||
call g:NERDTreeCreator.CreateSecondary(a:node.path.str())
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ endfunction
|
||||
"FUNCTION: TreeDirNode._openInNewTab() {{{1
|
||||
function! s:TreeDirNode._openInNewTab()
|
||||
tabnew
|
||||
call g:NERDTreeCreator.New().createPrimary(self.path.str())
|
||||
call g:NERDTreeCreator.CreatePrimary(self.path.str())
|
||||
endfunction
|
||||
|
||||
"FUNCTION: TreeDirNode.openRecursively() {{{1
|
||||
|
||||
Reference in New Issue
Block a user