rename "primary" and "secondary" trees to "tab" and "window" trees

This is much more accurate and descriptive.
This commit is contained in:
Martin Grenfell 2015-11-14 11:50:01 +00:00
parent 4dada8c04f
commit 848857d18b
9 changed files with 44 additions and 44 deletions

View File

@ -11,10 +11,10 @@ endfunction
"============================================================
"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)
if a:dir != '' && isdirectory(a:dir)
call g:NERDTreeCreator.CreateSecondary(a:dir)
call g:NERDTreeCreator.CreateWindowTree(a:dir)
endif
endfunction

View File

@ -208,7 +208,7 @@ endfunction
" FUNCTION: s:closeTreeWindow() {{{1
" close the tree window
function! s:closeTreeWindow()
if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1
if b:NERDTreeType ==# "window" && b:NERDTreePreviousBuf != -1
exec "buffer " . b:NERDTreePreviousBuf
else
if winnr("$") > 1
@ -269,14 +269,14 @@ function! s:findAndRevealPath()
endtry
if p.isUnder(cwd)
call g:NERDTreeCreator.CreatePrimary(cwd.str())
call g:NERDTreeCreator.CreateTabTree(cwd.str())
else
call g:NERDTreeCreator.CreatePrimary(p.getParent().str())
call g:NERDTreeCreator.CreateTabTree(p.getParent().str())
endif
else
if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path)
if !g:NERDTree.IsOpen()
call g:NERDTreeCreator.TogglePrimary('')
call g:NERDTreeCreator.ToggleTabTree('')
else
call g:NERDTree.CursorToTreeWin()
endif
@ -284,7 +284,7 @@ function! s:findAndRevealPath()
call s:chRoot(g:NERDTreeDirNode.New(p.getParent()))
else
if !g:NERDTree.IsOpen()
call g:NERDTreeCreator.TogglePrimary("")
call g:NERDTreeCreator.ToggleTabTree("")
endif
endif
endif
@ -545,10 +545,10 @@ endfunction
" FUNCTION: nerdtree#ui_glue#setupCommands() {{{1
function! nerdtree#ui_glue#setupCommands()
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('<args>')
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('<args>')
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('<args>')
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('<args>')
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 NERDTreeFind call s:findAndRevealPath()
command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()

View File

@ -776,13 +776,13 @@ Default: 1.
If set to 1, doing a >
: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:
1. 'o' will open the selected file in the same window as the tree,
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'*

View File

@ -1,5 +1,5 @@
"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.
"============================================================
let s:Creator = {}
@ -32,15 +32,15 @@ function! s:Creator.BufNamePrefix()
return 'NERD_tree_'
endfunction
"FUNCTION: s:Creator.CreatePrimary(a:name) {{{1
function! s:Creator.CreatePrimary(name)
"FUNCTION: s:Creator.CreateTabTree(a:name) {{{1
function! s:Creator.CreateTabTree(name)
let creator = s:Creator.New()
call creator.createPrimary(a:name)
call creator.createTabTree(a:name)
endfunction
"FUNCTION: s:Creator.createPrimary(a:name) {{{1
"FUNCTION: s:Creator.createTabTree(a:name) {{{1
"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)
"abort if exception was thrown (bookmark/dir doesn't exist)
@ -67,7 +67,7 @@ function! s:Creator.createPrimary(name)
call self._createTreeWin()
call self._createNERDTree(path)
let b:NERDTreeType = "primary"
let b:NERDTreeType = "tab"
let b:treeShowHelp = 0
let b:NERDTreeIgnoreEnabled = 1
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
@ -80,14 +80,14 @@ function! s:Creator.createPrimary(name)
call self._broadcastInitEvent()
endfunction
"FUNCTION: s:Creator.CreateSecondary(dir) {{{1
function! s:Creator.CreateSecondary(dir)
"FUNCTION: s:Creator.CreateWindowTree(dir) {{{1
function! s:Creator.CreateWindowTree(dir)
let creator = s:Creator.New()
call creator.createSecondary(a:dir)
call creator.createWindowTree(a:dir)
endfunction
"FUNCTION: s:Creator.createSecondary(dir) {{{1
function! s:Creator.createSecondary(dir)
"FUNCTION: s:Creator.createWindowTree(dir) {{{1
function! s:Creator.createWindowTree(dir)
try
let path = g:NERDTreePath.New(a:dir)
catch /^NERDTree.InvalidArgumentsError/
@ -100,14 +100,14 @@ function! s:Creator.createSecondary(dir)
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
exec "silent edit " . self._nextBufferName()
let b:NERDTreePreviousBuf = bufnr(previousBuf)
call self._createNERDTree(path)
call self._setCommonBufOptions()
let b:NERDTreeType = "secondary"
let b:NERDTreeType = "window"
call b:NERDTree.render()
@ -322,20 +322,20 @@ function! s:Creator._tabpagevar(tabnr, var)
return v
endfunction
"FUNCTION: s:Creator.TogglePrimary(dir) {{{1
function! s:Creator.TogglePrimary(dir)
"FUNCTION: s:Creator.ToggleTabTree(dir) {{{1
function! s:Creator.ToggleTabTree(dir)
let creator = s:Creator.New()
call creator.togglePrimary(a:dir)
call creator.toggleTabTree(a:dir)
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
"closed it is restored or initialized (if it doesnt exist)
"
"Args:
"dir: the full path for the root node (is only used if the NERD tree is being
"initialized.
function! s:Creator.togglePrimary(dir)
function! s:Creator.toggleTabTree(dir)
if g:NERDTree.ExistsForTab()
if !g:NERDTree.IsOpen()
call self._createTreeWin()
@ -347,7 +347,7 @@ function! s:Creator.togglePrimary(dir)
call g:NERDTree.Close()
endif
else
call self.createPrimary(a:dir)
call self.createTabTree(a:dir)
endif
endfunction

