mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 19:33:50 -05:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7ebee3084 | ||
|
|
1239f78baf | ||
|
|
5f4c005771 | ||
|
|
9e0a0b6a43 | ||
|
|
5c85d28285 | ||
|
|
f65bc62fac | ||
|
|
9b12953343 | ||
|
|
84f9793231 | ||
|
|
1f46ecf4b8 | ||
|
|
eef90bf320 | ||
|
|
3796a8799a | ||
|
|
c726655d23 | ||
|
|
bdfac3e25c | ||
|
|
faf1459ce5 | ||
|
|
02751f4d11 | ||
|
|
992c9f24eb | ||
|
|
8164fa09d3 | ||
|
|
5e50601788 | ||
|
|
23e79de2c2 | ||
|
|
4accc8a79c | ||
|
|
7522cbf4f0 | ||
|
|
3a25a594ca | ||
|
|
40374e5056 | ||
|
|
4e4fb179e7 | ||
|
|
0f2effb049 | ||
|
|
63ee15ca6e | ||
|
|
f8a105d972 | ||
|
|
f2707106bd | ||
|
|
1586cfdb03 | ||
|
|
ca8b1d2b34 | ||
|
|
100d8d2a47 |
@@ -202,13 +202,16 @@ go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go|
|
|||||||
t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
|
t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
|
||||||
T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
|
T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
|
||||||
i.......Open selected file in a split window.....................|NERDTree-i|
|
i.......Open selected file in a split window.....................|NERDTree-i|
|
||||||
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-i|
|
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
|
||||||
|
s.......Open selected file in a new vsplit.......................|NERDTree-s|
|
||||||
|
gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|
|
||||||
!.......Execute the current file.................................|NERDTree-!|
|
!.......Execute the current file.................................|NERDTree-!|
|
||||||
O.......Recursively open the selected directory..................|NERDTree-O|
|
O.......Recursively open the selected directory..................|NERDTree-O|
|
||||||
x.......Close the current nodes parent...........................|NERDTree-x|
|
x.......Close the current nodes parent...........................|NERDTree-x|
|
||||||
X.......Recursively close all children of the current node.......|NERDTree-X|
|
X.......Recursively close all children of the current node.......|NERDTree-X|
|
||||||
e.......Edit the current dif.....................................|NERDTree-e|
|
e.......Edit the current dif.....................................|NERDTree-e|
|
||||||
|
|
||||||
|
<CR>...............same as |NERDTree-o|.
|
||||||
double-click.......same as the |NERDTree-o| map.
|
double-click.......same as the |NERDTree-o| map.
|
||||||
middle-click.......same as |NERDTree-i| for files, same as
|
middle-click.......same as |NERDTree-i| for files, same as
|
||||||
|NERDTree-e| for dirs.
|
|NERDTree-e| for dirs.
|
||||||
@@ -219,8 +222,8 @@ P.......Jump to the root node....................................|NERDTree-P|
|
|||||||
p.......Jump to current nodes parent.............................|NERDTree-p|
|
p.......Jump to current nodes parent.............................|NERDTree-p|
|
||||||
K.......Jump up inside directories at the current tree depth.....|NERDTree-K|
|
K.......Jump up inside directories at the current tree depth.....|NERDTree-K|
|
||||||
J.......Jump down inside directories at the current tree depth...|NERDTree-J|
|
J.......Jump down inside directories at the current tree depth...|NERDTree-J|
|
||||||
<C-j>...Jump down to the next sibling of the current directory...|NERDTree-c-j|
|
<C-J>...Jump down to the next sibling of the current directory...|NERDTree-C-J|
|
||||||
<C-k>...Jump up to the previous sibling of the current directory.|NERDTree-c-k|
|
<C-K>...Jump up to the previous sibling of the current directory.|NERDTree-C-K|
|
||||||
|
|
||||||
C.......Change the tree root to the selected dir.................|NERDTree-C|
|
C.......Change the tree root to the selected dir.................|NERDTree-C|
|
||||||
u.......Move the tree root up one directory......................|NERDTree-u|
|
u.......Move the tree root up one directory......................|NERDTree-u|
|
||||||
@@ -308,6 +311,26 @@ The same as |NERDTree-i| except that the cursor is not moved.
|
|||||||
The key combo for this mapping is always "g" + NERDTreeMapOpenSplit (see
|
The key combo for this mapping is always "g" + NERDTreeMapOpenSplit (see
|
||||||
|NERDTree-i|).
|
|NERDTree-i|).
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*NERDTree-s*
|
||||||
|
Default key: s
|
||||||
|
Map option: NERDTreeMapOpenVSplit
|
||||||
|
Applies to: files.
|
||||||
|
|
||||||
|
Opens the selected file in a new vertically split window and puts the cursor in
|
||||||
|
the new window.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*NERDTree-gs*
|
||||||
|
Default key: gs
|
||||||
|
Map option: None
|
||||||
|
Applies to: files.
|
||||||
|
|
||||||
|
The same as |NERDTree-s| except that the cursor is not moved.
|
||||||
|
|
||||||
|
The key combo for this mapping is always "g" + NERDTreeMapOpenVSplit (see
|
||||||
|
|NERDTree-s|).
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTree-!*
|
*NERDTree-!*
|
||||||
Default key: !
|
Default key: !
|
||||||
@@ -408,16 +431,16 @@ If the cursor is already on the last node then do the following:
|
|||||||
* go to the last child of that node
|
* go to the last child of that node
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTree-c-j*
|
*NERDTree-C-J*
|
||||||
Default key: <C-j>
|
Default key: <C-J>
|
||||||
Map option: NERDTreeMapJumpNextSibling
|
Map option: NERDTreeMapJumpNextSibling
|
||||||
Applies to: files and directories.
|
Applies to: files and directories.
|
||||||
|
|
||||||
Jump to the next sibling of the selected node.
|
Jump to the next sibling of the selected node.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTree-c-k*
|
*NERDTree-C-K*
|
||||||
Default key: <C-k>
|
Default key: <C-K>
|
||||||
Map option: NERDTreeMapJumpPrevSibling
|
Map option: NERDTreeMapJumpPrevSibling
|
||||||
Applies to: files and directories.
|
Applies to: files and directories.
|
||||||
|
|
||||||
@@ -475,6 +498,14 @@ Applies to: files and directories.
|
|||||||
|
|
||||||
Display the filesystem menu. See |NERDTreeFilesysMenu| for details.
|
Display the filesystem menu. See |NERDTreeFilesysMenu| for details.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*NERDTree-cd*
|
||||||
|
Default key: cd
|
||||||
|
Map option: NERDTreeMapChdir
|
||||||
|
Applies to: files and directories.
|
||||||
|
|
||||||
|
Change vims current working directory to that of the selected node.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTree-I*
|
*NERDTree-I*
|
||||||
Default key: I
|
Default key: I
|
||||||
@@ -619,6 +650,8 @@ NERD tree. These options should be set in your vimrc.
|
|||||||
|'NERDTreeSortOrder'| Tell the NERD tree how to sort the nodes in
|
|'NERDTreeSortOrder'| Tell the NERD tree how to sort the nodes in
|
||||||
the tree.
|
the tree.
|
||||||
|
|
||||||
|
|'NERDTreeStatusline'| Set a statusline for NERD tree windows.
|
||||||
|
|
||||||
|'NERDTreeWinPos'| Tells the script where to put the NERD tree
|
|'NERDTreeWinPos'| Tells the script where to put the NERD tree
|
||||||
window.
|
window.
|
||||||
|
|
||||||
@@ -655,7 +688,7 @@ If set to 1, the NERD tree window will center around the cursor if it moves to
|
|||||||
within |'NERDTreeAutoCenterThreshold'| lines of the top/bottom of the window.
|
within |'NERDTreeAutoCenterThreshold'| lines of the top/bottom of the window.
|
||||||
|
|
||||||
This is ONLY done in response to tree navigation mappings,
|
This is ONLY done in response to tree navigation mappings,
|
||||||
i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-c-K| |NERDTree-p|
|
i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-C-K| |NERDTree-p|
|
||||||
|NERDTree-P|
|
|NERDTree-P|
|
||||||
|
|
||||||
The centering is done with a |zz| operation.
|
The centering is done with a |zz| operation.
|
||||||
@@ -718,7 +751,7 @@ Values: 0 or 1.
|
|||||||
Default: 1.
|
Default: 1.
|
||||||
|
|
||||||
If set to 1, the current cursor line in the NERD tree buffer will be
|
If set to 1, the current cursor line in the NERD tree buffer will be
|
||||||
highlighted. This is done using the |cursorline| option.
|
highlighted. This is done using the |'cursorline'| option.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'NERDTreeHijackNetrw'*
|
*'NERDTreeHijackNetrw'*
|
||||||
@@ -871,6 +904,20 @@ Other examples: >
|
|||||||
3. Dirs will appear first, then ruby and php. Swap files, bak files and vim
|
3. Dirs will appear first, then ruby and php. Swap files, bak files and vim
|
||||||
backup files will appear last with everything else preceding them.
|
backup files will appear last with everything else preceding them.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'NERDTreeStatusline'*
|
||||||
|
Values: Any valid statusline setting.
|
||||||
|
Default: %{b:NERDTreeRoot.path.strForOS(0)}
|
||||||
|
|
||||||
|
Tells the script what to use as the |'statusline'| setting for NERD tree
|
||||||
|
windows.
|
||||||
|
|
||||||
|
Note that the statusline is set using |:let-&| not |:set| so escaping spaces
|
||||||
|
isn't necessary.
|
||||||
|
|
||||||
|
Setting this option to -1 will will deactivate it so that your global
|
||||||
|
statusline setting is used instead.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'NERDTreeWinPos'*
|
*'NERDTreeWinPos'*
|
||||||
Values: "left" or "right"
|
Values: "left" or "right"
|
||||||
@@ -879,9 +926,9 @@ Default: "left".
|
|||||||
This option is used to determine where NERD tree window is placed on the
|
This option is used to determine where NERD tree window is placed on the
|
||||||
screen.
|
screen.
|
||||||
|
|
||||||
This option is makes it possible to use two different explorer type
|
This option makes it possible to use two different explorer plugins
|
||||||
plugins simultaneously. For example, you could have the taglist plugin on the
|
simultaneously. For example, you could have the taglist plugin on the left of
|
||||||
left of the window and the NERD tree on the right.
|
the window and the NERD tree on the right.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'NERDTreeWinSize'*
|
*'NERDTreeWinSize'*
|
||||||
@@ -950,6 +997,33 @@ The latest dev versions are on github
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
6. Changelog *NERDTreeChangelog*
|
6. Changelog *NERDTreeChangelog*
|
||||||
|
|
||||||
|
3.1.1
|
||||||
|
- fix a bug where a non-listed no-name buffer was getting created every
|
||||||
|
time the tree windows was created, thanks to Derek Wyatt and owen1
|
||||||
|
- make <CR> behave the same as the 'o' mapping
|
||||||
|
- some helptag fixes in the doc, thanks strull
|
||||||
|
- fix a bug when using :set nohidden and opening a file where the previous
|
||||||
|
buf was modified. Thanks iElectric
|
||||||
|
- other minor fixes
|
||||||
|
|
||||||
|
3.1.0
|
||||||
|
New features:
|
||||||
|
- add mappings to open files in a vsplit, see :help NERDTree-s and :help
|
||||||
|
NERDTree-gs
|
||||||
|
- make the statusline for the nerd tree window default to something
|
||||||
|
hopefully more useful. See :help 'NERDTreeStatusline'
|
||||||
|
Bugfixes:
|
||||||
|
- make the hijack netrw functionality work when vim is started with "vim
|
||||||
|
<some dir>" (thanks to Alf Mikula for the patch).
|
||||||
|
- fix a bug where the CWD wasnt being changed for some operations even when
|
||||||
|
NERDTreeChDirMode==2 (thanks to Lucas S. Buchala)
|
||||||
|
- add -bar to all the nerd tree :commands so they can chain with other
|
||||||
|
:commands (thanks to tpope)
|
||||||
|
- fix bugs when ignorecase was set (thanks to nach)
|
||||||
|
- fix a bug with the relative path code (thanks to nach)
|
||||||
|
- fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach)
|
||||||
|
|
||||||
|
|
||||||
3.0.1
|
3.0.1
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden
|
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden
|
||||||
@@ -1010,6 +1084,9 @@ just downloaded pr0n instead.
|
|||||||
Tim Pope (tpope)
|
Tim Pope (tpope)
|
||||||
James Kanze
|
James Kanze
|
||||||
James Vega (jamessan)
|
James Vega (jamessan)
|
||||||
|
Frederic Chanal (nach)
|
||||||
|
Alf Mikula
|
||||||
|
Lucas S. Buchala
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
8. License *NERDTreeLicense*
|
8. License *NERDTreeLicense*
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
" File: NERD_tree.vim
|
" File: NERD_tree.vim
|
||||||
" Description: vim global plugin that provides a nice tree explorer
|
" Description: vim global plugin that provides a nice tree explorer
|
||||||
" Maintainer: Martin Grenfell <martin_grenfell at msn dot com>
|
" Maintainer: Martin Grenfell <martin_grenfell at msn dot com>
|
||||||
" Last Change: 12 Jan, 2009
|
" Last Change: 7 Jun, 2009
|
||||||
" License: This program is free software. It comes without any warranty,
|
" License: This program is free software. It comes without any warranty,
|
||||||
" to the extent permitted by applicable law. You can redistribute
|
" to the extent permitted by applicable law. You can redistribute
|
||||||
" it and/or modify it under the terms of the Do What The Fuck You
|
" it and/or modify it under the terms of the Do What The Fuck You
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||||
"
|
"
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
let s:NERD_tree_version = '3.0.1'
|
let s:NERD_tree_version = '3.1.1'
|
||||||
|
|
||||||
" SECTION: Script init stuff {{{1
|
" SECTION: Script init stuff {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
@@ -79,6 +79,7 @@ endif
|
|||||||
"once here
|
"once here
|
||||||
let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*')
|
let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*')
|
||||||
|
|
||||||
|
call s:initVariable("g:NERDTreeStatusline", "%{b:NERDTreeRoot.path.strForOS(0)}")
|
||||||
call s:initVariable("g:NERDTreeWinPos", "left")
|
call s:initVariable("g:NERDTreeWinPos", "left")
|
||||||
call s:initVariable("g:NERDTreeWinSize", 31)
|
call s:initVariable("g:NERDTreeWinSize", 31)
|
||||||
|
|
||||||
@@ -116,8 +117,10 @@ call s:initVariable("g:NERDTreeMapOpenInTab", "t")
|
|||||||
call s:initVariable("g:NERDTreeMapOpenInTabSilent", "T")
|
call s:initVariable("g:NERDTreeMapOpenInTabSilent", "T")
|
||||||
call s:initVariable("g:NERDTreeMapOpenRecursively", "O")
|
call s:initVariable("g:NERDTreeMapOpenRecursively", "O")
|
||||||
call s:initVariable("g:NERDTreeMapOpenSplit", "i")
|
call s:initVariable("g:NERDTreeMapOpenSplit", "i")
|
||||||
|
call s:initVariable("g:NERDTreeMapOpenVSplit", "s")
|
||||||
call s:initVariable("g:NERDTreeMapPreview", "g" . NERDTreeMapActivateNode)
|
call s:initVariable("g:NERDTreeMapPreview", "g" . NERDTreeMapActivateNode)
|
||||||
call s:initVariable("g:NERDTreeMapPreviewSplit", "g" . NERDTreeMapOpenSplit)
|
call s:initVariable("g:NERDTreeMapPreviewSplit", "g" . NERDTreeMapOpenSplit)
|
||||||
|
call s:initVariable("g:NERDTreeMapPreviewVSplit", "g" . NERDTreeMapOpenVSplit)
|
||||||
call s:initVariable("g:NERDTreeMapQuit", "q")
|
call s:initVariable("g:NERDTreeMapQuit", "q")
|
||||||
call s:initVariable("g:NERDTreeMapRefresh", "r")
|
call s:initVariable("g:NERDTreeMapRefresh", "r")
|
||||||
call s:initVariable("g:NERDTreeMapRefreshRoot", "R")
|
call s:initVariable("g:NERDTreeMapRefreshRoot", "R")
|
||||||
@@ -147,11 +150,11 @@ let s:next_buffer_number = 1
|
|||||||
" SECTION: Commands {{{1
|
" SECTION: Commands {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
"init the command that users start the nerd tree with
|
"init the command that users start the nerd tree with
|
||||||
command! -n=? -complete=dir NERDTree :call s:initNerdTree('<args>')
|
command! -n=? -complete=dir -bar NERDTree :call s:initNerdTree('<args>')
|
||||||
command! -n=? -complete=dir NERDTreeToggle :call s:toggle('<args>')
|
command! -n=? -complete=dir -bar NERDTreeToggle :call s:toggle('<args>')
|
||||||
command! -n=0 NERDTreeClose :call s:closeTreeIfOpen()
|
command! -n=0 -bar NERDTreeClose :call s:closeTreeIfOpen()
|
||||||
command! -n=1 -complete=customlist,s:completeBookmarks NERDTreeFromBookmark call s:initNerdTree('<args>')
|
command! -n=1 -complete=customlist,s:completeBookmarks -bar NERDTreeFromBookmark call s:initNerdTree('<args>')
|
||||||
command! -n=0 -complete=customlist,s:completeNERDTreeMirrors NERDTreeMirror call s:initNerdTreeMirror()
|
command! -n=0 -bar NERDTreeMirror call s:initNerdTreeMirror()
|
||||||
" SECTION: Auto commands {{{1
|
" SECTION: Auto commands {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
augroup NERDTree
|
augroup NERDTree
|
||||||
@@ -164,7 +167,7 @@ augroup END
|
|||||||
if g:NERDTreeHijackNetrw
|
if g:NERDTreeHijackNetrw
|
||||||
augroup NERDTreeHijackNetrw
|
augroup NERDTreeHijackNetrw
|
||||||
autocmd VimEnter * silent! autocmd! FileExplorer
|
autocmd VimEnter * silent! autocmd! FileExplorer
|
||||||
au BufEnter * call s:checkForBrowse(expand("<amatch>"))
|
au BufEnter,VimEnter * call s:checkForBrowse(expand("<amatch>"))
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -178,7 +181,7 @@ let s:Bookmark = {}
|
|||||||
" with the same name, just update the path for that bookmark
|
" with the same name, just update the path for that bookmark
|
||||||
function! s:Bookmark.AddBookmark(name, path)
|
function! s:Bookmark.AddBookmark(name, path)
|
||||||
for i in s:Bookmark.Bookmarks()
|
for i in s:Bookmark.Bookmarks()
|
||||||
if i.name == a:name
|
if i.name ==# a:name
|
||||||
let i.path = a:path
|
let i.path = a:path
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -211,7 +214,7 @@ endfunction
|
|||||||
" bookmark is found
|
" bookmark is found
|
||||||
function! s:Bookmark.BookmarkFor(name)
|
function! s:Bookmark.BookmarkFor(name)
|
||||||
for i in s:Bookmark.Bookmarks()
|
for i in s:Bookmark.Bookmarks()
|
||||||
if i.name == a:name
|
if i.name ==# a:name
|
||||||
return i
|
return i
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -489,7 +492,7 @@ endfunction
|
|||||||
"FUNCTION: TreeFileNode.renderToString {{{3
|
"FUNCTION: TreeFileNode.renderToString {{{3
|
||||||
"returns a string representation for this tree to be rendered in the view
|
"returns a string representation for this tree to be rendered in the view
|
||||||
function! s:TreeFileNode.renderToString()
|
function! s:TreeFileNode.renderToString()
|
||||||
return self._renderToString(0, 0, [], self.getChildCount() == 1)
|
return self._renderToString(0, 0, [], self.getChildCount() ==# 1)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
@@ -502,14 +505,14 @@ endfunction
|
|||||||
"isLastChild:true if this curNode is the last child of its parent
|
"isLastChild:true if this curNode is the last child of its parent
|
||||||
function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
|
function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
|
||||||
let output = ""
|
let output = ""
|
||||||
if a:drawText == 1
|
if a:drawText ==# 1
|
||||||
|
|
||||||
let treeParts = ''
|
let treeParts = ''
|
||||||
|
|
||||||
"get all the leading spaces and vertical tree parts for this line
|
"get all the leading spaces and vertical tree parts for this line
|
||||||
if a:depth > 1
|
if a:depth > 1
|
||||||
for j in a:vertMap[0:-2]
|
for j in a:vertMap[0:-2]
|
||||||
if j == 1
|
if j ==# 1
|
||||||
let treeParts = treeParts . '| '
|
let treeParts = treeParts . '| '
|
||||||
else
|
else
|
||||||
let treeParts = treeParts . ' '
|
let treeParts = treeParts . ' '
|
||||||
@@ -543,7 +546,7 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
"if the node is an open dir, draw its children
|
"if the node is an open dir, draw its children
|
||||||
if self.path.isDirectory == 1 && self.isOpen == 1
|
if self.path.isDirectory ==# 1 && self.isOpen ==# 1
|
||||||
|
|
||||||
let childNodesToDraw = self.getVisibleChildren()
|
let childNodesToDraw = self.getVisibleChildren()
|
||||||
if len(childNodesToDraw) > 0
|
if len(childNodesToDraw) > 0
|
||||||
@@ -574,7 +577,7 @@ endfunction
|
|||||||
"Args:
|
"Args:
|
||||||
"treenode: the other treenode to compare to
|
"treenode: the other treenode to compare to
|
||||||
function! s:TreeFileNode.equals(treenode)
|
function! s:TreeFileNode.equals(treenode)
|
||||||
return self.path.str(1) == a:treenode.path.str(1)
|
return self.path.str(1) ==# a:treenode.path.str(1)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.findNode(path) {{{3
|
"FUNCTION: TreeFileNode.findNode(path) {{{3
|
||||||
@@ -632,7 +635,7 @@ function! s:TreeFileNode.findSibling(direction)
|
|||||||
|
|
||||||
if siblingIndx != -1
|
if siblingIndx != -1
|
||||||
"move a long to the next potential sibling node
|
"move a long to the next potential sibling node
|
||||||
let siblingIndx = a:direction == 1 ? siblingIndx+1 : siblingIndx-1
|
let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1
|
||||||
|
|
||||||
"keep moving along to the next sibling till we find one that is valid
|
"keep moving along to the next sibling till we find one that is valid
|
||||||
let numSiblings = self.parent.getChildCount()
|
let numSiblings = self.parent.getChildCount()
|
||||||
@@ -640,12 +643,12 @@ function! s:TreeFileNode.findSibling(direction)
|
|||||||
|
|
||||||
"if the next node is not an ignored node (i.e. wont show up in the
|
"if the next node is not an ignored node (i.e. wont show up in the
|
||||||
"view) then return it
|
"view) then return it
|
||||||
if self.parent.children[siblingIndx].path.ignore() == 0
|
if self.parent.children[siblingIndx].path.ignore() ==# 0
|
||||||
return self.parent.children[siblingIndx]
|
return self.parent.children[siblingIndx]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"go to next node
|
"go to next node
|
||||||
let siblingIndx = a:direction == 1 ? siblingIndx+1 : siblingIndx-1
|
let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1
|
||||||
endwhile
|
endwhile
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@@ -675,24 +678,24 @@ function! s:TreeFileNode.getLineNum()
|
|||||||
while lnum > 0
|
while lnum > 0
|
||||||
let lnum = lnum + 1
|
let lnum = lnum + 1
|
||||||
"have we reached the bottom of the tree?
|
"have we reached the bottom of the tree?
|
||||||
if lnum == totalLines+1
|
if lnum ==# totalLines+1
|
||||||
return -1
|
return -1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let curLine = getline(lnum)
|
let curLine = getline(lnum)
|
||||||
|
|
||||||
let indent = s:indentLevelFor(curLine)
|
let indent = s:indentLevelFor(curLine)
|
||||||
if indent == curPathComponent
|
if indent ==# curPathComponent
|
||||||
let curLine = s:stripMarkupFromLine(curLine, 1)
|
let curLine = s:stripMarkupFromLine(curLine, 1)
|
||||||
|
|
||||||
let curPath = join(pathcomponents, '/') . '/' . curLine
|
let curPath = join(pathcomponents, '/') . '/' . curLine
|
||||||
if stridx(fullpath, curPath, 0) == 0
|
if stridx(fullpath, curPath, 0) ==# 0
|
||||||
if fullpath == curPath || strpart(fullpath, len(curPath)-1,1) == '/'
|
if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/'
|
||||||
let curLine = substitute(curLine, '/ *$', '', '')
|
let curLine = substitute(curLine, '/ *$', '', '')
|
||||||
call add(pathcomponents, curLine)
|
call add(pathcomponents, curLine)
|
||||||
let curPathComponent = curPathComponent + 1
|
let curPathComponent = curPathComponent + 1
|
||||||
|
|
||||||
if fullpath == curPath
|
if fullpath ==# curPath
|
||||||
return lnum
|
return lnum
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@@ -717,7 +720,7 @@ endfunction
|
|||||||
function! s:TreeFileNode.GetSelected()
|
function! s:TreeFileNode.GetSelected()
|
||||||
try
|
try
|
||||||
let path = s:getPath(line("."))
|
let path = s:getPath(line("."))
|
||||||
if path == {}
|
if path ==# {}
|
||||||
return {}
|
return {}
|
||||||
endif
|
endif
|
||||||
return b:NERDTreeRoot.findNode(path)
|
return b:NERDTreeRoot.findNode(path)
|
||||||
@@ -754,7 +757,7 @@ function! s:TreeFileNode.makeRoot()
|
|||||||
call b:NERDTreeRoot.open()
|
call b:NERDTreeRoot.open()
|
||||||
|
|
||||||
"change dir to the dir of the new root if instructed to
|
"change dir to the dir of the new root if instructed to
|
||||||
if g:NERDTreeChDirMode == 2
|
if g:NERDTreeChDirMode ==# 2
|
||||||
exec "cd " . b:NERDTreeRoot.path.strForEditCmd()
|
exec "cd " . b:NERDTreeRoot.path.strForEditCmd()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@@ -782,25 +785,23 @@ endfunction
|
|||||||
"ARGS:
|
"ARGS:
|
||||||
"treenode: file node to open
|
"treenode: file node to open
|
||||||
function! s:TreeFileNode.open()
|
function! s:TreeFileNode.open()
|
||||||
if b:NERDTreeType == "secondary"
|
if b:NERDTreeType ==# "secondary"
|
||||||
exec 'edit ' . self.path.strForEditCmd()
|
exec 'edit ' . self.path.strForEditCmd()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:putCursorInTreeWin()
|
|
||||||
|
|
||||||
"if the file is already open in this tab then just stick the cursor in it
|
"if the file is already open in this tab then just stick the cursor in it
|
||||||
let winnr = bufwinnr('^' . self.path.strForOS(0) . '$')
|
let winnr = bufwinnr('^' . self.path.strForOS(0) . '$')
|
||||||
if winnr != -1
|
if winnr != -1
|
||||||
call s:exec(winnr . "wincmd w")
|
call s:exec(winnr . "wincmd w")
|
||||||
|
|
||||||
else
|
else
|
||||||
if !s:isWindowUsable(winnr("#")) && s:firstNormalWindow() == -1
|
if !s:isWindowUsable(winnr("#")) && s:firstUsableWindow() ==# -1
|
||||||
call self.openSplit()
|
call self.openSplit()
|
||||||
else
|
else
|
||||||
try
|
try
|
||||||
if !s:isWindowUsable(winnr("#"))
|
if !s:isWindowUsable(winnr("#"))
|
||||||
call s:exec(s:firstNormalWindow() . "wincmd w")
|
call s:exec(s:firstUsableWindow() . "wincmd w")
|
||||||
else
|
else
|
||||||
call s:exec('wincmd p')
|
call s:exec('wincmd p')
|
||||||
endif
|
endif
|
||||||
@@ -818,7 +819,7 @@ endfunction
|
|||||||
"Open this node in a new window
|
"Open this node in a new window
|
||||||
function! s:TreeFileNode.openSplit()
|
function! s:TreeFileNode.openSplit()
|
||||||
|
|
||||||
if b:NERDTreeType == "secondary"
|
if b:NERDTreeType ==# "secondary"
|
||||||
exec "split " . self.path.strForEditCmd()
|
exec "split " . self.path.strForEditCmd()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -836,15 +837,15 @@ function! s:TreeFileNode.openSplit()
|
|||||||
" 'right' and 'below' will be set to the settings needed for
|
" 'right' and 'below' will be set to the settings needed for
|
||||||
" splitbelow and splitright IF the explorer is the only window.
|
" splitbelow and splitright IF the explorer is the only window.
|
||||||
"
|
"
|
||||||
let there= g:NERDTreeWinPos == "left" ? "wincmd h" : "wincmd l"
|
let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l"
|
||||||
let back = g:NERDTreeWinPos == "left" ? "wincmd l" : "wincmd h"
|
let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h"
|
||||||
let right= g:NERDTreeWinPos == "left"
|
let right= g:NERDTreeWinPos ==# "left"
|
||||||
let below=0
|
let below=0
|
||||||
|
|
||||||
" Attempt to go to adjacent window
|
" Attempt to go to adjacent window
|
||||||
call s:exec(back)
|
call s:exec(back)
|
||||||
|
|
||||||
let onlyOneWin = (winnr() == s:getTreeWinNum())
|
let onlyOneWin = (winnr("$") ==# 1)
|
||||||
|
|
||||||
" If no adjacent window, set splitright and splitbelow appropriately
|
" If no adjacent window, set splitright and splitbelow appropriately
|
||||||
if onlyOneWin
|
if onlyOneWin
|
||||||
@@ -880,7 +881,27 @@ function! s:TreeFileNode.openSplit()
|
|||||||
let &splitbelow=savesplitbelow
|
let &splitbelow=savesplitbelow
|
||||||
let &splitright=savesplitright
|
let &splitright=savesplitright
|
||||||
endfunction
|
endfunction
|
||||||
|
"FUNCTION: TreeFileNode.openVSplit() {{{3
|
||||||
|
"Open this node in a new vertical window
|
||||||
|
function! s:TreeFileNode.openVSplit()
|
||||||
|
if b:NERDTreeType ==# "secondary"
|
||||||
|
exec "vnew " . self.path.strForEditCmd()
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let winwidth = winwidth(".")
|
||||||
|
if winnr("$")==#1
|
||||||
|
let winwidth = g:NERDTreeWinSize
|
||||||
|
endif
|
||||||
|
|
||||||
|
call s:exec("wincmd p")
|
||||||
|
exec "vnew " . self.path.strForEditCmd()
|
||||||
|
|
||||||
|
"resize the nerd tree back to the original size
|
||||||
|
call s:putCursorInTreeWin()
|
||||||
|
exec("silent vertical resize ". winwidth)
|
||||||
|
call s:exec('wincmd p')
|
||||||
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{3
|
"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{3
|
||||||
"Places the cursor on the line number this node is rendered on
|
"Places the cursor on the line number this node is rendered on
|
||||||
"
|
"
|
||||||
@@ -898,7 +919,7 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward)
|
|||||||
else
|
else
|
||||||
if a:recurseUpward
|
if a:recurseUpward
|
||||||
let node = self
|
let node = self
|
||||||
while node != {} && node.getLineNum() == -1
|
while node != {} && node.getLineNum() ==# -1
|
||||||
let node = node.parent
|
let node = node.parent
|
||||||
call node.open()
|
call node.open()
|
||||||
endwhile
|
endwhile
|
||||||
@@ -1011,7 +1032,7 @@ function! s:TreeDirNode.findNode(path)
|
|||||||
if a:path.equals(self.path)
|
if a:path.equals(self.path)
|
||||||
return self
|
return self
|
||||||
endif
|
endif
|
||||||
if stridx(a:path.str(1), self.path.str(1), 0) == -1
|
if stridx(a:path.str(1), self.path.str(1), 0) ==# -1
|
||||||
return {}
|
return {}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -1040,12 +1061,12 @@ endfunction
|
|||||||
"Args:
|
"Args:
|
||||||
"path: a path object
|
"path: a path object
|
||||||
function! s:TreeDirNode.getChild(path)
|
function! s:TreeDirNode.getChild(path)
|
||||||
if stridx(a:path.str(1), self.path.str(1), 0) == -1
|
if stridx(a:path.str(1), self.path.str(1), 0) ==# -1
|
||||||
return {}
|
return {}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let index = self.getChildIndex(a:path)
|
let index = self.getChildIndex(a:path)
|
||||||
if index == -1
|
if index ==# -1
|
||||||
return {}
|
return {}
|
||||||
else
|
else
|
||||||
return self.children[index]
|
return self.children[index]
|
||||||
@@ -1076,7 +1097,7 @@ endfunction
|
|||||||
"Args:
|
"Args:
|
||||||
"path: a path object
|
"path: a path object
|
||||||
function! s:TreeDirNode.getChildIndex(path)
|
function! s:TreeDirNode.getChildIndex(path)
|
||||||
if stridx(a:path.str(1), self.path.str(1), 0) == -1
|
if stridx(a:path.str(1), self.path.str(1), 0) ==# -1
|
||||||
return -1
|
return -1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -1087,9 +1108,9 @@ function! s:TreeDirNode.getChildIndex(path)
|
|||||||
let mid = (a+z)/2
|
let mid = (a+z)/2
|
||||||
let diff = a:path.compareTo(self.children[mid].path)
|
let diff = a:path.compareTo(self.children[mid].path)
|
||||||
|
|
||||||
if diff == -1
|
if diff ==# -1
|
||||||
let z = mid
|
let z = mid
|
||||||
elseif diff == 1
|
elseif diff ==# 1
|
||||||
let a = mid+1
|
let a = mid+1
|
||||||
else
|
else
|
||||||
return mid
|
return mid
|
||||||
@@ -1105,7 +1126,7 @@ unlet s:TreeDirNode.GetSelected
|
|||||||
function! s:TreeDirNode.GetSelected()
|
function! s:TreeDirNode.GetSelected()
|
||||||
let currentDir = s:TreeFileNode.GetSelected()
|
let currentDir = s:TreeFileNode.GetSelected()
|
||||||
if currentDir != {} && !currentDir.isRoot()
|
if currentDir != {} && !currentDir.isRoot()
|
||||||
if currentDir.path.isDirectory == 0
|
if currentDir.path.isDirectory ==# 0
|
||||||
let currentDir = currentDir.parent
|
let currentDir = currentDir.parent
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@@ -1125,7 +1146,7 @@ endfunction
|
|||||||
function! s:TreeDirNode.getVisibleChildren()
|
function! s:TreeDirNode.getVisibleChildren()
|
||||||
let toReturn = []
|
let toReturn = []
|
||||||
for i in self.children
|
for i in self.children
|
||||||
if i.path.ignore() == 0
|
if i.path.ignore() ==# 0
|
||||||
call add(toReturn, i)
|
call add(toReturn, i)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -1216,7 +1237,7 @@ endfunction
|
|||||||
unlet s:TreeDirNode.open
|
unlet s:TreeDirNode.open
|
||||||
function! s:TreeDirNode.open()
|
function! s:TreeDirNode.open()
|
||||||
let self.isOpen = 1
|
let self.isOpen = 1
|
||||||
if self.children == []
|
if self.children ==# []
|
||||||
return self._initChildren(0)
|
return self._initChildren(0)
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
@@ -1229,7 +1250,7 @@ endfunction
|
|||||||
function! s:TreeDirNode.openExplorer()
|
function! s:TreeDirNode.openExplorer()
|
||||||
let oldwin = winnr()
|
let oldwin = winnr()
|
||||||
call s:exec('wincmd p')
|
call s:exec('wincmd p')
|
||||||
if oldwin == winnr() || (&modified && s:bufInWindows(winbufnr(winnr())) < 2)
|
if oldwin ==# winnr() || (&modified && s:bufInWindows(winbufnr(winnr())) < 2)
|
||||||
call s:exec('wincmd p')
|
call s:exec('wincmd p')
|
||||||
call self.openSplit()
|
call self.openSplit()
|
||||||
else
|
else
|
||||||
@@ -1254,14 +1275,14 @@ endfunction
|
|||||||
"Args:
|
"Args:
|
||||||
"forceOpen: 1 if this node should be opened regardless of file filters
|
"forceOpen: 1 if this node should be opened regardless of file filters
|
||||||
function! s:TreeDirNode._openRecursively2(forceOpen)
|
function! s:TreeDirNode._openRecursively2(forceOpen)
|
||||||
if self.path.ignore() == 0 || a:forceOpen
|
if self.path.ignore() ==# 0 || a:forceOpen
|
||||||
let self.isOpen = 1
|
let self.isOpen = 1
|
||||||
if self.children == []
|
if self.children ==# []
|
||||||
call self._initChildren(1)
|
call self._initChildren(1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
for i in self.children
|
for i in self.children
|
||||||
if i.path.isDirectory == 1
|
if i.path.isDirectory ==# 1
|
||||||
call i._openRecursively2(0)
|
call i._openRecursively2(0)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -1348,7 +1369,7 @@ endfunction
|
|||||||
"FUNCTION: TreeDirNode.toggleOpen() {{{3
|
"FUNCTION: TreeDirNode.toggleOpen() {{{3
|
||||||
"Opens this directory if it is closed and vice versa
|
"Opens this directory if it is closed and vice versa
|
||||||
function! s:TreeDirNode.toggleOpen()
|
function! s:TreeDirNode.toggleOpen()
|
||||||
if self.isOpen == 1
|
if self.isOpen ==# 1
|
||||||
call self.close()
|
call self.close()
|
||||||
else
|
else
|
||||||
call self.open()
|
call self.open()
|
||||||
@@ -1427,7 +1448,7 @@ endfunction
|
|||||||
"FUNCTION: Path.changeToDir() {{{3
|
"FUNCTION: Path.changeToDir() {{{3
|
||||||
function! s:Path.changeToDir()
|
function! s:Path.changeToDir()
|
||||||
let dir = self.strForCd()
|
let dir = self.strForCd()
|
||||||
if self.isDirectory == 0
|
if self.isDirectory ==# 0
|
||||||
let dir = self.getPathTrunk().strForCd()
|
let dir = self.getPathTrunk().strForCd()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -1454,7 +1475,7 @@ function! s:Path.compareTo(path)
|
|||||||
let thatPath = a:path.getLastPathComponent(1)
|
let thatPath = a:path.getLastPathComponent(1)
|
||||||
|
|
||||||
"if the paths are the same then clearly we return 0
|
"if the paths are the same then clearly we return 0
|
||||||
if thisPath == thatPath
|
if thisPath ==# thatPath
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -1689,11 +1710,11 @@ function! s:Path.ignore()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
"dont show hidden files unless instructed to
|
"dont show hidden files unless instructed to
|
||||||
if b:NERDTreeShowHidden == 0 && lastPathComponent =~ '^\.'
|
if b:NERDTreeShowHidden ==# 0 && lastPathComponent =~ '^\.'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if b:NERDTreeShowFiles == 0 && self.isDirectory == 0
|
if b:NERDTreeShowFiles ==# 0 && self.isDirectory ==# 0
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -1717,7 +1738,7 @@ endfunction
|
|||||||
"Args:
|
"Args:
|
||||||
"path: the other path obj to compare this with
|
"path: the other path obj to compare this with
|
||||||
function! s:Path.equals(path)
|
function! s:Path.equals(path)
|
||||||
return self.str(0) == a:path.str(0)
|
return self.str(0) ==# a:path.str(0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.New() {{{3
|
"FUNCTION: Path.New() {{{3
|
||||||
@@ -1741,7 +1762,7 @@ function! s:Path.readInfoFromDisk(fullpath)
|
|||||||
|
|
||||||
let fullpath = s:Path.WinToUnixPath(a:fullpath)
|
let fullpath = s:Path.WinToUnixPath(a:fullpath)
|
||||||
|
|
||||||
if getftype(fullpath) == "fifo"
|
if getftype(fullpath) ==# "fifo"
|
||||||
throw "NERDTree.InvalidFiletypeError: Cant handle FIFO files: " . a:fullpath
|
throw "NERDTree.InvalidFiletypeError: Cant handle FIFO files: " . a:fullpath
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -1752,7 +1773,7 @@ function! s:Path.readInfoFromDisk(fullpath)
|
|||||||
let self.isDirectory = 1
|
let self.isDirectory = 1
|
||||||
elseif filereadable(a:fullpath)
|
elseif filereadable(a:fullpath)
|
||||||
let self.isDirectory = 0
|
let self.isDirectory = 0
|
||||||
let self.isReadOnly = filewritable(a:fullpath) == 0
|
let self.isReadOnly = filewritable(a:fullpath) ==# 0
|
||||||
else
|
else
|
||||||
throw "NERDTree.InvalidArgumentsError: Invalid path = " . a:fullpath
|
throw "NERDTree.InvalidArgumentsError: Invalid path = " . a:fullpath
|
||||||
endif
|
endif
|
||||||
@@ -1796,7 +1817,7 @@ endfunction
|
|||||||
"
|
"
|
||||||
"Renames this node on the filesystem
|
"Renames this node on the filesystem
|
||||||
function! s:Path.rename(newPath)
|
function! s:Path.rename(newPath)
|
||||||
if a:newPath == ''
|
if a:newPath ==# ''
|
||||||
throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath
|
throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -1862,7 +1883,7 @@ endfunction
|
|||||||
"Return:
|
"Return:
|
||||||
"a string that can be used in the view to represent this path
|
"a string that can be used in the view to represent this path
|
||||||
function! s:Path.strDisplay()
|
function! s:Path.strDisplay()
|
||||||
if self.cachedDisplayString == ""
|
if self.cachedDisplayString ==# ""
|
||||||
call self.cacheDisplayString()
|
call self.cacheDisplayString()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -1882,12 +1903,14 @@ function! s:Path.strForEditCmd()
|
|||||||
let cwd = tolower(getcwd())
|
let cwd = tolower(getcwd())
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let cwd = cwd . s:os_slash
|
||||||
|
|
||||||
"return a relative path if we can
|
"return a relative path if we can
|
||||||
if stridx(p, cwd) == 0
|
if stridx(p, cwd) ==# 0
|
||||||
let p = strpart(p, strlen(cwd)+1)
|
let p = strpart(p, strlen(cwd))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if p == ''
|
if p ==# ''
|
||||||
let p = '.'
|
let p = '.'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -1985,7 +2008,7 @@ function! s:bufInWindows(bnum)
|
|||||||
if bufnum < 0
|
if bufnum < 0
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
if bufnum == a:bnum
|
if bufnum ==# a:bnum
|
||||||
let cnt = cnt + 1
|
let cnt = cnt + 1
|
||||||
endif
|
endif
|
||||||
let winnum = winnum + 1
|
let winnum = winnum + 1
|
||||||
@@ -2030,7 +2053,7 @@ function! s:initNerdTree(name)
|
|||||||
if s:Bookmark.BookmarkExistsFor(a:name)
|
if s:Bookmark.BookmarkExistsFor(a:name)
|
||||||
let path = s:Bookmark.BookmarkFor(a:name).path
|
let path = s:Bookmark.BookmarkFor(a:name).path
|
||||||
else
|
else
|
||||||
let dir = a:name == '' ? getcwd() : a:name
|
let dir = a:name ==# '' ? getcwd() : a:name
|
||||||
|
|
||||||
"hack to get an absolute path if a relative path is given
|
"hack to get an absolute path if a relative path is given
|
||||||
if dir =~ '^\.'
|
if dir =~ '^\.'
|
||||||
@@ -2122,6 +2145,8 @@ function! s:initNerdTreeInPlace(dir)
|
|||||||
setlocal cursorline
|
setlocal cursorline
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
call s:setupStatusline()
|
||||||
|
|
||||||
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
|
||||||
@@ -2169,12 +2194,12 @@ function! s:initNerdTreeMirror()
|
|||||||
let choices = ["Choose a tree to mirror"]
|
let choices = ["Choose a tree to mirror"]
|
||||||
let choices = extend(choices, sort(keys(options)))
|
let choices = extend(choices, sort(keys(options)))
|
||||||
let choice = inputlist(choices)
|
let choice = inputlist(choices)
|
||||||
if choice < 1 || choice > len(options) || choice == ''
|
if choice < 1 || choice > len(options) || choice ==# ''
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let bufferName = options[keys(options)[choice-1]]
|
let bufferName = options[keys(options)[choice-1]]
|
||||||
elseif len(keys(options)) == 1
|
elseif len(keys(options)) ==# 1
|
||||||
let bufferName = values(options)[0]
|
let bufferName = values(options)[0]
|
||||||
else
|
else
|
||||||
call s:echo("No trees to mirror")
|
call s:echo("No trees to mirror")
|
||||||
@@ -2231,7 +2256,7 @@ endfunction
|
|||||||
function! s:unique(list)
|
function! s:unique(list)
|
||||||
let uniqlist = []
|
let uniqlist = []
|
||||||
for elem in a:list
|
for elem in a:list
|
||||||
if index(uniqlist, elem) == -1
|
if index(uniqlist, elem) ==# -1
|
||||||
let uniqlist += [elem]
|
let uniqlist += [elem]
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -2328,20 +2353,23 @@ endfunction
|
|||||||
"options etc
|
"options etc
|
||||||
function! s:createTreeWin()
|
function! s:createTreeWin()
|
||||||
"create the nerd tree window
|
"create the nerd tree window
|
||||||
let splitLocation = g:NERDTreeWinPos == "left" ? "topleft " : "botright "
|
let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright "
|
||||||
let splitSize = g:NERDTreeWinSize
|
let splitSize = g:NERDTreeWinSize
|
||||||
|
|
||||||
if !exists('t:NERDTreeBufName')
|
if !exists('t:NERDTreeBufName')
|
||||||
let t:NERDTreeBufName = s:nextBufferName()
|
let t:NERDTreeBufName = s:nextBufferName()
|
||||||
|
silent! exec splitLocation . 'vertical ' . splitSize . ' new'
|
||||||
|
silent! exec "edit " . t:NERDTreeBufName
|
||||||
|
else
|
||||||
|
silent! exec splitLocation . 'vertical ' . splitSize . ' split'
|
||||||
|
silent! exec "buffer " . t:NERDTreeBufName
|
||||||
endif
|
endif
|
||||||
let cmd = splitLocation . 'vertical ' . splitSize . ' new ' . t:NERDTreeBufName
|
|
||||||
silent! execute cmd
|
|
||||||
|
|
||||||
setlocal winfixwidth
|
setlocal winfixwidth
|
||||||
|
|
||||||
"throwaway buffer options
|
"throwaway buffer options
|
||||||
setlocal noswapfile
|
setlocal noswapfile
|
||||||
setlocal buftype=nofile
|
setlocal buftype=nofile
|
||||||
"setlocal bufhidden=delete
|
|
||||||
setlocal nowrap
|
setlocal nowrap
|
||||||
setlocal foldcolumn=0
|
setlocal foldcolumn=0
|
||||||
setlocal nobuflisted
|
setlocal nobuflisted
|
||||||
@@ -2358,7 +2386,7 @@ function! s:createTreeWin()
|
|||||||
setlocal cursorline
|
setlocal cursorline
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
call s:setupStatusline()
|
||||||
|
|
||||||
call s:bindMappings()
|
call s:bindMappings()
|
||||||
setfiletype nerdtree
|
setfiletype nerdtree
|
||||||
@@ -2372,17 +2400,18 @@ endfunction
|
|||||||
"prints out the quick help
|
"prints out the quick help
|
||||||
function! s:dumpHelp()
|
function! s:dumpHelp()
|
||||||
let old_h = @h
|
let old_h = @h
|
||||||
if b:treeShowHelp == 1
|
if b:treeShowHelp ==# 1
|
||||||
let @h= "\" NERD tree (" . s:NERD_tree_version . ") quickhelp~\n"
|
let @h= "\" NERD tree (" . s:NERD_tree_version . ") quickhelp~\n"
|
||||||
let @h=@h."\" ============================\n"
|
let @h=@h."\" ============================\n"
|
||||||
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"
|
||||||
if b:NERDTreeType == "primary"
|
let @h=@h."\" <CR>,\n"
|
||||||
|
if b:NERDTreeType ==# "primary"
|
||||||
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 ==# "primary"
|
||||||
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"
|
||||||
@@ -2390,11 +2419,13 @@ function! s:dumpHelp()
|
|||||||
let @h=@h."\" middle-click,\n"
|
let @h=@h."\" middle-click,\n"
|
||||||
let @h=@h."\" ". g:NERDTreeMapOpenSplit .": open split\n"
|
let @h=@h."\" ". g:NERDTreeMapOpenSplit .": open split\n"
|
||||||
let @h=@h."\" ". g:NERDTreeMapPreviewSplit .": preview split\n"
|
let @h=@h."\" ". g:NERDTreeMapPreviewSplit .": preview split\n"
|
||||||
|
let @h=@h."\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n"
|
||||||
|
let @h=@h."\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n"
|
||||||
let @h=@h."\" ". g:NERDTreeMapExecute.": Execute file\n"
|
let @h=@h."\" ". g:NERDTreeMapExecute.": Execute file\n"
|
||||||
|
|
||||||
let @h=@h."\"\n\" ----------------------------\n"
|
let @h=@h."\"\n\" ----------------------------\n"
|
||||||
let @h=@h."\" Directory node mappings~\n"
|
let @h=@h."\" Directory node mappings~\n"
|
||||||
let @h=@h."\" ". (g:NERDTreeMouseMode == 1 ? "double" : "single") ."-click,\n"
|
let @h=@h."\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n"
|
||||||
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n"
|
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n"
|
||||||
let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n"
|
let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n"
|
||||||
let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n"
|
let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n"
|
||||||
@@ -2487,14 +2518,15 @@ function! s:echoError(msg)
|
|||||||
call s:echo(a:msg)
|
call s:echo(a:msg)
|
||||||
echohl normal
|
echohl normal
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:firstNormalWindow(){{{2
|
"FUNCTION: s:firstUsableWindow(){{{2
|
||||||
"find the window number of the first normal window
|
"find the window number of the first normal window
|
||||||
function! s:firstNormalWindow()
|
function! s:firstUsableWindow()
|
||||||
let i = 1
|
let i = 1
|
||||||
while i <= winnr("$")
|
while i <= winnr("$")
|
||||||
let bnum = winbufnr(i)
|
let bnum = winbufnr(i)
|
||||||
if bnum != -1 && getbufvar(bnum, '&buftype') == ''
|
if bnum != -1 && getbufvar(bnum, '&buftype') ==# ''
|
||||||
\ && !getwinvar(i, '&previewwindow')
|
\ && !getwinvar(i, '&previewwindow')
|
||||||
|
\ && (!getbufvar(bnum, '&modified') || &hidden)
|
||||||
return i
|
return i
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2525,7 +2557,7 @@ function! s:getPath(ln)
|
|||||||
return {}
|
return {}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if line == s:tree_up_dir_line
|
if line ==# s:tree_up_dir_line
|
||||||
return b:NERDTreeRoot.path.getParent()
|
return b:NERDTreeRoot.path.getParent()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2601,14 +2633,14 @@ function! s:isTreeOpen()
|
|||||||
return s:getTreeWinNum() != -1
|
return s:getTreeWinNum() != -1
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:isWindowUsable(winnumber) {{{2
|
"FUNCTION: s:isWindowUsable(winnumber) {{{2
|
||||||
"Returns 1 if opening a file from the tree in the given window requires it to
|
"Returns 0 if opening a file from the tree in the given window requires it to
|
||||||
"be split
|
"be split, 1 otherwise
|
||||||
"
|
"
|
||||||
"Args:
|
"Args:
|
||||||
"winnumber: the number of the window in question
|
"winnumber: the number of the window in question
|
||||||
function! s:isWindowUsable(winnumber)
|
function! s:isWindowUsable(winnumber)
|
||||||
"gotta split if theres only one window (i.e. the NERD tree)
|
"gotta split if theres only one window (i.e. the NERD tree)
|
||||||
if winnr("$") == 1
|
if winnr("$") ==# 1
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2636,7 +2668,7 @@ endfunction
|
|||||||
" direction: 0 if going to first child, 1 if going to last
|
" direction: 0 if going to first child, 1 if going to last
|
||||||
function! s:jumpToChild(direction)
|
function! s:jumpToChild(direction)
|
||||||
let currentNode = s:TreeFileNode.GetSelected()
|
let currentNode = s:TreeFileNode.GetSelected()
|
||||||
if currentNode == {} || currentNode.isRoot()
|
if currentNode ==# {} || currentNode.isRoot()
|
||||||
call s:echo("cannot jump to " . (a:direction ? "last" : "first") . " child")
|
call s:echo("cannot jump to " . (a:direction ? "last" : "first") . " child")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -2672,7 +2704,7 @@ endfunction
|
|||||||
" del the buffer
|
" del the buffer
|
||||||
function! s:promptToDelBuffer(bufnum, msg)
|
function! s:promptToDelBuffer(bufnum, msg)
|
||||||
echo a:msg
|
echo a:msg
|
||||||
if nr2char(getchar()) == 'y'
|
if nr2char(getchar()) ==# 'y'
|
||||||
exec "silent bdelete! " . a:bufnum
|
exec "silent bdelete! " . a:bufnum
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@@ -2825,6 +2857,12 @@ function! s:saveScreenState()
|
|||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: s:setupStatusline() {{{2
|
||||||
|
function! s:setupStatusline()
|
||||||
|
if g:NERDTreeStatusline != -1
|
||||||
|
let &l:statusline = g:NERDTreeStatusline
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
"FUNCTION: s:setupSyntaxHighlighting() {{{2
|
"FUNCTION: s:setupSyntaxHighlighting() {{{2
|
||||||
function! s:setupSyntaxHighlighting()
|
function! s:setupSyntaxHighlighting()
|
||||||
"treeFlags are syntax items that should be invisible, but give clues as to
|
"treeFlags are syntax items that should be invisible, but give clues as to
|
||||||
@@ -2942,7 +2980,7 @@ function! s:stripMarkupFromLine(line, removeLeadingSpaces)
|
|||||||
let wasdir = 1
|
let wasdir = 1
|
||||||
endif
|
endif
|
||||||
let line = substitute (line,' -> .*',"","") " remove link to
|
let line = substitute (line,' -> .*',"","") " remove link to
|
||||||
if wasdir == 1
|
if wasdir ==# 1
|
||||||
let line = substitute (line, '/\?$', '/', "")
|
let line = substitute (line, '/\?$', '/', "")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2984,7 +3022,7 @@ endfunction
|
|||||||
"args:
|
"args:
|
||||||
"forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set
|
"forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set
|
||||||
function! s:activateNode(forceKeepWindowOpen)
|
function! s:activateNode(forceKeepWindowOpen)
|
||||||
if getline(".") == s:tree_up_dir_line
|
if getline(".") ==# s:tree_up_dir_line
|
||||||
return s:upDir(0)
|
return s:upDir(0)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -3007,7 +3045,8 @@ function! s:activateNode(forceKeepWindowOpen)
|
|||||||
call bookmark.toRoot()
|
call bookmark.toRoot()
|
||||||
else
|
else
|
||||||
if bookmark.validate()
|
if bookmark.validate()
|
||||||
call (s:TreeFileNode.New(bookmark.path)).open()
|
let n = s:TreeFileNode.New(bookmark.path)
|
||||||
|
call n.open()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@@ -3022,11 +3061,14 @@ function! s:bindMappings()
|
|||||||
nnoremap <silent> <buffer> <2-leftmouse> :call <SID>activateNode(0)<cr>
|
nnoremap <silent> <buffer> <2-leftmouse> :call <SID>activateNode(0)<cr>
|
||||||
|
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapActivateNode . " :call <SID>activateNode(0)<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapActivateNode . " :call <SID>activateNode(0)<cr>"
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenSplit ." :call <SID>openEntrySplit(0)<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenSplit ." :call <SID>openEntrySplit(0,0)<cr>"
|
||||||
|
exec "nnoremap <silent> <buffer> <cr> :call <SID>activateNode(0)<cr>"
|
||||||
|
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapPreview ." :call <SID>previewNode(0)<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapPreview ." :call <SID>previewNode(0)<cr>"
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapPreviewSplit ." :call <SID>previewNode(1)<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapPreviewSplit ." :call <SID>previewNode(1)<cr>"
|
||||||
|
|
||||||
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenVSplit ." :call <SID>openEntrySplit(1,0)<cr>"
|
||||||
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapPreviewVSplit ." :call <SID>previewNode(2)<cr>"
|
||||||
|
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapExecute ." :call <SID>executeNode()<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapExecute ." :call <SID>executeNode()<cr>"
|
||||||
|
|
||||||
@@ -3112,7 +3154,7 @@ function! s:checkForActivate()
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if (g:NERDTreeMouseMode == 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode == 3
|
if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3
|
||||||
if char !~ s:tree_markup_reg && startToCur !~ '\/$'
|
if char !~ s:tree_markup_reg && startToCur !~ '\/$'
|
||||||
call s:activateNode(0)
|
call s:activateNode(0)
|
||||||
return
|
return
|
||||||
@@ -3124,7 +3166,7 @@ endfunction
|
|||||||
" FUNCTION: s:chCwd() {{{2
|
" FUNCTION: s:chCwd() {{{2
|
||||||
function! s:chCwd()
|
function! s:chCwd()
|
||||||
let treenode = s:TreeFileNode.GetSelected()
|
let treenode = s:TreeFileNode.GetSelected()
|
||||||
if treenode == {}
|
if treenode ==# {}
|
||||||
call s:echo("Select a node first")
|
call s:echo("Select a node first")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3140,7 +3182,7 @@ endfunction
|
|||||||
" changes the current root to the selected one
|
" changes the current root to the selected one
|
||||||
function! s:chRoot()
|
function! s:chRoot()
|
||||||
let treenode = s:TreeFileNode.GetSelected()
|
let treenode = s:TreeFileNode.GetSelected()
|
||||||
if treenode == {}
|
if treenode ==# {}
|
||||||
call s:echo("Select a node first")
|
call s:echo("Select a node first")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3152,7 +3194,7 @@ endfunction
|
|||||||
|
|
||||||
" FUNCTION: s:clearBookmarks(bookmarks) {{{2
|
" FUNCTION: s:clearBookmarks(bookmarks) {{{2
|
||||||
function! s:clearBookmarks(bookmarks)
|
function! s:clearBookmarks(bookmarks)
|
||||||
if a:bookmarks == ''
|
if a:bookmarks ==# ''
|
||||||
let currentNode = s:TreeFileNode.GetSelected()
|
let currentNode = s:TreeFileNode.GetSelected()
|
||||||
if currentNode != {}
|
if currentNode != {}
|
||||||
call currentNode.clearBoomarks()
|
call currentNode.clearBoomarks()
|
||||||
@@ -3169,7 +3211,7 @@ endfunction
|
|||||||
" closes all childnodes of the current node
|
" closes all childnodes of the current node
|
||||||
function! s:closeChildren()
|
function! s:closeChildren()
|
||||||
let currentNode = s:TreeDirNode.GetSelected()
|
let currentNode = s:TreeDirNode.GetSelected()
|
||||||
if currentNode == {}
|
if currentNode ==# {}
|
||||||
call s:echo("Select a node first")
|
call s:echo("Select a node first")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3182,7 +3224,7 @@ endfunction
|
|||||||
" closes the parent dir of the current node
|
" closes the parent dir of the current node
|
||||||
function! s:closeCurrentDir()
|
function! s:closeCurrentDir()
|
||||||
let treenode = s:TreeFileNode.GetSelected()
|
let treenode = s:TreeFileNode.GetSelected()
|
||||||
if treenode == {}
|
if treenode ==# {}
|
||||||
call s:echo("Select a node first")
|
call s:echo("Select a node first")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3199,7 +3241,7 @@ endfunction
|
|||||||
" FUNCTION: s:closeTreeWindow() {{{2
|
" FUNCTION: s:closeTreeWindow() {{{2
|
||||||
" close the tree window
|
" close the tree window
|
||||||
function! s:closeTreeWindow()
|
function! s:closeTreeWindow()
|
||||||
if b:NERDTreeType == "secondary" && b:NERDTreePreviousBuf != -1
|
if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1
|
||||||
exec "buffer " . b:NERDTreePreviousBuf
|
exec "buffer " . b:NERDTreePreviousBuf
|
||||||
else
|
else
|
||||||
if winnr("$") > 1
|
if winnr("$") > 1
|
||||||
@@ -3212,7 +3254,7 @@ endfunction
|
|||||||
" FUNCTION: s:copyNode() {{{2
|
" FUNCTION: s:copyNode() {{{2
|
||||||
function! s:copyNode()
|
function! s:copyNode()
|
||||||
let currentNode = s:TreeFileNode.GetSelected()
|
let currentNode = s:TreeFileNode.GetSelected()
|
||||||
if currentNode == {}
|
if currentNode ==# {}
|
||||||
call s:echo("Put the cursor on a file node first")
|
call s:echo("Put the cursor on a file node first")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3230,7 +3272,7 @@ function! s:copyNode()
|
|||||||
if currentNode.path.copyingWillOverwrite(newNodePath)
|
if currentNode.path.copyingWillOverwrite(newNodePath)
|
||||||
call s:echo("\nWarning: copying may overwrite files! Continue? (yN)")
|
call s:echo("\nWarning: copying may overwrite files! Continue? (yN)")
|
||||||
let choice = nr2char(getchar())
|
let choice = nr2char(getchar())
|
||||||
let confirmed = choice == 'y'
|
let confirmed = choice ==# 'y'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if confirmed
|
if confirmed
|
||||||
@@ -3252,14 +3294,14 @@ endfunction
|
|||||||
" if the cursor is on a bookmark, prompt to delete
|
" if the cursor is on a bookmark, prompt to delete
|
||||||
function! s:deleteBookmark()
|
function! s:deleteBookmark()
|
||||||
let bookmark = s:getSelectedBookmark()
|
let bookmark = s:getSelectedBookmark()
|
||||||
if bookmark == {}
|
if bookmark ==# {}
|
||||||
call s:echo("Put the cursor on a bookmark")
|
call s:echo("Put the cursor on a bookmark")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
echo "Are you sure you wish to delete the bookmark:\n\"" . bookmark.name . "\" (yN):"
|
echo "Are you sure you wish to delete the bookmark:\n\"" . bookmark.name . "\" (yN):"
|
||||||
|
|
||||||
if nr2char(getchar()) == 'y'
|
if nr2char(getchar()) ==# 'y'
|
||||||
try
|
try
|
||||||
call bookmark.delete()
|
call bookmark.delete()
|
||||||
call s:renderView()
|
call s:renderView()
|
||||||
@@ -3278,7 +3320,7 @@ endfunction
|
|||||||
" to delete it
|
" to delete it
|
||||||
function! s:deleteNode()
|
function! s:deleteNode()
|
||||||
let currentNode = s:TreeFileNode.GetSelected()
|
let currentNode = s:TreeFileNode.GetSelected()
|
||||||
if currentNode == {}
|
if currentNode ==# {}
|
||||||
call s:echo("Put the cursor on a file node first")
|
call s:echo("Put the cursor on a file node first")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3290,14 +3332,14 @@ function! s:deleteNode()
|
|||||||
\ "==========================================================\n" .
|
\ "==========================================================\n" .
|
||||||
\ "STOP! To delete this entire directory, type 'yes'\n" .
|
\ "STOP! To delete this entire directory, type 'yes'\n" .
|
||||||
\ "" . currentNode.path.strForOS(0) . ": ")
|
\ "" . currentNode.path.strForOS(0) . ": ")
|
||||||
let confirmed = choice == 'yes'
|
let confirmed = choice ==# 'yes'
|
||||||
else
|
else
|
||||||
echo "Delete the current node\n" .
|
echo "Delete the current node\n" .
|
||||||
\ "==========================================================\n".
|
\ "==========================================================\n".
|
||||||
\ "Are you sure you wish to delete the node:\n" .
|
\ "Are you sure you wish to delete the node:\n" .
|
||||||
\ "" . currentNode.path.strForOS(0) . " (yN):"
|
\ "" . currentNode.path.strForOS(0) . " (yN):"
|
||||||
let choice = nr2char(getchar())
|
let choice = nr2char(getchar())
|
||||||
let confirmed = choice == 'y'
|
let confirmed = choice ==# 'y'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
@@ -3310,7 +3352,7 @@ function! s:deleteNode()
|
|||||||
"close that buffer
|
"close that buffer
|
||||||
let bufnum = bufnr(currentNode.path.str(0))
|
let bufnum = bufnr(currentNode.path.str(0))
|
||||||
if buflisted(bufnum)
|
if buflisted(bufnum)
|
||||||
let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) == -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
||||||
call s:promptToDelBuffer(bufnum, prompt)
|
call s:promptToDelBuffer(bufnum, prompt)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -3335,7 +3377,7 @@ endfunction
|
|||||||
" FUNCTION: s:executeNode() {{{2
|
" FUNCTION: s:executeNode() {{{2
|
||||||
function! s:executeNode()
|
function! s:executeNode()
|
||||||
let treenode = s:TreeFileNode.GetSelected()
|
let treenode = s:TreeFileNode.GetSelected()
|
||||||
if treenode == {} || treenode.path.isDirectory
|
if treenode ==# {} || treenode.path.isDirectory
|
||||||
call s:echo("Select an executable file node first" )
|
call s:echo("Select an executable file node first" )
|
||||||
else
|
else
|
||||||
echo "NERDTree executor\n" .
|
echo "NERDTree executor\n" .
|
||||||
@@ -3355,7 +3397,7 @@ endfunction
|
|||||||
" FUNCTION: s:handleMiddleMouse() {{{2
|
" FUNCTION: s:handleMiddleMouse() {{{2
|
||||||
function! s:handleMiddleMouse()
|
function! s:handleMiddleMouse()
|
||||||
let curNode = s:TreeFileNode.GetSelected()
|
let curNode = s:TreeFileNode.GetSelected()
|
||||||
if curNode == {}
|
if curNode ==# {}
|
||||||
call s:echo("Put the cursor on a node first" )
|
call s:echo("Put the cursor on a node first" )
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3363,7 +3405,7 @@ function! s:handleMiddleMouse()
|
|||||||
if curNode.path.isDirectory
|
if curNode.path.isDirectory
|
||||||
call s:openExplorer()
|
call s:openExplorer()
|
||||||
else
|
else
|
||||||
call s:openEntrySplit(0)
|
call s:openEntrySplit(0,0)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -3372,7 +3414,7 @@ endfunction
|
|||||||
" Adds a new node to the filesystem and then into the tree
|
" Adds a new node to the filesystem and then into the tree
|
||||||
function! s:insertNewNode()
|
function! s:insertNewNode()
|
||||||
let curDirNode = s:TreeDirNode.GetSelected()
|
let curDirNode = s:TreeDirNode.GetSelected()
|
||||||
if curDirNode == {}
|
if curDirNode ==# {}
|
||||||
call s:echo("Put the cursor on a node first" )
|
call s:echo("Put the cursor on a node first" )
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3382,7 +3424,7 @@ function! s:insertNewNode()
|
|||||||
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
|
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
|
||||||
\ "", curDirNode.path.strForGlob() . s:os_slash)
|
\ "", curDirNode.path.strForGlob() . s:os_slash)
|
||||||
|
|
||||||
if newNodeName == ''
|
if newNodeName ==# ''
|
||||||
call s:echo("Node Creation Aborted.")
|
call s:echo("Node Creation Aborted.")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3475,16 +3517,20 @@ function! s:openBookmark(name)
|
|||||||
call targetNode.open()
|
call targetNode.open()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: s:openEntrySplit(forceKeepWindowOpen) {{{2
|
" FUNCTION: s:openEntrySplit(vertical, forceKeepWindowOpen) {{{2
|
||||||
"Opens the currently selected file from the explorer in a
|
"Opens the currently selected file from the explorer in a
|
||||||
"new window
|
"new window
|
||||||
"
|
"
|
||||||
"args:
|
"args:
|
||||||
"forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set
|
"forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set
|
||||||
function! s:openEntrySplit(forceKeepWindowOpen)
|
function! s:openEntrySplit(vertical, forceKeepWindowOpen)
|
||||||
let treenode = s:TreeFileNode.GetSelected()
|
let treenode = s:TreeFileNode.GetSelected()
|
||||||
if treenode != {}
|
if treenode != {}
|
||||||
|
if a:vertical
|
||||||
|
call treenode.openVSplit()
|
||||||
|
else
|
||||||
call treenode.openSplit()
|
call treenode.openSplit()
|
||||||
|
endif
|
||||||
if !a:forceKeepWindowOpen
|
if !a:forceKeepWindowOpen
|
||||||
call s:closeTreeIfQuitOnOpen()
|
call s:closeTreeIfQuitOnOpen()
|
||||||
endif
|
endif
|
||||||
@@ -3538,7 +3584,7 @@ endfunction
|
|||||||
" FUNCTION: s:openNodeRecursively() {{{2
|
" FUNCTION: s:openNodeRecursively() {{{2
|
||||||
function! s:openNodeRecursively()
|
function! s:openNodeRecursively()
|
||||||
let treenode = s:TreeFileNode.GetSelected()
|
let treenode = s:TreeFileNode.GetSelected()
|
||||||
if treenode == {} || treenode.path.isDirectory == 0
|
if treenode ==# {} || treenode.path.isDirectory ==# 0
|
||||||
call s:echo("Select a directory node first" )
|
call s:echo("Select a directory node first" )
|
||||||
else
|
else
|
||||||
call s:echo("Recursively opening node. Please wait...")
|
call s:echo("Recursively opening node. Please wait...")
|
||||||
@@ -3551,10 +3597,13 @@ function! s:openNodeRecursively()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:previewNode() {{{2
|
"FUNCTION: s:previewNode() {{{2
|
||||||
|
"Args:
|
||||||
|
" openNewWin: if 0, use the previous window, if 1 open in new split, if 2
|
||||||
|
" open in a vsplit
|
||||||
function! s:previewNode(openNewWin)
|
function! s:previewNode(openNewWin)
|
||||||
let currentBuf = bufnr("")
|
let currentBuf = bufnr("")
|
||||||
if a:openNewWin
|
if a:openNewWin > 0
|
||||||
call s:openEntrySplit(1)
|
call s:openEntrySplit(a:openNewWin ==# 2,1)
|
||||||
else
|
else
|
||||||
call s:activateNode(1)
|
call s:activateNode(1)
|
||||||
end
|
end
|
||||||
@@ -3586,7 +3635,7 @@ endfunction
|
|||||||
" refreshes the root for the current node
|
" refreshes the root for the current node
|
||||||
function! s:refreshCurrent()
|
function! s:refreshCurrent()
|
||||||
let treenode = s:TreeDirNode.GetSelected()
|
let treenode = s:TreeDirNode.GetSelected()
|
||||||
if treenode == {}
|
if treenode ==# {}
|
||||||
call s:echo("Refresh failed. Select a node first")
|
call s:echo("Refresh failed. Select a node first")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3601,7 +3650,7 @@ endfunction
|
|||||||
" allows the user to rename the current node
|
" allows the user to rename the current node
|
||||||
function! s:renameCurrent()
|
function! s:renameCurrent()
|
||||||
let curNode = s:TreeFileNode.GetSelected()
|
let curNode = s:TreeFileNode.GetSelected()
|
||||||
if curNode == {}
|
if curNode ==# {}
|
||||||
call s:echo("Put the cursor on a node first" )
|
call s:echo("Put the cursor on a node first" )
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3611,7 +3660,7 @@ function! s:renameCurrent()
|
|||||||
\ "Enter the new path for the node: \n" .
|
\ "Enter the new path for the node: \n" .
|
||||||
\ "", curNode.path.strForOS(0))
|
\ "", curNode.path.strForOS(0))
|
||||||
|
|
||||||
if newNodePath == ''
|
if newNodePath ==# ''
|
||||||
call s:echo("Node Renaming Aborted.")
|
call s:echo("Node Renaming Aborted.")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3625,7 +3674,7 @@ function! s:renameCurrent()
|
|||||||
"if the node is open in a buffer, ask the user if they want to
|
"if the node is open in a buffer, ask the user if they want to
|
||||||
"close that buffer
|
"close that buffer
|
||||||
if bufnum != -1
|
if bufnum != -1
|
||||||
let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) == -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
||||||
call s:promptToDelBuffer(bufnum, prompt)
|
call s:promptToDelBuffer(bufnum, prompt)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -3640,7 +3689,7 @@ endfunction
|
|||||||
" FUNCTION: s:showFileSystemMenu() {{{2
|
" FUNCTION: s:showFileSystemMenu() {{{2
|
||||||
function! s:showFileSystemMenu()
|
function! s:showFileSystemMenu()
|
||||||
let curNode = s:TreeFileNode.GetSelected()
|
let curNode = s:TreeFileNode.GetSelected()
|
||||||
if curNode == {}
|
if curNode ==# {}
|
||||||
call s:echo("Put the cursor on a node first" )
|
call s:echo("Put the cursor on a node first" )
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -3717,7 +3766,7 @@ endfunction
|
|||||||
"re-rendered
|
"re-rendered
|
||||||
function! s:upDir(keepState)
|
function! s:upDir(keepState)
|
||||||
let cwd = b:NERDTreeRoot.path.str(0)
|
let cwd = b:NERDTreeRoot.path.str(0)
|
||||||
if cwd == "/" || cwd =~ '^[^/]..$'
|
if cwd ==# "/" || cwd =~ '^[^/]..$'
|
||||||
call s:echo("already at top dir")
|
call s:echo("already at top dir")
|
||||||
else
|
else
|
||||||
if !a:keepState
|
if !a:keepState
|
||||||
@@ -3734,7 +3783,10 @@ function! s:upDir(keepState)
|
|||||||
let b:NERDTreeRoot = newRoot
|
let b:NERDTreeRoot = newRoot
|
||||||
else
|
else
|
||||||
let b:NERDTreeRoot = b:NERDTreeRoot.parent
|
let b:NERDTreeRoot = b:NERDTreeRoot.parent
|
||||||
|
endif
|
||||||
|
|
||||||
|
if g:NERDTreeChDirMode ==# 2
|
||||||
|
exec 'cd ' . b:NERDTreeRoot.path.strForCd()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:renderView()
|
call s:renderView()
|
||||||
|
|||||||
Reference in New Issue
Block a user