mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 03:43:50 -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)
|
* optional displaying of hidden files (. files)
|
||||||
* files can be "turned off" so that only directories are displayed
|
* files can be "turned off" so that only directories are displayed
|
||||||
* A textual filesystem menu is provided which allows you to
|
* 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 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.
|
* 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
|
* 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
|
rendered again. If no NERD tree exists for this tab then this
|
||||||
command acts the same as the |:NERDTree| command.
|
command acts the same as the |:NERDTree| command.
|
||||||
|
|
||||||
|
:NERDTreeClose
|
||||||
|
Close the NERD tree in this tab.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.2. NERD tree Mappings *NERDTreeMappings*
|
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
|
|NERDTreeShowHidden| Tells the NERD tree whether to display hidden
|
||||||
files on startup.
|
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
|
|NERDTreeSortOrder| Tell the NERD tree how to sort the nodes in
|
||||||
the tree.
|
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
|
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.
|
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
|
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
|
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
|
with the root dir of my project and always have ctags available to me --- no
|
||||||
@@ -659,6 +662,17 @@ Use one of the follow lines to set this option: >
|
|||||||
let NERDTreeShowHidden=1
|
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*
|
*NERDTreeSortOrder*
|
||||||
Values: a list of regular expressions.
|
Values: a list of regular expressions.
|
||||||
@@ -688,7 +702,7 @@ Other examples: >
|
|||||||
(3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$']
|
(3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$']
|
||||||
<
|
<
|
||||||
1. Directories will appear last, everything else will appear above.
|
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
|
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.
|
||||||
|
|
||||||
@@ -770,6 +784,22 @@ fridge for later ;)
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
7. Changelog *NERDTreeChangelog*
|
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
|
2.7.1
|
||||||
- Changed the keys for the filesystem menu to be mnemonic rather than
|
- Changed the keys for the filesystem menu to be mnemonic rather than
|
||||||
arbitrary integers
|
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
|
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
|
window if you try to open a file in a window containing a modified buffer when
|
||||||
the &hidden option is set.
|
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
|
" 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>
|
" 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
|
" SECTION: Script init stuff {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
@@ -43,8 +43,9 @@ endif
|
|||||||
call s:InitVariable("g:NERDTreeHighlightCursorline", 1)
|
call s:InitVariable("g:NERDTreeHighlightCursorline", 1)
|
||||||
call s:InitVariable("g:NERDTreeMouseMode", 1)
|
call s:InitVariable("g:NERDTreeMouseMode", 1)
|
||||||
call s:InitVariable("g:NERDTreeNotificationThreshold", 100)
|
call s:InitVariable("g:NERDTreeNotificationThreshold", 100)
|
||||||
call s:InitVariable("g:NERDTreeShowHidden", 0)
|
|
||||||
call s:InitVariable("g:NERDTreeShowFiles", 1)
|
call s:InitVariable("g:NERDTreeShowFiles", 1)
|
||||||
|
call s:InitVariable("g:NERDTreeShowHidden", 0)
|
||||||
|
call s:InitVariable("g:NERDTreeShowLineNumbers", 0)
|
||||||
call s:InitVariable("g:NERDTreeSortDirs", 1)
|
call s:InitVariable("g:NERDTreeSortDirs", 1)
|
||||||
|
|
||||||
if !exists("g:NERDTreeSortOrder")
|
if !exists("g:NERDTreeSortOrder")
|
||||||
@@ -109,7 +110,7 @@ call s:InitVariable("g:NERDTreeMapUpdir", "u")
|
|||||||
call s:InitVariable("g:NERDTreeMapUpdirKeepOpen", "U")
|
call s:InitVariable("g:NERDTreeMapUpdirKeepOpen", "U")
|
||||||
|
|
||||||
"SECTION: Script level variable declaration{{{2
|
"SECTION: Script level variable declaration{{{2
|
||||||
let s:escape_chars = " `|\"~'#"
|
let s:escape_chars = " \\`\|\"#%&,?()\*^<>"
|
||||||
let s:NERDTreeWinName = '_NERD_tree_'
|
let s:NERDTreeWinName = '_NERD_tree_'
|
||||||
|
|
||||||
"init all the nerd tree markup
|
"init all the nerd tree markup
|
||||||
@@ -138,6 +139,7 @@ endif
|
|||||||
"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 NERDTree :call s:InitNerdTree('<args>')
|
||||||
command! -n=? -complete=dir NERDTreeToggle :call s:Toggle('<args>')
|
command! -n=? -complete=dir NERDTreeToggle :call s:Toggle('<args>')
|
||||||
|
command! -n=0 NERDTreeClose :call s:CloseTreeIfOpen()
|
||||||
" SECTION: Auto commands {{{1
|
" SECTION: Auto commands {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
"Save the cursor position whenever we close the nerd tree
|
"Save the cursor position whenever we close the nerd tree
|
||||||
@@ -307,7 +309,8 @@ endfunction
|
|||||||
"FUNCTION: oTreeFileNode.Rename {{{3
|
"FUNCTION: oTreeFileNode.Rename {{{3
|
||||||
"Calls the rename method for this nodes path obj
|
"Calls the rename method for this nodes path obj
|
||||||
function! s:oTreeFileNode.Rename(newName) dict
|
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)
|
call self.parent.RemoveChild(self)
|
||||||
|
|
||||||
let parentPath = self.path.GetPathTrunk()
|
let parentPath = self.path.GetPathTrunk()
|
||||||
@@ -317,7 +320,6 @@ function! s:oTreeFileNode.Rename(newName) dict
|
|||||||
call newParent.CreateChild(self.path, 1)
|
call newParent.CreateChild(self.path, 1)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oTreeFileNode.StrDisplay() {{{3
|
"FUNCTION: oTreeFileNode.StrDisplay() {{{3
|
||||||
"
|
"
|
||||||
"Returns a string that specifies how the node should be represented as a
|
"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
|
"get an array of all the files in the nodes dir
|
||||||
let dir = self.path
|
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")
|
let files = split(filesStr, "\n")
|
||||||
|
|
||||||
if !a:silent && len(files) > g:NERDTreeNotificationThreshold
|
if !a:silent && len(files) > g:NERDTreeNotificationThreshold
|
||||||
@@ -563,7 +565,9 @@ function! s:oTreeDirNode.InitChildren(silent) dict
|
|||||||
for i in files
|
for i in files
|
||||||
|
|
||||||
"filter out the .. and . directories
|
"filter out the .. and . directories
|
||||||
if i !~ '\.\.$' && i !~ '\.$'
|
"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
|
"put the next file in a new node and attach it
|
||||||
try
|
try
|
||||||
@@ -661,7 +665,7 @@ function! s:oTreeDirNode.Refresh() dict
|
|||||||
|
|
||||||
"go thru all the files/dirs under this node
|
"go thru all the files/dirs under this node
|
||||||
let dir = self.path
|
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")
|
let files = split(filesStr, "\n")
|
||||||
for i in files
|
for i in files
|
||||||
if i !~ '\.\.$' && i !~ '\.$'
|
if i !~ '\.\.$' && i !~ '\.$'
|
||||||
@@ -769,9 +773,9 @@ let s:oPath = {}
|
|||||||
let oPath = s:oPath
|
let oPath = s:oPath
|
||||||
"FUNCTION: oPath.ChangeToDir() {{{3
|
"FUNCTION: oPath.ChangeToDir() {{{3
|
||||||
function! s:oPath.ChangeToDir() dict
|
function! s:oPath.ChangeToDir() dict
|
||||||
let dir = self.Str(1)
|
let dir = self.StrForCd()
|
||||||
if self.isDirectory == 0
|
if self.isDirectory == 0
|
||||||
let dir = self.GetPathTrunk().Str(1)
|
let dir = self.GetPathTrunk().StrForCd()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -847,27 +851,24 @@ function! s:oPath.Create(fullpath) dict
|
|||||||
throw "NERDTree.Path.Exists Exception: Directory Exists: '" . a:fullpath . "'"
|
throw "NERDTree.Path.Exists Exception: Directory Exists: '" . a:fullpath . "'"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"get the unix version of the input path
|
|
||||||
let fullpath = s:oPath.WinToUnixPath(a:fullpath)
|
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
||||||
"if it ends with a slash, assume its a dir create it
|
"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
|
"whack the trailing slash off the end if it exists
|
||||||
let fullpath = substitute(fullpath, '\/$', '', '')
|
let fullpath = substitute(a:fullpath, '\(\\\|\/\)$', '', '')
|
||||||
|
|
||||||
call mkdir(fullpath, 'p')
|
call mkdir(fullpath, 'p')
|
||||||
|
|
||||||
"assume its a file and create
|
"assume its a file and create
|
||||||
else
|
else
|
||||||
call writefile([], fullpath)
|
call writefile([], a:fullpath)
|
||||||
endif
|
endif
|
||||||
catch /.*/
|
catch /.*/
|
||||||
throw "NERDTree.Path Exception: Could not create path: '" . a:fullpath . "'"
|
throw "NERDTree.Path Exception: Could not create path: '" . a:fullpath . "'"
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
return s:oPath.New(fullpath)
|
return s:oPath.New(a:fullpath)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oPath.Copy(dest) {{{3
|
"FUNCTION: oPath.Copy(dest) {{{3
|
||||||
@@ -886,7 +887,7 @@ function! s:oPath.Copy(dest) dict
|
|||||||
let cmd = g:NERDTreeCopyCmd . " " . self.StrForOS(0) . " " . dest
|
let cmd = g:NERDTreeCopyCmd . " " . self.StrForOS(0) . " " . dest
|
||||||
let success = system(cmd)
|
let success = system(cmd)
|
||||||
if success != 0
|
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
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -932,7 +933,7 @@ function! s:oPath.Delete() dict
|
|||||||
"if we are runnnig windows then put quotes around the pathstring
|
"if we are runnnig windows then put quotes around the pathstring
|
||||||
let cmd = g:NERDTreeRemoveDirCmd . self.StrForOS(1)
|
let cmd = g:NERDTreeRemoveDirCmd . self.StrForOS(1)
|
||||||
else
|
else
|
||||||
let cmd = g:NERDTreeRemoveDirCmd . self.StrForOS(0)
|
let cmd = g:NERDTreeRemoveDirCmd . self.StrForOS(1)
|
||||||
endif
|
endif
|
||||||
let success = system(cmd)
|
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) . "'"
|
throw "NERDTree.Path.Deletion Exception: Could not delete directory: '" . self.StrForOS(0) . "'"
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let success = delete(self.Str(0))
|
let success = delete(self.StrForOS(!s:running_windows))
|
||||||
if success != 0
|
if success != 0
|
||||||
throw "NERDTree.Path.Deletion Exception: Could not delete file: '" . self.Str(0) . "'"
|
throw "NERDTree.Path.Deletion Exception: Could not delete file: '" . self.Str(0) . "'"
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
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
|
"FUNCTION: oPath.GetDir() {{{3
|
||||||
"
|
"
|
||||||
"Returns this path if it is a directory, else this paths parent.
|
"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], '/')
|
let path = '/'. join(self.pathSegments[0:-2], '/')
|
||||||
return s:oPath.New(path)
|
return s:oPath.New(path)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
"FUNCTION: oPath.GetLastPathComponent(dirSlash) {{{3
|
"FUNCTION: oPath.GetLastPathComponent(dirSlash) {{{3
|
||||||
"
|
"
|
||||||
"Gets the last part of this path.
|
"Gets the last part of this path.
|
||||||
@@ -995,7 +1005,7 @@ endfunction
|
|||||||
"FUNCTION: oPath.GetPathTrunk() {{{3
|
"FUNCTION: oPath.GetPathTrunk() {{{3
|
||||||
"Gets the path without the last segment on the end.
|
"Gets the path without the last segment on the end.
|
||||||
function! s:oPath.GetPathTrunk() dict
|
function! s:oPath.GetPathTrunk() dict
|
||||||
return s:oPath.New('/' . join(self.pathSegments[0:-2], '/'))
|
return s:oPath.New(self.StrTrunk())
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oPath.GetSortOrderIndex() {{{3
|
"FUNCTION: oPath.GetSortOrderIndex() {{{3
|
||||||
@@ -1048,15 +1058,13 @@ endfunction
|
|||||||
|
|
||||||
"FUNCTION: oPath.Equals() {{{3
|
"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
|
"They are equal if the paths they represent are the same
|
||||||
"
|
"
|
||||||
"Args:
|
"Args:
|
||||||
"path: the other path obj to compare this with
|
"path: the other path obj to compare this with
|
||||||
function! s:oPath.Equals(path) dict
|
function! s:oPath.Equals(path) dict
|
||||||
let this = self.ChopTrailingSlash(self.Str(1))
|
return self.Str(0) == a:path.Str(0)
|
||||||
let that = self.ChopTrailingSlash(a:path.Str(1))
|
|
||||||
return this == that
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oPath.New() {{{3
|
"FUNCTION: oPath.New() {{{3
|
||||||
@@ -1071,35 +1079,25 @@ function! s:oPath.New(fullpath) dict
|
|||||||
return newPath
|
return newPath
|
||||||
endfunction
|
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
|
"FUNCTION: oPath.ReadInfoFromDisk(fullpath) {{{3
|
||||||
"
|
"
|
||||||
"
|
"
|
||||||
"Throws NERDTree.Path.InvalidArguments exception.
|
"Throws NERDTree.Path.InvalidArguments exception.
|
||||||
function! s:oPath.ReadInfoFromDisk(fullpath) dict
|
function! s:oPath.ReadInfoFromDisk(fullpath) dict
|
||||||
|
call self.ExtractDriveLetter(a:fullpath)
|
||||||
|
|
||||||
let fullpath = s:oPath.WinToUnixPath(a:fullpath)
|
let fullpath = s:oPath.WinToUnixPath(a:fullpath)
|
||||||
|
|
||||||
let self.pathSegments = split(fullpath, '/')
|
let self.pathSegments = split(fullpath, '/')
|
||||||
|
|
||||||
let self.isReadOnly = 0
|
let self.isReadOnly = 0
|
||||||
if isdirectory(fullpath)
|
if isdirectory(a:fullpath)
|
||||||
let self.isDirectory = 1
|
let self.isDirectory = 1
|
||||||
elseif filereadable(fullpath)
|
elseif filereadable(a:fullpath)
|
||||||
let self.isDirectory = 0
|
let self.isDirectory = 0
|
||||||
let self.isReadOnly = filewritable(fullpath) == 0
|
let self.isReadOnly = filewritable(a:fullpath) == 0
|
||||||
else
|
else
|
||||||
throw "NERDTree.Path.InvalidArguments Exception: Invalid path = " . fullpath
|
throw "NERDTree.Path.InvalidArguments Exception: Invalid path = " . a:fullpath
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"grab the last part of the path (minus the trailing slash)
|
"grab the last part of the path (minus the trailing slash)
|
||||||
@@ -1128,7 +1126,7 @@ endfunction
|
|||||||
|
|
||||||
"FUNCTION: oPath.Refresh() {{{3
|
"FUNCTION: oPath.Refresh() {{{3
|
||||||
function! s:oPath.Refresh() dict
|
function! s:oPath.Refresh() dict
|
||||||
call self.ReadInfoFromDisk(self.Str(0))
|
call self.ReadInfoFromDisk(self.StrForOS(0))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oPath.Rename() {{{3
|
"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
|
throw "NERDTree.Path.InvalidArguments exception. Invalid newPath for renaming = ". a:newPath
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let success = rename(self.Str(0), a:newPath)
|
let success = rename(self.StrForOS(!s:running_windows), a:newPath)
|
||||||
if success != 0
|
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
|
endif
|
||||||
let self.pathSegments = split(a:newPath, '/')
|
call self.ReadInfoFromDisk(a:newPath)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oPath.Str(esc) {{{3
|
"FUNCTION: oPath.Str(esc) {{{3
|
||||||
@@ -1174,6 +1172,19 @@ function! s:oPath.StrAbs() dict
|
|||||||
return resolve(self.Str(1))
|
return resolve(self.Str(1))
|
||||||
endfunction
|
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
|
"FUNCTION: oPath.StrDisplay() {{{3
|
||||||
"
|
"
|
||||||
"Returns a string that specifies how the path should be represented as a
|
"Returns a string that specifies how the path should be represented as a
|
||||||
@@ -1207,6 +1218,22 @@ function! s:oPath.StrForEditCmd() dict
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
endfunction
|
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
|
"FUNCTION: oPath.StrForOS(esc) {{{3
|
||||||
"
|
"
|
||||||
"Gets the string path for this path object that is appropriate for the OS.
|
"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 we are running windows then slap a drive letter on the front
|
||||||
if s:running_windows
|
if s:running_windows
|
||||||
let lead = strpart(getcwd(), 0, 2) . s:os_slash
|
let lead = self.drive . '\'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let toReturn = lead . join(self.pathSegments, s:os_slash)
|
let toReturn = lead . join(self.pathSegments, s:os_slash)
|
||||||
@@ -1239,7 +1266,7 @@ endfunction
|
|||||||
"FUNCTION: oPath.StrTrunk() {{{3
|
"FUNCTION: oPath.StrTrunk() {{{3
|
||||||
"Gets the path without the last segment on the end.
|
"Gets the path without the last segment on the end.
|
||||||
function! s:oPath.StrTrunk() dict
|
function! s:oPath.StrTrunk() dict
|
||||||
return '/' . join(self.pathSegments[0:-2], '/')
|
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oPath.WinToUnixPath(pathstr){{{3
|
"FUNCTION: oPath.WinToUnixPath(pathstr){{{3
|
||||||
@@ -1311,7 +1338,9 @@ function! s:InitNerdTree(dir)
|
|||||||
let dir = a:dir == '' ? expand('%:p:h') : a:dir
|
let dir = a:dir == '' ? expand('%:p:h') : a:dir
|
||||||
let dir = resolve(dir)
|
let dir = resolve(dir)
|
||||||
|
|
||||||
if !isdirectory(dir)
|
let path = s:oPath.New(dir)
|
||||||
|
|
||||||
|
if !path.isDirectory
|
||||||
call s:EchoWarning("Error reading: " . dir)
|
call s:EchoWarning("Error reading: " . dir)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -1319,7 +1348,7 @@ function! s:InitNerdTree(dir)
|
|||||||
"if instructed to, then change the vim CWD to the dir the NERDTree is
|
"if instructed to, then change the vim CWD to the dir the NERDTree is
|
||||||
"inited in
|
"inited in
|
||||||
if g:NERDTreeChDirMode != 0
|
if g:NERDTreeChDirMode != 0
|
||||||
exec "cd " . dir
|
exec 'cd ' . path.StrForCd()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let t:treeShowHelp = 0
|
let t:treeShowHelp = 0
|
||||||
@@ -1332,7 +1361,6 @@ function! s:InitNerdTree(dir)
|
|||||||
unlet t:NERDTreeRoot
|
unlet t:NERDTreeRoot
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let path = s:oPath.New(dir)
|
|
||||||
let t:NERDTreeRoot = s:oTreeDirNode.New(path)
|
let t:NERDTreeRoot = s:oTreeDirNode.New(path)
|
||||||
call t:NERDTreeRoot.Open()
|
call t:NERDTreeRoot.Open()
|
||||||
|
|
||||||
@@ -1403,7 +1431,13 @@ function! s:CenterView()
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
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
|
"FUNCTION: s:CloseTree() {{{2
|
||||||
"Closes the NERD tree window
|
"Closes the NERD tree window
|
||||||
function! s:CloseTree()
|
function! s:CloseTree()
|
||||||
@@ -1442,23 +1476,29 @@ function! s:CreateTreeWin()
|
|||||||
setlocal foldcolumn=0
|
setlocal foldcolumn=0
|
||||||
setlocal nobuflisted
|
setlocal nobuflisted
|
||||||
setlocal nospell
|
setlocal nospell
|
||||||
|
if g:NERDTreeShowLineNumbers
|
||||||
|
setlocal nu
|
||||||
|
else
|
||||||
setlocal nonu
|
setlocal nonu
|
||||||
|
endif
|
||||||
|
|
||||||
iabc <buffer>
|
iabc <buffer>
|
||||||
|
|
||||||
if g:NERDTreeHighlightCursorline
|
if g:NERDTreeHighlightCursorline
|
||||||
setlocal cursorline
|
setlocal cursorline
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" syntax highlighting
|
|
||||||
if has("syntax") && exists("g:syntax_on") && !has("syntax_items")
|
|
||||||
call s:SetupSyntaxHighlighting()
|
|
||||||
endif
|
|
||||||
|
|
||||||
" for line continuation
|
" for line continuation
|
||||||
let cpo_save1 = &cpo
|
let cpo_save1 = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
call s:BindMappings()
|
call s:BindMappings()
|
||||||
|
setfiletype nerdtree
|
||||||
|
" syntax highlighting
|
||||||
|
if has("syntax") && exists("g:syntax_on") && !has("syntax_items")
|
||||||
|
call s:SetupSyntaxHighlighting()
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:DrawTree {{{2
|
"FUNCTION: s:DrawTree {{{2
|
||||||
@@ -1766,8 +1806,9 @@ function! s:GetPath(ln)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
let curFile = dir . curFile
|
let curFile = t:NERDTreeRoot.path.drive . dir . curFile
|
||||||
return s:oPath.NewMinimal(curFile)
|
let toReturn = s:oPath.New(curFile)
|
||||||
|
return toReturn
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:GetSelectedDir() {{{2
|
"FUNCTION: s:GetSelectedDir() {{{2
|
||||||
@@ -2579,7 +2620,7 @@ function! s:InsertNewNode()
|
|||||||
let newNodeName = input("Add a childnode\n".
|
let newNodeName = input("Add a childnode\n".
|
||||||
\ "==========================================================\n".
|
\ "==========================================================\n".
|
||||||
\ "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.Str(0))
|
\ "", curDirNode.path.StrForGlob() . s:os_slash)
|
||||||
|
|
||||||
if newNodeName == ''
|
if newNodeName == ''
|
||||||
call s:Echo("Node Creation Aborted.")
|
call s:Echo("Node Creation Aborted.")
|
||||||
@@ -2588,7 +2629,6 @@ function! s:InsertNewNode()
|
|||||||
|
|
||||||
try
|
try
|
||||||
let newPath = s:oPath.Create(newNodeName)
|
let newPath = s:oPath.Create(newNodeName)
|
||||||
|
|
||||||
let parentNode = t:NERDTreeRoot.FindNode(newPath.GetPathTrunk())
|
let parentNode = t:NERDTreeRoot.FindNode(newPath.GetPathTrunk())
|
||||||
|
|
||||||
let newTreeNode = s:oTreeFileNode.New(newPath)
|
let newTreeNode = s:oTreeFileNode.New(newPath)
|
||||||
@@ -2787,15 +2827,13 @@ function! s:RenameCurrent()
|
|||||||
let newNodePath = input("Rename the current node\n" .
|
let newNodePath = input("Rename the current node\n" .
|
||||||
\ "==========================================================\n" .
|
\ "==========================================================\n" .
|
||||||
\ "Enter the new path for the node: \n" .
|
\ "Enter the new path for the node: \n" .
|
||||||
\ "", curNode.path.Str(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
|
||||||
|
|
||||||
let newNodePath = substitute(newNodePath, '\/$', '', '')
|
|
||||||
|
|
||||||
try
|
try
|
||||||
let bufnum = bufnr(curNode.path.Str(0))
|
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
|
"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 = "|\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)
|
call s:PromptToDelBuffer(bufnum, prompt)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user