mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80e0bca4dc | ||
|
|
04ea2eb0f7 | ||
|
|
25aaaaae42 | ||
|
|
8a32f5851f | ||
|
|
6018625170 | ||
|
|
c36aaf55f8 | ||
|
|
6e7960ba94 | ||
|
|
f1a9bd3c89 | ||
|
|
191dcc4068 | ||
|
|
0d62ffd5db | ||
|
|
510f890ee1 | ||
|
|
06db1cdf2c | ||
|
|
0eaaf6842c | ||
|
|
2ed6524b9d | ||
|
|
fb7f66dc47 | ||
|
|
dcf9e956a7 | ||
|
|
8aafa66eac | ||
|
|
f2ce7390b8 | ||
|
|
7275d89a35 | ||
|
|
e6479c36f3 | ||
|
|
da76bafaef | ||
|
|
ec76876a74 | ||
|
|
ef1a466342 | ||
|
|
56dd5f05ab | ||
|
|
92a006f51c | ||
|
|
7d1cc4ecec | ||
|
|
c008fb3983 | ||
|
|
8654b98b09 | ||
|
|
5e3e95d168 | ||
|
|
faabc8c47d | ||
|
|
91d5a52c39 |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*~
|
||||
*.swp
|
||||
tags
|
||||
18
Rakefile
Normal file
18
Rakefile
Normal file
@@ -0,0 +1,18 @@
|
||||
desc "Copy the vim/doc files into ~/.vim"
|
||||
task :deploy_local do
|
||||
run "cp plugin/NERD_tree.vim ~/.vim/plugin"
|
||||
run "cp doc/NERD_tree.txt ~/.vim/doc"
|
||||
end
|
||||
|
||||
|
||||
desc "Create a zip archive for release to vim.org"
|
||||
task :zip do
|
||||
abort "NERD_tree.zip already exists, aborting" if File.exist?("NERD_tree.zip")
|
||||
run "zip NERD_tree.zip plugin/NERD_tree.vim doc/NERD_tree.txt"
|
||||
end
|
||||
|
||||
def run(cmd)
|
||||
puts "Executing: #{cmd}"
|
||||
system cmd
|
||||
end
|
||||
|
||||
@@ -63,7 +63,8 @@ The following features and functionality are provided by the NERD tree:
|
||||
* optional displaying of hidden files (. files)
|
||||
* files can be "turned off" so that only directories are displayed
|
||||
* A textual filesystem menu is provided which allows you to
|
||||
create/delete/rename file and directory nodes
|
||||
create/delete/rename file and directory nodes as well as copy (for
|
||||
supported OSs)
|
||||
* The position and size of the NERD tree window can be customised
|
||||
* The order in which the nodes in the tree are listed can be customised.
|
||||
* A model of your filesystem is created/maintained as you explore it. This
|
||||
@@ -95,6 +96,9 @@ The following features and functionality are provided by the NERD tree:
|
||||
rendered again. If no NERD tree exists for this tab then this
|
||||
command acts the same as the |:NERDTree| command.
|
||||
|
||||
:NERDTreeClose
|
||||
Close the NERD tree in this tab.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2. NERD tree Mappings *NERDTreeMappings*
|
||||
|
||||
@@ -477,6 +481,9 @@ NERD tree. These options should be set in your vimrc.
|
||||
|NERDTreeShowHidden| Tells the NERD tree whether to display hidden
|
||||
files on startup.
|
||||
|
||||
|NERDTreeShowLineNumbers| Tells the NERD tree whether to display line
|
||||
numbers in the tree window.
|
||||
|
||||
|NERDTreeSortOrder| Tell the NERD tree how to sort the nodes in
|
||||
the tree.
|
||||
|
||||
@@ -578,10 +585,6 @@ the CWD is changed whenever the tree root is changed. For example, if the CWD
|
||||
is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new
|
||||
root then the CWD will become /home/marty/foobar/baz.
|
||||
|
||||
Note to windows users: it is highly recommended that you have this option set
|
||||
to either 1 or 2 or else the script wont function properly if you attempt to
|
||||
open a NERD tree on a different drive to the one vim is currently in.
|
||||
|
||||
Authors note: at work i have this option set to 1 because i have a giant ctags
|
||||
file in the root dir of my project. This way i can initialise the NERD tree
|
||||
with the root dir of my project and always have ctags available to me --- no
|
||||
@@ -658,6 +661,17 @@ Use one of the follow lines to set this option: >
|
||||
let NERDTreeShowHidden=0
|
||||
let NERDTreeShowHidden=1
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*NERDTreeShowLineNumbers*
|
||||
Values: 0 or 1.
|
||||
Default: 0.
|
||||
|
||||
This option tells vim whether to display line numbers for the NERD tree
|
||||
window. Use one of the follow lines to set this option: >
|
||||
let NERDTreeShowLineNumbers=0
|
||||
let NERDTreeShowLineNumbers=1
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*NERDTreeSortOrder*
|
||||
@@ -688,7 +702,7 @@ Other examples: >
|
||||
(3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$']
|
||||
<
|
||||
1. Directories will appear last, everything else will appear above.
|
||||
2. Every will simply appear in alphabetical order.
|
||||
2. Everything will simply appear in alphabetical order.
|
||||
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.
|
||||
|
||||
@@ -770,6 +784,22 @@ fridge for later ;)
|
||||
==============================================================================
|
||||
7. Changelog *NERDTreeChangelog*
|
||||
|
||||
2.9.0
|
||||
|
||||
- path handling improvements, thanks to Zhang Shuhan for heaps of
|
||||
testing/bug reports
|
||||
* improved how paths are stored, now the script will no longer get
|
||||
confused about drives on MF Windows
|
||||
* made the script way better at handling paths with strange characters
|
||||
in them (eg '$@; etc)
|
||||
- applied a patch from Cory Echols
|
||||
* add the command :NERDTreeClose to close the tree for the current tab
|
||||
* set the filetype for the NERD tree buffer to "nerdtree"
|
||||
|
||||
2.8.0
|
||||
- added an option to enable/disable line numbers in the NERD tree window,
|
||||
thanks to Olivier Yiptong for the email.
|
||||
|
||||
2.7.1
|
||||
- Changed the keys for the filesystem menu to be mnemonic rather than
|
||||
arbitrary integers
|
||||
@@ -978,3 +1008,9 @@ in 2.6.0
|
||||
Thanks to Niels Aan de Brugh for the suggestion that the script now split the
|
||||
window if you try to open a file in a window containing a modified buffer when
|
||||
the &hidden option is set.
|
||||
|
||||
Thanks to Olivier Yiptong for prompting me to make line numbers in the
|
||||
NERD tree window optional.
|
||||
|
||||
Thanks to Zhang Shuhan for all of his emails and testing to help improve the
|
||||
NERD tree path handling.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
" vim global plugin that provides a nice tree explorer
|
||||
" Last Change: 18 jan 2008
|
||||
" Last Change: 17 May 2008
|
||||
" Maintainer: Martin Grenfell <martin_grenfell at msn dot com>
|
||||
let s:NERD_tree_version = '2.7.1'
|
||||
let s:NERD_tree_version = '2.9.0'
|
||||
|
||||
" SECTION: Script init stuff {{{1
|
||||
"============================================================
|
||||
@@ -43,8 +43,9 @@ endif
|
||||
call s:InitVariable("g:NERDTreeHighlightCursorline", 1)
|
||||
call s:InitVariable("g:NERDTreeMouseMode", 1)
|
||||
call s:InitVariable("g:NERDTreeNotificationThreshold", 100)
|
||||
call s:InitVariable("g:NERDTreeShowHidden", 0)
|
||||
call s:InitVariable("g:NERDTreeShowFiles", 1)
|
||||
call s:InitVariable("g:NERDTreeShowHidden", 0)
|
||||
call s:InitVariable("g:NERDTreeShowLineNumbers", 0)
|
||||
call s:InitVariable("g:NERDTreeSortDirs", 1)
|
||||
|
||||
if !exists("g:NERDTreeSortOrder")
|
||||
@@ -109,7 +110,7 @@ call s:InitVariable("g:NERDTreeMapUpdir", "u")
|
||||
call s:InitVariable("g:NERDTreeMapUpdirKeepOpen", "U")
|
||||
|
||||
"SECTION: Script level variable declaration{{{2
|
||||
let s:escape_chars = " `|\"~'#"
|
||||
let s:escape_chars = " \\`\|\"#%&,?()\*^<>"
|
||||
let s:NERDTreeWinName = '_NERD_tree_'
|
||||
|
||||
"init all the nerd tree markup
|
||||
@@ -138,6 +139,7 @@ endif
|
||||
"init the command that users start the nerd tree with
|
||||
command! -n=? -complete=dir NERDTree :call s:InitNerdTree('<args>')
|
||||
command! -n=? -complete=dir NERDTreeToggle :call s:Toggle('<args>')
|
||||
command! -n=0 NERDTreeClose :call s:CloseTreeIfOpen()
|
||||
" SECTION: Auto commands {{{1
|
||||
"============================================================
|
||||
"Save the cursor position whenever we close the nerd tree
|
||||
@@ -307,7 +309,8 @@ endfunction
|
||||
"FUNCTION: oTreeFileNode.Rename {{{3
|
||||
"Calls the rename method for this nodes path obj
|
||||
function! s:oTreeFileNode.Rename(newName) dict
|
||||
call self.path.Rename(a:newName)
|
||||
let newName = substitute(a:newName, '\(\\\|\/\)$', '', '')
|
||||
call self.path.Rename(newName)
|
||||
call self.parent.RemoveChild(self)
|
||||
|
||||
let parentPath = self.path.GetPathTrunk()
|
||||
@@ -317,7 +320,6 @@ function! s:oTreeFileNode.Rename(newName) dict
|
||||
call newParent.CreateChild(self.path, 1)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oTreeFileNode.StrDisplay() {{{3
|
||||
"
|
||||
"Returns a string that specifies how the node should be represented as a
|
||||
@@ -552,7 +554,7 @@ function! s:oTreeDirNode.InitChildren(silent) dict
|
||||
|
||||
"get an array of all the files in the nodes dir
|
||||
let dir = self.path
|
||||
let filesStr = globpath(dir.StrForOS(0), '*') . "\n" . globpath(dir.StrForOS(0), '.*')
|
||||
let filesStr = globpath(dir.StrForGlob(), '*') . "\n" . globpath(dir.StrForGlob(), '.*')
|
||||
let files = split(filesStr, "\n")
|
||||
|
||||
if !a:silent && len(files) > g:NERDTreeNotificationThreshold
|
||||
@@ -562,8 +564,10 @@ function! s:oTreeDirNode.InitChildren(silent) dict
|
||||
let invalidFilesFound = 0
|
||||
for i in files
|
||||
|
||||
"filter out the .. and . directories
|
||||
if i !~ '\.\.$' && i !~ '\.$'
|
||||
"filter out the .. and . directories
|
||||
"Note: we must match .. AND ../ cos sometimes the globpath returns
|
||||
"../ for path with strange chars (eg $)
|
||||
if i !~ '\.\.\/\?$' && i !~ '\.\/\?$'
|
||||
|
||||
"put the next file in a new node and attach it
|
||||
try
|
||||
@@ -661,7 +665,7 @@ function! s:oTreeDirNode.Refresh() dict
|
||||
|
||||
"go thru all the files/dirs under this node
|
||||
let dir = self.path
|
||||
let filesStr = globpath(dir.StrForOS(0), '*') . "\n" . globpath(dir.StrForOS(0), '.*')
|
||||
let filesStr = globpath(dir.StrForGlob(), '*') . "\n" . globpath(dir.StrForGlob(), '.*')
|
||||
let files = split(filesStr, "\n")
|
||||
for i in files
|
||||
if i !~ '\.\.$' && i !~ '\.$'
|
||||
@@ -769,9 +773,9 @@ let s:oPath = {}
|
||||
let oPath = s:oPath
|
||||
"FUNCTION: oPath.ChangeToDir() {{{3
|
||||
function! s:oPath.ChangeToDir() dict
|
||||
let dir = self.Str(1)
|
||||
let dir = self.StrForCd()
|
||||
if self.isDirectory == 0
|
||||
let dir = self.GetPathTrunk().Str(1)
|
||||
let dir = self.GetPathTrunk().StrForCd()
|
||||
endif
|
||||
|
||||
try
|
||||
@@ -847,27 +851,24 @@ function! s:oPath.Create(fullpath) dict
|
||||
throw "NERDTree.Path.Exists Exception: Directory Exists: '" . a:fullpath . "'"
|
||||
endif
|
||||
|
||||
"get the unix version of the input path
|
||||
let fullpath = s:oPath.WinToUnixPath(a:fullpath)
|
||||
|
||||
try
|
||||
|
||||
"if it ends with a slash, assume its a dir create it
|
||||
if fullpath =~ '\/$'
|
||||
if a:fullpath =~ '\(\\\|\/\)$'
|
||||
"whack the trailing slash off the end if it exists
|
||||
let fullpath = substitute(fullpath, '\/$', '', '')
|
||||
let fullpath = substitute(a:fullpath, '\(\\\|\/\)$', '', '')
|
||||
|
||||
call mkdir(fullpath, 'p')
|
||||
|
||||
"assume its a file and create
|
||||
else
|
||||
call writefile([], fullpath)
|
||||
call writefile([], a:fullpath)
|
||||
endif
|
||||
catch /.*/
|
||||
throw "NERDTree.Path Exception: Could not create path: '" . a:fullpath . "'"
|
||||
endtry
|
||||
|
||||
return s:oPath.New(fullpath)
|
||||
return s:oPath.New(a:fullpath)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oPath.Copy(dest) {{{3
|
||||
@@ -886,7 +887,7 @@ function! s:oPath.Copy(dest) dict
|
||||
let cmd = g:NERDTreeCopyCmd . " " . self.StrForOS(0) . " " . dest
|
||||
let success = system(cmd)
|
||||
if success != 0
|
||||
throw "NERDTree.Path Exception: Could not copy ''". self.StrForOS() ."'' to: '" . a:dest . "'"
|
||||
throw "NERDTree.Path Exception: Could not copy ''". self.StrForOS(0) ."'' to: '" . a:dest . "'"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -932,7 +933,7 @@ function! s:oPath.Delete() dict
|
||||
"if we are runnnig windows then put quotes around the pathstring
|
||||
let cmd = g:NERDTreeRemoveDirCmd . self.StrForOS(1)
|
||||
else
|
||||
let cmd = g:NERDTreeRemoveDirCmd . self.StrForOS(0)
|
||||
let cmd = g:NERDTreeRemoveDirCmd . self.StrForOS(1)
|
||||
endif
|
||||
let success = system(cmd)
|
||||
|
||||
@@ -940,13 +941,24 @@ function! s:oPath.Delete() dict
|
||||
throw "NERDTree.Path.Deletion Exception: Could not delete directory: '" . self.StrForOS(0) . "'"
|
||||
endif
|
||||
else
|
||||
let success = delete(self.Str(0))
|
||||
let success = delete(self.StrForOS(!s:running_windows))
|
||||
if success != 0
|
||||
throw "NERDTree.Path.Deletion Exception: Could not delete file: '" . self.Str(0) . "'"
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oPath.ExtractDriveLetter(fullpath) {{{3
|
||||
"
|
||||
"If running windows, cache the drive letter for this path
|
||||
function! s:oPath.ExtractDriveLetter(fullpath) dict
|
||||
if s:running_windows
|
||||
let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '')
|
||||
else
|
||||
let self.drive = ''
|
||||
endif
|
||||
|
||||
endfunction
|
||||
"FUNCTION: oPath.GetDir() {{{3
|
||||
"
|
||||
"Returns this path if it is a directory, else this paths parent.
|
||||
@@ -972,8 +984,6 @@ function! s:oPath.GetParent() dict
|
||||
let path = '/'. join(self.pathSegments[0:-2], '/')
|
||||
return s:oPath.New(path)
|
||||
endfunction
|
||||
|
||||
|
||||
"FUNCTION: oPath.GetLastPathComponent(dirSlash) {{{3
|
||||
"
|
||||
"Gets the last part of this path.
|
||||
@@ -995,7 +1005,7 @@ endfunction
|
||||
"FUNCTION: oPath.GetPathTrunk() {{{3
|
||||
"Gets the path without the last segment on the end.
|
||||
function! s:oPath.GetPathTrunk() dict
|
||||
return s:oPath.New('/' . join(self.pathSegments[0:-2], '/'))
|
||||
return s:oPath.New(self.StrTrunk())
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oPath.GetSortOrderIndex() {{{3
|
||||
@@ -1048,15 +1058,13 @@ endfunction
|
||||
|
||||
"FUNCTION: oPath.Equals() {{{3
|
||||
"
|
||||
"Determines whether 2 path objecs are "equal".
|
||||
"Determines whether 2 path objects are "equal".
|
||||
"They are equal if the paths they represent are the same
|
||||
"
|
||||
"Args:
|
||||
"path: the other path obj to compare this with
|
||||
function! s:oPath.Equals(path) dict
|
||||
let this = self.ChopTrailingSlash(self.Str(1))
|
||||
let that = self.ChopTrailingSlash(a:path.Str(1))
|
||||
return this == that
|
||||
return self.Str(0) == a:path.Str(0)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oPath.New() {{{3
|
||||
@@ -1071,35 +1079,25 @@ function! s:oPath.New(fullpath) dict
|
||||
return newPath
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oPath.NewMinimal() {{{3
|
||||
function! s:oPath.NewMinimal(fullpath) dict
|
||||
let newPath = copy(self)
|
||||
let fullpath = s:oPath.WinToUnixPath(a:fullpath)
|
||||
|
||||
let newPath.pathSegments = split(fullpath, '/')
|
||||
|
||||
let newPath.isDirectory = isdirectory(fullpath)
|
||||
|
||||
return newPath
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oPath.ReadInfoFromDisk(fullpath) {{{3
|
||||
"
|
||||
"
|
||||
"Throws NERDTree.Path.InvalidArguments exception.
|
||||
function! s:oPath.ReadInfoFromDisk(fullpath) dict
|
||||
call self.ExtractDriveLetter(a:fullpath)
|
||||
|
||||
let fullpath = s:oPath.WinToUnixPath(a:fullpath)
|
||||
|
||||
let self.pathSegments = split(fullpath, '/')
|
||||
|
||||
let self.isReadOnly = 0
|
||||
if isdirectory(fullpath)
|
||||
if isdirectory(a:fullpath)
|
||||
let self.isDirectory = 1
|
||||
elseif filereadable(fullpath)
|
||||
elseif filereadable(a:fullpath)
|
||||
let self.isDirectory = 0
|
||||
let self.isReadOnly = filewritable(fullpath) == 0
|
||||
let self.isReadOnly = filewritable(a:fullpath) == 0
|
||||
else
|
||||
throw "NERDTree.Path.InvalidArguments Exception: Invalid path = " . fullpath
|
||||
throw "NERDTree.Path.InvalidArguments Exception: Invalid path = " . a:fullpath
|
||||
endif
|
||||
|
||||
"grab the last part of the path (minus the trailing slash)
|
||||
@@ -1128,7 +1126,7 @@ endfunction
|
||||
|
||||
"FUNCTION: oPath.Refresh() {{{3
|
||||
function! s:oPath.Refresh() dict
|
||||
call self.ReadInfoFromDisk(self.Str(0))
|
||||
call self.ReadInfoFromDisk(self.StrForOS(0))
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oPath.Rename() {{{3
|
||||
@@ -1139,11 +1137,11 @@ function! s:oPath.Rename(newPath) dict
|
||||
throw "NERDTree.Path.InvalidArguments exception. Invalid newPath for renaming = ". a:newPath
|
||||
endif
|
||||
|
||||
let success = rename(self.Str(0), a:newPath)
|
||||
let success = rename(self.StrForOS(!s:running_windows), a:newPath)
|
||||
if success != 0
|
||||
throw "NERDTree.Path.Rename Exception: Could not rename: '" . self.Str(0) . "'" . 'to:' . a:newPath
|
||||
throw "NERDTree.Path.Rename Exception: Could not rename: '" . self.StrForOS(0) . "'" . 'to:' . a:newPath
|
||||
endif
|
||||
let self.pathSegments = split(a:newPath, '/')
|
||||
call self.ReadInfoFromDisk(a:newPath)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oPath.Str(esc) {{{3
|
||||
@@ -1174,6 +1172,19 @@ function! s:oPath.StrAbs() dict
|
||||
return resolve(self.Str(1))
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oPath.StrForCd() {{{3
|
||||
"
|
||||
" returns a string that can be used with :cd
|
||||
"
|
||||
"Return:
|
||||
"a string that can be used in the view to represent this path
|
||||
function! s:oPath.StrForCd() dict
|
||||
if s:running_windows
|
||||
return self.StrForOS(0)
|
||||
else
|
||||
return self.StrForOS(1)
|
||||
endif
|
||||
endfunction
|
||||
"FUNCTION: oPath.StrDisplay() {{{3
|
||||
"
|
||||
"Returns a string that specifies how the path should be represented as a
|
||||
@@ -1207,6 +1218,22 @@ function! s:oPath.StrForEditCmd() dict
|
||||
endif
|
||||
|
||||
endfunction
|
||||
"FUNCTION: oPath.StrForGlob() {{{3
|
||||
function! s:oPath.StrForGlob() dict
|
||||
let lead = s:os_slash
|
||||
|
||||
"if we are running windows then slap a drive letter on the front
|
||||
if s:running_windows
|
||||
let lead = self.drive . '\'
|
||||
endif
|
||||
|
||||
let toReturn = lead . join(self.pathSegments, s:os_slash)
|
||||
|
||||
if !s:running_windows
|
||||
let toReturn = escape(toReturn, s:escape_chars)
|
||||
endif
|
||||
return toReturn
|
||||
endfunction
|
||||
"FUNCTION: oPath.StrForOS(esc) {{{3
|
||||
"
|
||||
"Gets the string path for this path object that is appropriate for the OS.
|
||||
@@ -1221,7 +1248,7 @@ function! s:oPath.StrForOS(esc) dict
|
||||
|
||||
"if we are running windows then slap a drive letter on the front
|
||||
if s:running_windows
|
||||
let lead = strpart(getcwd(), 0, 2) . s:os_slash
|
||||
let lead = self.drive . '\'
|
||||
endif
|
||||
|
||||
let toReturn = lead . join(self.pathSegments, s:os_slash)
|
||||
@@ -1239,7 +1266,7 @@ endfunction
|
||||
"FUNCTION: oPath.StrTrunk() {{{3
|
||||
"Gets the path without the last segment on the end.
|
||||
function! s:oPath.StrTrunk() dict
|
||||
return '/' . join(self.pathSegments[0:-2], '/')
|
||||
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oPath.WinToUnixPath(pathstr){{{3
|
||||
@@ -1311,7 +1338,9 @@ function! s:InitNerdTree(dir)
|
||||
let dir = a:dir == '' ? expand('%:p:h') : a:dir
|
||||
let dir = resolve(dir)
|
||||
|
||||
if !isdirectory(dir)
|
||||
let path = s:oPath.New(dir)
|
||||
|
||||
if !path.isDirectory
|
||||
call s:EchoWarning("Error reading: " . dir)
|
||||
return
|
||||
endif
|
||||
@@ -1319,7 +1348,7 @@ function! s:InitNerdTree(dir)
|
||||
"if instructed to, then change the vim CWD to the dir the NERDTree is
|
||||
"inited in
|
||||
if g:NERDTreeChDirMode != 0
|
||||
exec "cd " . dir
|
||||
exec 'cd ' . path.StrForCd()
|
||||
endif
|
||||
|
||||
let t:treeShowHelp = 0
|
||||
@@ -1332,7 +1361,6 @@ function! s:InitNerdTree(dir)
|
||||
unlet t:NERDTreeRoot
|
||||
endif
|
||||
|
||||
let path = s:oPath.New(dir)
|
||||
let t:NERDTreeRoot = s:oTreeDirNode.New(path)
|
||||
call t:NERDTreeRoot.Open()
|
||||
|
||||
@@ -1403,7 +1431,13 @@ function! s:CenterView()
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:CloseTreeIfOpen() {{{2
|
||||
"Closes the NERD tree window if it is open
|
||||
function! s:CloseTreeIfOpen()
|
||||
if s:IsTreeOpen()
|
||||
call s:CloseTree()
|
||||
endif
|
||||
endfunction
|
||||
"FUNCTION: s:CloseTree() {{{2
|
||||
"Closes the NERD tree window
|
||||
function! s:CloseTree()
|
||||
@@ -1442,23 +1476,29 @@ function! s:CreateTreeWin()
|
||||
setlocal foldcolumn=0
|
||||
setlocal nobuflisted
|
||||
setlocal nospell
|
||||
setlocal nonu
|
||||
if g:NERDTreeShowLineNumbers
|
||||
setlocal nu
|
||||
else
|
||||
setlocal nonu
|
||||
endif
|
||||
|
||||
iabc <buffer>
|
||||
|
||||
if g:NERDTreeHighlightCursorline
|
||||
setlocal cursorline
|
||||
endif
|
||||
|
||||
" syntax highlighting
|
||||
if has("syntax") && exists("g:syntax_on") && !has("syntax_items")
|
||||
call s:SetupSyntaxHighlighting()
|
||||
endif
|
||||
|
||||
" for line continuation
|
||||
let cpo_save1 = &cpo
|
||||
set cpo&vim
|
||||
|
||||
call s:BindMappings()
|
||||
setfiletype nerdtree
|
||||
" syntax highlighting
|
||||
if has("syntax") && exists("g:syntax_on") && !has("syntax_items")
|
||||
call s:SetupSyntaxHighlighting()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:DrawTree {{{2
|
||||
@@ -1766,8 +1806,9 @@ function! s:GetPath(ln)
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
let curFile = dir . curFile
|
||||
return s:oPath.NewMinimal(curFile)
|
||||
let curFile = t:NERDTreeRoot.path.drive . dir . curFile
|
||||
let toReturn = s:oPath.New(curFile)
|
||||
return toReturn
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:GetSelectedDir() {{{2
|
||||
@@ -1965,7 +2006,7 @@ function! s:OpenNodeSplit(treenode)
|
||||
try
|
||||
exec("silent " . splitMode." sp " . a:treenode.path.StrForEditCmd())
|
||||
catch /^Vim\%((\a\+)\)\=:E37/
|
||||
call s:PutCursorInTreeWin()
|
||||
call s:PutCursorInTreeWin()
|
||||
throw "NERDTree.view.FileOpen exception: ". a:treenode.path.Str(0) ." is already open and modified."
|
||||
catch /^Vim\%((\a\+)\)\=:/
|
||||
do nothing
|
||||
@@ -2019,11 +2060,11 @@ endfunction
|
||||
"FUNCTION: s:PutCursorInTreeWin(){{{2
|
||||
"Places the cursor in the nerd tree window
|
||||
function! s:PutCursorInTreeWin()
|
||||
if !s:IsTreeOpen()
|
||||
throw "NERDTree.view.InvalidOperation Exception: No NERD tree window exists"
|
||||
endif
|
||||
if !s:IsTreeOpen()
|
||||
throw "NERDTree.view.InvalidOperation Exception: No NERD tree window exists"
|
||||
endif
|
||||
|
||||
exec s:GetTreeWinNum() . "wincmd w"
|
||||
exec s:GetTreeWinNum() . "wincmd w"
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:RenderView {{{2
|
||||
@@ -2579,7 +2620,7 @@ function! s:InsertNewNode()
|
||||
let newNodeName = input("Add a childnode\n".
|
||||
\ "==========================================================\n".
|
||||
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
|
||||
\ "", curDirNode.path.Str(0))
|
||||
\ "", curDirNode.path.StrForGlob() . s:os_slash)
|
||||
|
||||
if newNodeName == ''
|
||||
call s:Echo("Node Creation Aborted.")
|
||||
@@ -2588,7 +2629,6 @@ function! s:InsertNewNode()
|
||||
|
||||
try
|
||||
let newPath = s:oPath.Create(newNodeName)
|
||||
|
||||
let parentNode = t:NERDTreeRoot.FindNode(newPath.GetPathTrunk())
|
||||
|
||||
let newTreeNode = s:oTreeFileNode.New(newPath)
|
||||
@@ -2787,15 +2827,13 @@ function! s:RenameCurrent()
|
||||
let newNodePath = input("Rename the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "Enter the new path for the node: \n" .
|
||||
\ "", curNode.path.Str(0))
|
||||
\ "", curNode.path.StrForOS(0))
|
||||
|
||||
if newNodePath == ''
|
||||
call s:Echo("Node Renaming Aborted.")
|
||||
return
|
||||
endif
|
||||
|
||||
let newNodePath = substitute(newNodePath, '\/$', '', '')
|
||||
|
||||
try
|
||||
let bufnum = bufnr(curNode.path.Str(0))
|
||||
|
||||
@@ -2805,7 +2843,7 @@ function! s:RenameCurrent()
|
||||
"if the node is open in a buffer, ask the user if they want to
|
||||
"close that buffer
|
||||
if bufnum != -1
|
||||
let prompt = "|\n|Node renamed.\n|\n|The 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)
|
||||
endif
|
||||
|
||||
@@ -2832,13 +2870,13 @@ function! s:ShowFileSystemMenu()
|
||||
\ " (a)dd a childnode\n".
|
||||
\ " (m)ove the current node\n".
|
||||
\ " (d)elete the current node\n"
|
||||
if s:oPath.CopyingSupported()
|
||||
let prompt = prompt . " (c)opy the current node\n\n"
|
||||
else
|
||||
let prompt = prompt . " \n"
|
||||
endif
|
||||
if s:oPath.CopyingSupported()
|
||||
let prompt = prompt . " (c)opy the current node\n\n"
|
||||
else
|
||||
let prompt = prompt . " \n"
|
||||
endif
|
||||
|
||||
echo prompt
|
||||
echo prompt
|
||||
|
||||
let choice = nr2char(getchar())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user