mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2670f0d19 | ||
|
|
4cc6097ecb | ||
|
|
30ad6da984 | ||
|
|
3005a0e9c0 | ||
|
|
a7d585f7af | ||
|
|
5e77fb2fef | ||
|
|
29a321d061 | ||
|
|
0257d64248 | ||
|
|
2d7cb043d4 | ||
|
|
f767dd34a0 | ||
|
|
832bbaa729 | ||
|
|
343508e9fd | ||
|
|
495b4e781a |
11
CHANGELOG.md
11
CHANGELOG.md
@@ -5,6 +5,17 @@
|
||||
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
|
||||
-->
|
||||
#### 6.7
|
||||
- **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) [#1122](https://github.com/preservim/nerdtree/pull/1122)
|
||||
- **.10**: Do not consider the tree root to be "cascadable". (lifecrisis) [#1120](https://github.com/preservim/nerdtree/pull/1120)
|
||||
- **.9**: Force `:NERDTreeFocus` to allow events to be fired when switching windows. (PhilRunninger) [#1118](https://github.com/preservim/nerdtree/pull/1118)
|
||||
- **.8**: Fix example code for the `NERDTreeAddKeyMap()` function. (PhilRunninger) [#1116](https://github.com/preservim/nerdtree/pull/1116)
|
||||
- **.7**: Put `'%'` argument in `bufname()` for backwards compatibility. (PhilRunninger) [#1105](https://github.com/preservim/nerdtree/pull/1105)
|
||||
- **.6**: If a file's already open in the window, don't edit it again. (PhilRunninger) [#1103](https://github.com/preservim/nerdtree/pull/1103)
|
||||
- **.5**: Prevent unneeded tree creation in `:NERDTreeToggle[VCS] <path>` (PhilRunninger) [#1101](https://github.com/preservim/nerdtree/pull/1101)
|
||||
- **.4**: Add missing calls to the `shellescape()` function (lifecrisis) [#1099](https://github.com/preservim/nerdtree/pull/1099)
|
||||
- **.3**: Fix vsplit to not open empty buffers when opening previously closed file (AwkwardKore) [#1098](https://github.com/preservim/nerdtree/pull/1098)
|
||||
- **.2**: Fix infinity loop (on winvim) in FindParentVCSRoot (Eugenij-W) [#1095](https://github.com/preservim/nerdtree/pull/1095)
|
||||
- **.1**: File Move: Escape existing directory name when looking for open files. (PhilRunninger) [#1094](https://github.com/preservim/nerdtree/pull/1094)
|
||||
- **.0**: Open the parent directory when revealing a non-existent file with :NERDTreeFind (bouk) [#1090](https://github.com/preservim/nerdtree/pull/1090)
|
||||
#### 6.6
|
||||
- **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087)
|
||||
|
||||
@@ -1353,12 +1353,12 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()*
|
||||
Example: >
|
||||
call NERDTreeAddKeyMap({
|
||||
\ 'key': 'foo',
|
||||
\ 'callback': 'NERDTreeCDHandler',
|
||||
\ 'callback': 'NERDTreeEchoPathHandler',
|
||||
\ 'quickhelpText': 'echo full path of current node',
|
||||
\ 'scope': 'DirNode' })
|
||||
|
||||
function! NERDTreeCDHandler(dirnode)
|
||||
call a:dirnode.changeToDir()
|
||||
function! NERDTreeEchoPathHandler(dirnode)
|
||||
echo a:dirnode.path.str()
|
||||
endfunction
|
||||
<
|
||||
This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim.
|
||||
|
||||
@@ -249,7 +249,11 @@ function! s:Creator._pathForString(str)
|
||||
if dir =~# '^\.'
|
||||
let dir = getcwd() . g:NERDTreePath.Slash() . dir
|
||||
endif
|
||||
let dir = g:NERDTreePath.Resolve(dir)
|
||||
|
||||
"hack to prevent removing slash if dir is the root of the file system.
|
||||
if dir !=# '/'
|
||||
let dir = g:NERDTreePath.Resolve(dir)
|
||||
endif
|
||||
|
||||
try
|
||||
let path = g:NERDTreePath.New(dir)
|
||||
@@ -366,7 +370,7 @@ function! s:Creator.toggleTabTree(dir)
|
||||
if g:NERDTree.ExistsForTab()
|
||||
if !g:NERDTree.IsOpen()
|
||||
call self._createTreeWin()
|
||||
if !empty(a:dir)
|
||||
if !empty(a:dir) && a:dir !=# b:NERDTree.root.path.str()
|
||||
call self.createTabTree(a:dir)
|
||||
elseif !&hidden
|
||||
call b:NERDTree.render()
|
||||
|
||||
@@ -96,9 +96,9 @@ endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.CursorToTreeWin(){{{1
|
||||
"Places the cursor in the nerd tree window
|
||||
function! s:NERDTree.CursorToTreeWin()
|
||||
function! s:NERDTree.CursorToTreeWin(...)
|
||||
call g:NERDTree.MustBeOpen()
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', 1)
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', a:0 >0 ? a:1 : 1)
|
||||
endfunction
|
||||
|
||||
" Function: s:NERDTree.ExistsForBuffer() {{{1
|
||||
|
||||
@@ -195,7 +195,7 @@ function! s:Opener._newVSplit()
|
||||
endif
|
||||
|
||||
call nerdtree#exec('wincmd p', 1)
|
||||
call nerdtree#exec('vnew', 1)
|
||||
call nerdtree#exec('vsplit', 1)
|
||||
|
||||
let l:currentWindowNumber = winnr()
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ function! s:Path.copy(dest)
|
||||
let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd)
|
||||
endif
|
||||
|
||||
let cmd = cmd_prefix . ' ' . escape(self.str(), self._escChars()) . ' ' . escape(a:dest, self._escChars())
|
||||
let cmd = cmd_prefix . ' ' . shellescape(self.str()) . ' ' . shellescape(a:dest)
|
||||
let success = system(cmd)
|
||||
if v:shell_error !=# 0
|
||||
throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'"
|
||||
@@ -295,7 +295,10 @@ endfunction
|
||||
|
||||
" FUNCTION: Path.edit() {{{1
|
||||
function! s:Path.edit()
|
||||
exec 'edit ' . self.str({'format': 'Edit'})
|
||||
let l:bufname = self.str({'format': 'Edit'})
|
||||
if bufname('%') !=# l:bufname
|
||||
exec 'edit ' . l:bufname
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.extractDriveLetter(fullpath) {{{1
|
||||
@@ -543,26 +546,36 @@ endfunction
|
||||
" return 1 if this path is somewhere above the given path in the filesystem.
|
||||
"
|
||||
" a:path should be a dir
|
||||
function! s:Path.isAncestor(path)
|
||||
if !self.isDirectory
|
||||
return 0
|
||||
endif
|
||||
|
||||
let this = self.str()
|
||||
let that = a:path.str()
|
||||
return stridx(that, this) ==# 0
|
||||
function! s:Path.isAncestor(child)
|
||||
return a:child.isUnder(self)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.isUnder(path) {{{1
|
||||
" return 1 if this path is somewhere under the given path in the filesystem.
|
||||
function! s:Path.isUnder(path)
|
||||
if a:path.isDirectory ==# 0
|
||||
function! s:Path.isUnder(parent)
|
||||
if a:parent.isDirectory ==# 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let this = self.str()
|
||||
let that = a:path.str()
|
||||
return stridx(this, that . s:Path.Slash()) ==# 0
|
||||
if nerdtree#runningWindows() && a:parent.drive !=# self.drive
|
||||
return 0
|
||||
endif
|
||||
let l:this_count = len(self.pathSegments)
|
||||
if l:this_count ==# 0
|
||||
return 0
|
||||
endif
|
||||
let l:that_count = len(a:parent.pathSegments)
|
||||
if l:that_count ==# 0
|
||||
return 1
|
||||
endif
|
||||
if l:that_count >= l:this_count
|
||||
return 0
|
||||
endif
|
||||
for i in range(0, l:that_count-1)
|
||||
if self.pathSegments[i] !=# a:parent.pathSegments[i]
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.JoinPathStrings(...) {{{1
|
||||
|
||||
@@ -377,11 +377,17 @@ endfunction
|
||||
" 1. If cascaded, we don't know which dir is bookmarked or is a symlink.
|
||||
" 2. If the parent is a symlink or is bookmarked, you end up with unparsable
|
||||
" text, and NERDTree cannot get the path of any child node.
|
||||
" Also, return false if this directory is the tree root, which should never be
|
||||
" part of a cascade.
|
||||
function! s:TreeDirNode.isCascadable()
|
||||
if g:NERDTreeCascadeSingleChildDir ==# 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
if self.isRoot()
|
||||
return 0
|
||||
endif
|
||||
|
||||
if self.path.isSymLink
|
||||
return 0
|
||||
endif
|
||||
|
||||
@@ -209,7 +209,8 @@ function! NERDTreeMoveNode()
|
||||
|
||||
try
|
||||
if curNode.path.isDirectory
|
||||
let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# curNode.path.str() . "/.*"')
|
||||
let l:curPath = escape(curNode.path.str(),'\') . (nerdtree#runningWindows()?'\\':'/') . '.*'
|
||||
let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# "'.escape(l:curPath,'\').'"')
|
||||
else
|
||||
let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()')
|
||||
endif
|
||||
@@ -387,44 +388,67 @@ endfunction
|
||||
|
||||
" FUNCTION: NERDTreeQuickLook() {{{1
|
||||
function! NERDTreeQuickLook()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
if treenode !=# {}
|
||||
call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'")
|
||||
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||
|
||||
if empty(l:node)
|
||||
return
|
||||
endif
|
||||
|
||||
call system('qlmanage -p 2>/dev/null ' . shellescape(l:node.path.str()))
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeRevealInFinder() {{{1
|
||||
function! NERDTreeRevealInFinder()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
if treenode !=# {}
|
||||
call system("open -R '" . treenode.path.str() . "'")
|
||||
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||
|
||||
if empty(l:node)
|
||||
return
|
||||
endif
|
||||
|
||||
call system('open -R ' . shellescape(l:node.path.str()))
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeExecuteFile() {{{1
|
||||
function! NERDTreeExecuteFile()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
if treenode !=# {}
|
||||
call system("open '" . treenode.path.str() . "'")
|
||||
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||
|
||||
if empty(l:node)
|
||||
return
|
||||
endif
|
||||
|
||||
call system('open ' . shellescape(l:node.path.str()))
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeRevealFileLinux() {{{1
|
||||
function! NERDTreeRevealFileLinux()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
let parentnode = treenode.parent
|
||||
if parentnode !=# {}
|
||||
call system("xdg-open '" . parentnode.path.str() . "' &")
|
||||
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||
|
||||
if empty(l:node)
|
||||
return
|
||||
endif
|
||||
|
||||
" Handle the edge case of "/", which has no parent.
|
||||
if l:node.path.str() ==# '/'
|
||||
call system('xdg-open /')
|
||||
return
|
||||
endif
|
||||
|
||||
if empty(l:node.parent)
|
||||
return
|
||||
endif
|
||||
|
||||
call system('xdg-open ' . shellescape(l:node.parent.path.str()))
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeExecuteFileLinux() {{{1
|
||||
function! NERDTreeExecuteFileLinux()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
if treenode !=# {}
|
||||
call system("xdg-open '" . treenode.path.str() . "' &")
|
||||
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||
|
||||
if empty(l:node)
|
||||
return
|
||||
endif
|
||||
|
||||
call system('xdg-open ' . shellescape(l:node.path.str()))
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ endfunction
|
||||
function! s:FindParentVCSRoot(path)
|
||||
let l:path = a:path
|
||||
while !empty(l:path) &&
|
||||
\ l:path._str() !~# '^\(\a:\\\|\/\)$' &&
|
||||
\ l:path._str() !~# '^\(\a:[\\\/]\|\/\)$' &&
|
||||
\ !isdirectory(l:path._str() . '/.git') &&
|
||||
\ !isdirectory(l:path._str() . '/.svn') &&
|
||||
\ !isdirectory(l:path._str() . '/.hg') &&
|
||||
@@ -42,6 +42,6 @@ function! s:FindParentVCSRoot(path)
|
||||
\ !isdirectory(l:path._str() . '/_darcs')
|
||||
let l:path = l:path.getParent()
|
||||
endwhile
|
||||
return (empty(l:path) || l:path._str() =~# '^\(\a:\\\|\/\)$') ? a:path : l:path
|
||||
return (empty(l:path) || l:path._str() =~# '^\(\a:[\\\/]\|\/\)$') ? a:path : l:path
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ endfunction
|
||||
|
||||
function! NERDTreeFocus()
|
||||
if g:NERDTree.IsOpen()
|
||||
call g:NERDTree.CursorToTreeWin()
|
||||
call g:NERDTree.CursorToTreeWin(0)
|
||||
else
|
||||
call g:NERDTreeCreator.ToggleTabTree('')
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user