rename "primary" and "secondary" trees to "tab" and "window" trees
This is much more accurate and descriptive.
This commit is contained in:
parent
4dada8c04f
commit
848857d18b
@ -11,10 +11,10 @@ endfunction
|
|||||||
"============================================================
|
"============================================================
|
||||||
|
|
||||||
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
|
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
|
||||||
"inits a secondary nerd tree in the current buffer if appropriate
|
"inits a window tree in the current buffer if appropriate
|
||||||
function! nerdtree#checkForBrowse(dir)
|
function! nerdtree#checkForBrowse(dir)
|
||||||
if a:dir != '' && isdirectory(a:dir)
|
if a:dir != '' && isdirectory(a:dir)
|
||||||
call g:NERDTreeCreator.CreateSecondary(a:dir)
|
call g:NERDTreeCreator.CreateWindowTree(a:dir)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ endfunction
|
|||||||
" FUNCTION: s:closeTreeWindow() {{{1
|
" FUNCTION: s:closeTreeWindow() {{{1
|
||||||
" close the tree window
|
" close the tree window
|
||||||
function! s:closeTreeWindow()
|
function! s:closeTreeWindow()
|
||||||
if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1
|
if b:NERDTreeType ==# "window" && b:NERDTreePreviousBuf != -1
|
||||||
exec "buffer " . b:NERDTreePreviousBuf
|
exec "buffer " . b:NERDTreePreviousBuf
|
||||||
else
|
else
|
||||||
if winnr("$") > 1
|
if winnr("$") > 1
|
||||||
@ -269,14 +269,14 @@ function! s:findAndRevealPath()
|
|||||||
endtry
|
endtry
|
||||||
|
|
||||||
if p.isUnder(cwd)
|
if p.isUnder(cwd)
|
||||||
call g:NERDTreeCreator.CreatePrimary(cwd.str())
|
call g:NERDTreeCreator.CreateTabTree(cwd.str())
|
||||||
else
|
else
|
||||||
call g:NERDTreeCreator.CreatePrimary(p.getParent().str())
|
call g:NERDTreeCreator.CreateTabTree(p.getParent().str())
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path)
|
if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path)
|
||||||
if !g:NERDTree.IsOpen()
|
if !g:NERDTree.IsOpen()
|
||||||
call g:NERDTreeCreator.TogglePrimary('')
|
call g:NERDTreeCreator.ToggleTabTree('')
|
||||||
else
|
else
|
||||||
call g:NERDTree.CursorToTreeWin()
|
call g:NERDTree.CursorToTreeWin()
|
||||||
endif
|
endif
|
||||||
@ -284,7 +284,7 @@ function! s:findAndRevealPath()
|
|||||||
call s:chRoot(g:NERDTreeDirNode.New(p.getParent()))
|
call s:chRoot(g:NERDTreeDirNode.New(p.getParent()))
|
||||||
else
|
else
|
||||||
if !g:NERDTree.IsOpen()
|
if !g:NERDTree.IsOpen()
|
||||||
call g:NERDTreeCreator.TogglePrimary("")
|
call g:NERDTreeCreator.ToggleTabTree("")
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -545,10 +545,10 @@ endfunction
|
|||||||
|
|
||||||
" FUNCTION: nerdtree#ui_glue#setupCommands() {{{1
|
" FUNCTION: nerdtree#ui_glue#setupCommands() {{{1
|
||||||
function! nerdtree#ui_glue#setupCommands()
|
function! nerdtree#ui_glue#setupCommands()
|
||||||
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('<args>')
|
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('<args>')
|
||||||
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('<args>')
|
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('<args>')
|
||||||
command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close()
|
command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close()
|
||||||
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('<args>')
|
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('<args>')
|
||||||
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
|
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
|
||||||
command! -n=0 -bar NERDTreeFind call s:findAndRevealPath()
|
command! -n=0 -bar NERDTreeFind call s:findAndRevealPath()
|
||||||
command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
|
command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
|
||||||
|
@ -776,13 +776,13 @@ Default: 1.
|
|||||||
If set to 1, doing a >
|
If set to 1, doing a >
|
||||||
:edit <some directory>
|
:edit <some directory>
|
||||||
<
|
<
|
||||||
will open up a "secondary" NERD tree instead of a netrw in the target window.
|
will open up a window level NERD tree instead of a netrw in the target window.
|
||||||
|
|
||||||
Secondary NERD trees behaves slightly different from a regular trees in the
|
Window level trees behaves slightly different from a regular trees in the
|
||||||
following respects:
|
following respects:
|
||||||
1. 'o' will open the selected file in the same window as the tree,
|
1. 'o' will open the selected file in the same window as the tree,
|
||||||
replacing it.
|
replacing it.
|
||||||
2. you can have as many secondary tree as you want in the same tab.
|
2. you can have one tree per window - instead of per tab.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'NERDTreeIgnore'*
|
*'NERDTreeIgnore'*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"CLASS: Creator
|
"CLASS: Creator
|
||||||
"Creates primary/secondary/mirror nerdtree windows. Sets up all the window and
|
"Creates tab/window/mirror nerdtree windows. Sets up all the window and
|
||||||
"buffer options and key mappings etc.
|
"buffer options and key mappings etc.
|
||||||
"============================================================
|
"============================================================
|
||||||
let s:Creator = {}
|
let s:Creator = {}
|
||||||
@ -32,15 +32,15 @@ function! s:Creator.BufNamePrefix()
|
|||||||
return 'NERD_tree_'
|
return 'NERD_tree_'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.CreatePrimary(a:name) {{{1
|
"FUNCTION: s:Creator.CreateTabTree(a:name) {{{1
|
||||||
function! s:Creator.CreatePrimary(name)
|
function! s:Creator.CreateTabTree(name)
|
||||||
let creator = s:Creator.New()
|
let creator = s:Creator.New()
|
||||||
call creator.createPrimary(a:name)
|
call creator.createTabTree(a:name)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.createPrimary(a:name) {{{1
|
"FUNCTION: s:Creator.createTabTree(a:name) {{{1
|
||||||
"name: the name of a bookmark or a directory
|
"name: the name of a bookmark or a directory
|
||||||
function! s:Creator.createPrimary(name)
|
function! s:Creator.createTabTree(name)
|
||||||
let path = self._pathForString(a:name)
|
let path = self._pathForString(a:name)
|
||||||
|
|
||||||
"abort if exception was thrown (bookmark/dir doesn't exist)
|
"abort if exception was thrown (bookmark/dir doesn't exist)
|
||||||
@ -67,7 +67,7 @@ function! s:Creator.createPrimary(name)
|
|||||||
|
|
||||||
call self._createTreeWin()
|
call self._createTreeWin()
|
||||||
call self._createNERDTree(path)
|
call self._createNERDTree(path)
|
||||||
let b:NERDTreeType = "primary"
|
let b:NERDTreeType = "tab"
|
||||||
let b:treeShowHelp = 0
|
let b:treeShowHelp = 0
|
||||||
let b:NERDTreeIgnoreEnabled = 1
|
let b:NERDTreeIgnoreEnabled = 1
|
||||||
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
|
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
|
||||||
@ -80,14 +80,14 @@ function! s:Creator.createPrimary(name)
|
|||||||
call self._broadcastInitEvent()
|
call self._broadcastInitEvent()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.CreateSecondary(dir) {{{1
|
"FUNCTION: s:Creator.CreateWindowTree(dir) {{{1
|
||||||
function! s:Creator.CreateSecondary(dir)
|
function! s:Creator.CreateWindowTree(dir)
|
||||||
let creator = s:Creator.New()
|
let creator = s:Creator.New()
|
||||||
call creator.createSecondary(a:dir)
|
call creator.createWindowTree(a:dir)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.createSecondary(dir) {{{1
|
"FUNCTION: s:Creator.createWindowTree(dir) {{{1
|
||||||
function! s:Creator.createSecondary(dir)
|
function! s:Creator.createWindowTree(dir)
|
||||||
try
|
try
|
||||||
let path = g:NERDTreePath.New(a:dir)
|
let path = g:NERDTreePath.New(a:dir)
|
||||||
catch /^NERDTree.InvalidArgumentsError/
|
catch /^NERDTree.InvalidArgumentsError/
|
||||||
@ -100,14 +100,14 @@ function! s:Creator.createSecondary(dir)
|
|||||||
|
|
||||||
let previousBuf = expand("#")
|
let previousBuf = expand("#")
|
||||||
|
|
||||||
"we need a unique name for each secondary tree buffer to ensure they are
|
"we need a unique name for each window tree buffer to ensure they are
|
||||||
"all independent
|
"all independent
|
||||||
exec "silent edit " . self._nextBufferName()
|
exec "silent edit " . self._nextBufferName()
|
||||||
|
|
||||||
let b:NERDTreePreviousBuf = bufnr(previousBuf)
|
let b:NERDTreePreviousBuf = bufnr(previousBuf)
|
||||||
call self._createNERDTree(path)
|
call self._createNERDTree(path)
|
||||||
call self._setCommonBufOptions()
|
call self._setCommonBufOptions()
|
||||||
let b:NERDTreeType = "secondary"
|
let b:NERDTreeType = "window"
|
||||||
|
|
||||||
call b:NERDTree.render()
|
call b:NERDTree.render()
|
||||||
|
|
||||||
@ -322,20 +322,20 @@ function! s:Creator._tabpagevar(tabnr, var)
|
|||||||
return v
|
return v
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.TogglePrimary(dir) {{{1
|
"FUNCTION: s:Creator.ToggleTabTree(dir) {{{1
|
||||||
function! s:Creator.TogglePrimary(dir)
|
function! s:Creator.ToggleTabTree(dir)
|
||||||
let creator = s:Creator.New()
|
let creator = s:Creator.New()
|
||||||
call creator.togglePrimary(a:dir)
|
call creator.toggleTabTree(a:dir)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.togglePrimary(dir) {{{1
|
"FUNCTION: s:Creator.toggleTabTree(dir) {{{1
|
||||||
"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is
|
"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)
|
"closed it is restored or initialized (if it doesnt exist)
|
||||||
"
|
"
|
||||||
"Args:
|
"Args:
|
||||||
"dir: the full path for the root node (is only used if the NERD tree is being
|
"dir: the full path for the root node (is only used if the NERD tree is being
|
||||||
"initialized.
|
"initialized.
|
||||||
function! s:Creator.togglePrimary(dir)
|
function! s:Creator.toggleTabTree(dir)
|
||||||
if g:NERDTree.ExistsForTab()
|
if g:NERDTree.ExistsForTab()
|
||||||
if !g:NERDTree.IsOpen()
|
if !g:NERDTree.IsOpen()
|
||||||
call self._createTreeWin()
|
call self._createTreeWin()
|
||||||
@ -347,7 +347,7 @@ function! s:Creator.togglePrimary(dir)
|
|||||||
call g:NERDTree.Close()
|
call g:NERDTree.Close()
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call self.createPrimary(a:dir)
|
call self.createTabTree(a:dir)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ function! s:NERDTree.AddPathFilter(callback)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:NERDTree.Close() {{{1
|
"FUNCTION: s:NERDTree.Close() {{{1
|
||||||
"Closes the primary NERD tree window for this tab
|
"Closes the tab tree window for this tab
|
||||||
function! s:NERDTree.Close()
|
function! s:NERDTree.Close()
|
||||||
if !s:NERDTree.IsOpen()
|
if !s:NERDTree.IsOpen()
|
||||||
return
|
return
|
||||||
|
@ -64,7 +64,7 @@ endfunction
|
|||||||
|
|
||||||
"FUNCTION: Opener._gotoTargetWin() {{{1
|
"FUNCTION: Opener._gotoTargetWin() {{{1
|
||||||
function! s:Opener._gotoTargetWin()
|
function! s:Opener._gotoTargetWin()
|
||||||
if b:NERDTreeType ==# "secondary"
|
if b:NERDTreeType ==# "window"
|
||||||
if self._where == 'v'
|
if self._where == 'v'
|
||||||
vsplit
|
vsplit
|
||||||
elseif self._where == 'h'
|
elseif self._where == 'h'
|
||||||
@ -248,7 +248,7 @@ function! s:Opener._openFile()
|
|||||||
|
|
||||||
call self._gotoTargetWin()
|
call self._gotoTargetWin()
|
||||||
|
|
||||||
if self._treetype ==# "secondary"
|
if self._treetype ==# "window"
|
||||||
call self._path.edit()
|
call self._path.edit()
|
||||||
else
|
else
|
||||||
call self._path.edit()
|
call self._path.edit()
|
||||||
@ -262,9 +262,9 @@ endfunction
|
|||||||
|
|
||||||
"FUNCTION: Opener._openDirectory(node) {{{1
|
"FUNCTION: Opener._openDirectory(node) {{{1
|
||||||
function! s:Opener._openDirectory(node)
|
function! s:Opener._openDirectory(node)
|
||||||
if self._treetype ==# "secondary"
|
if self._treetype ==# "window"
|
||||||
call self._gotoTargetWin()
|
call self._gotoTargetWin()
|
||||||
call g:NERDTreeCreator.CreateSecondary(a:node.path.str())
|
call g:NERDTreeCreator.CreateWindow(a:node.path.str())
|
||||||
else
|
else
|
||||||
call self._gotoTargetWin()
|
call self._gotoTargetWin()
|
||||||
if empty(self._where)
|
if empty(self._where)
|
||||||
@ -272,9 +272,9 @@ function! s:Opener._openDirectory(node)
|
|||||||
call b:NERDTree.render()
|
call b:NERDTree.render()
|
||||||
call a:node.putCursorHere(0, 0)
|
call a:node.putCursorHere(0, 0)
|
||||||
elseif self._where == 't'
|
elseif self._where == 't'
|
||||||
call g:NERDTreeCreator.CreatePrimary(a:node.path.str())
|
call g:NERDTreeCreator.CreateTabTree(a:node.path.str())
|
||||||
else
|
else
|
||||||
call g:NERDTreeCreator.CreateSecondary(a:node.path.str())
|
call g:NERDTreeCreator.CreateWindow(a:node.path.str())
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ endfunction
|
|||||||
"FUNCTION: TreeDirNode._openInNewTab() {{{1
|
"FUNCTION: TreeDirNode._openInNewTab() {{{1
|
||||||
function! s:TreeDirNode._openInNewTab()
|
function! s:TreeDirNode._openInNewTab()
|
||||||
tabnew
|
tabnew
|
||||||
call g:NERDTreeCreator.CreatePrimary(self.path.str())
|
call g:NERDTreeCreator.CreateTabTree(self.path.str())
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.openRecursively() {{{1
|
"FUNCTION: TreeDirNode.openRecursively() {{{1
|
||||||
|
@ -27,12 +27,12 @@ function! s:UI._dumpHelp()
|
|||||||
let @h=@h."\" File node mappings~\n"
|
let @h=@h."\" File node mappings~\n"
|
||||||
let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n"
|
let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n"
|
||||||
let @h=@h."\" <CR>,\n"
|
let @h=@h."\" <CR>,\n"
|
||||||
if b:NERDTreeType ==# "primary"
|
if b:NERDTreeType ==# "tab"
|
||||||
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n"
|
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n"
|
||||||
else
|
else
|
||||||
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n"
|
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n"
|
||||||
endif
|
endif
|
||||||
if b:NERDTreeType ==# "primary"
|
if b:NERDTreeType ==# "tab"
|
||||||
let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n"
|
let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n"
|
||||||
endif
|
endif
|
||||||
let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
|
let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
|
||||||
|
@ -188,7 +188,7 @@ function! NERDTreeFocus()
|
|||||||
if g:NERDTree.IsOpen()
|
if g:NERDTree.IsOpen()
|
||||||
call g:NERDTree.CursorToTreeWin()
|
call g:NERDTree.CursorToTreeWin()
|
||||||
else
|
else
|
||||||
call g:NERDTreeCreator.TogglePrimary("")
|
call g:NERDTreeCreator.ToggleTabTree("")
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user