View File

@ -9,7 +9,7 @@ function! s:NERDTree.AddPathFilter(callback)
endfunction
"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()
if !s:NERDTree.IsOpen()
return

View File

@ -64,7 +64,7 @@ endfunction
"FUNCTION: Opener._gotoTargetWin() {{{1
function! s:Opener._gotoTargetWin()
if b:NERDTreeType ==# "secondary"
if b:NERDTreeType ==# "window"
if self._where == 'v'
vsplit
elseif self._where == 'h'
@ -248,7 +248,7 @@ function! s:Opener._openFile()
call self._gotoTargetWin()
if self._treetype ==# "secondary"
if self._treetype ==# "window"
call self._path.edit()
else
call self._path.edit()
@ -262,9 +262,9 @@ endfunction
"FUNCTION: Opener._openDirectory(node) {{{1
function! s:Opener._openDirectory(node)
if self._treetype ==# "secondary"
if self._treetype ==# "window"
call self._gotoTargetWin()
call g:NERDTreeCreator.CreateSecondary(a:node.path.str())
call g:NERDTreeCreator.CreateWindow(a:node.path.str())
else
call self._gotoTargetWin()
if empty(self._where)
@ -272,9 +272,9 @@ function! s:Opener._openDirectory(node)
call b:NERDTree.render()
call a:node.putCursorHere(0, 0)
elseif self._where == 't'
call g:NERDTreeCreator.CreatePrimary(a:node.path.str())
call g:NERDTreeCreator.CreateTabTree(a:node.path.str())
else
call g:NERDTreeCreator.CreateSecondary(a:node.path.str())
call g:NERDTreeCreator.CreateWindow(a:node.path.str())
endif
endif

View File

@ -352,7 +352,7 @@ endfunction
"FUNCTION: TreeDirNode._openInNewTab() {{{1
function! s:TreeDirNode._openInNewTab()
tabnew
call g:NERDTreeCreator.CreatePrimary(self.path.str())
call g:NERDTreeCreator.CreateTabTree(self.path.str())
endfunction
"FUNCTION: TreeDirNode.openRecursively() {{{1

View File

@ -27,12 +27,12 @@ function! s:UI._dumpHelp()
let @h=@h."\" File node mappings~\n"
let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n"
let @h=@h."\" <CR>,\n"
if b:NERDTreeType ==# "primary"
if b:NERDTreeType ==# "tab"
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n"
else
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n"
endif
if b:NERDTreeType ==# "primary"
if b:NERDTreeType ==# "tab"
let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n"
endif
let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"

View File

@ -188,7 +188,7 @@ function! NERDTreeFocus()
if g:NERDTree.IsOpen()
call g:NERDTree.CursorToTreeWin()
else
call g:NERDTreeCreator.TogglePrimary("")
call g:NERDTreeCreator.ToggleTabTree("")
endif
endfunction