mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 11:53:48 -05:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e77fb2fef | ||
|
|
29a321d061 | ||
|
|
0257d64248 | ||
|
|
2d7cb043d4 | ||
|
|
f767dd34a0 | ||
|
|
832bbaa729 | ||
|
|
343508e9fd | ||
|
|
495b4e781a | ||
|
|
e67324fdea | ||
|
|
5249b30fbf | ||
|
|
09b165cfac | ||
|
|
6224d20698 |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -4,6 +4,16 @@
|
|||||||
version in an unordered list. The format is:
|
version in an unordered list. The format is:
|
||||||
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
|
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
|
||||||
-->
|
-->
|
||||||
|
#### 6.7
|
||||||
|
- **.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
|
#### 6.6
|
||||||
- **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087)
|
- **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087)
|
||||||
- **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085)
|
- **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085)
|
||||||
|
|||||||
@@ -284,6 +284,7 @@ endfunction
|
|||||||
" FUNCTION: s:findAndRevealPath(pathStr) {{{1
|
" FUNCTION: s:findAndRevealPath(pathStr) {{{1
|
||||||
function! s:findAndRevealPath(pathStr) abort
|
function! s:findAndRevealPath(pathStr) abort
|
||||||
let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p')
|
let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p')
|
||||||
|
let l:revealOpts = {}
|
||||||
|
|
||||||
if empty(l:pathStr)
|
if empty(l:pathStr)
|
||||||
call nerdtree#echoWarning('no file for the current buffer')
|
call nerdtree#echoWarning('no file for the current buffer')
|
||||||
@@ -292,6 +293,7 @@ function! s:findAndRevealPath(pathStr) abort
|
|||||||
|
|
||||||
if !filereadable(l:pathStr)
|
if !filereadable(l:pathStr)
|
||||||
let l:pathStr = fnamemodify(l:pathStr, ':h')
|
let l:pathStr = fnamemodify(l:pathStr, ':h')
|
||||||
|
let l:revealOpts['open'] = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -327,7 +329,7 @@ function! s:findAndRevealPath(pathStr) abort
|
|||||||
call b:NERDTree.ui.setShowHidden(1)
|
call b:NERDTree.ui.setShowHidden(1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:node = b:NERDTree.root.reveal(l:pathObj)
|
let l:node = b:NERDTree.root.reveal(l:pathObj, l:revealOpts)
|
||||||
call b:NERDTree.render()
|
call b:NERDTree.render()
|
||||||
call l:node.putCursorHere(1, 0)
|
call l:node.putCursorHere(1, 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -1353,12 +1353,12 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()*
|
|||||||
Example: >
|
Example: >
|
||||||
call NERDTreeAddKeyMap({
|
call NERDTreeAddKeyMap({
|
||||||
\ 'key': 'foo',
|
\ 'key': 'foo',
|
||||||
\ 'callback': 'NERDTreeCDHandler',
|
\ 'callback': 'NERDTreeEchoPathHandler',
|
||||||
\ 'quickhelpText': 'echo full path of current node',
|
\ 'quickhelpText': 'echo full path of current node',
|
||||||
\ 'scope': 'DirNode' })
|
\ 'scope': 'DirNode' })
|
||||||
|
|
||||||
function! NERDTreeCDHandler(dirnode)
|
function! NERDTreeEchoPathHandler(dirnode)
|
||||||
call a:dirnode.changeToDir()
|
echo a:dirnode.path.str()
|
||||||
endfunction
|
endfunction
|
||||||
<
|
<
|
||||||
This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim.
|
This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim.
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ function! s:Creator.toggleTabTree(dir)
|
|||||||
if g:NERDTree.ExistsForTab()
|
if g:NERDTree.ExistsForTab()
|
||||||
if !g:NERDTree.IsOpen()
|
if !g:NERDTree.IsOpen()
|
||||||
call self._createTreeWin()
|
call self._createTreeWin()
|
||||||
if !empty(a:dir)
|
if !empty(a:dir) && a:dir !=# b:NERDTree.root.path.str()
|
||||||
call self.createTabTree(a:dir)
|
call self.createTabTree(a:dir)
|
||||||
elseif !&hidden
|
elseif !&hidden
|
||||||
call b:NERDTree.render()
|
call b:NERDTree.render()
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ function! s:Opener._newVSplit()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
call nerdtree#exec('wincmd p', 1)
|
call nerdtree#exec('wincmd p', 1)
|
||||||
call nerdtree#exec('vnew', 1)
|
call nerdtree#exec('vsplit', 1)
|
||||||
|
|
||||||
let l:currentWindowNumber = winnr()
|
let l:currentWindowNumber = winnr()
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ function! s:Path.copy(dest)
|
|||||||
let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd)
|
let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd)
|
||||||
endif
|
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)
|
let success = system(cmd)
|
||||||
if v:shell_error !=# 0
|
if v:shell_error !=# 0
|
||||||
throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'"
|
throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'"
|
||||||
@@ -295,7 +295,10 @@ endfunction
|
|||||||
|
|
||||||
" FUNCTION: Path.edit() {{{1
|
" FUNCTION: Path.edit() {{{1
|
||||||
function! s:Path.edit()
|
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
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: Path.extractDriveLetter(fullpath) {{{1
|
" FUNCTION: Path.extractDriveLetter(fullpath) {{{1
|
||||||
|
|||||||
@@ -209,7 +209,8 @@ function! NERDTreeMoveNode()
|
|||||||
|
|
||||||
try
|
try
|
||||||
if curNode.path.isDirectory
|
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
|
else
|
||||||
let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()')
|
let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()')
|
||||||
endif
|
endif
|
||||||
@@ -387,44 +388,67 @@ endfunction
|
|||||||
|
|
||||||
" FUNCTION: NERDTreeQuickLook() {{{1
|
" FUNCTION: NERDTreeQuickLook() {{{1
|
||||||
function! NERDTreeQuickLook()
|
function! NERDTreeQuickLook()
|
||||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||||
if treenode !=# {}
|
|
||||||
call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'")
|
if empty(l:node)
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
call system('qlmanage -p 2>/dev/null ' . shellescape(l:node.path.str()))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: NERDTreeRevealInFinder() {{{1
|
" FUNCTION: NERDTreeRevealInFinder() {{{1
|
||||||
function! NERDTreeRevealInFinder()
|
function! NERDTreeRevealInFinder()
|
||||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||||
if treenode !=# {}
|
|
||||||
call system("open -R '" . treenode.path.str() . "'")
|
if empty(l:node)
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
call system('open -R ' . shellescape(l:node.path.str()))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: NERDTreeExecuteFile() {{{1
|
" FUNCTION: NERDTreeExecuteFile() {{{1
|
||||||
function! NERDTreeExecuteFile()
|
function! NERDTreeExecuteFile()
|
||||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||||
if treenode !=# {}
|
|
||||||
call system("open '" . treenode.path.str() . "'")
|
if empty(l:node)
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
call system('open ' . shellescape(l:node.path.str()))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: NERDTreeRevealFileLinux() {{{1
|
" FUNCTION: NERDTreeRevealFileLinux() {{{1
|
||||||
function! NERDTreeRevealFileLinux()
|
function! NERDTreeRevealFileLinux()
|
||||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||||
let parentnode = treenode.parent
|
|
||||||
if parentnode !=# {}
|
if empty(l:node)
|
||||||
call system("xdg-open '" . parentnode.path.str() . "' &")
|
return
|
||||||
endif
|
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
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: NERDTreeExecuteFileLinux() {{{1
|
" FUNCTION: NERDTreeExecuteFileLinux() {{{1
|
||||||
function! NERDTreeExecuteFileLinux()
|
function! NERDTreeExecuteFileLinux()
|
||||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||||
if treenode !=# {}
|
|
||||||
call system("xdg-open '" . treenode.path.str() . "' &")
|
if empty(l:node)
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
call system('xdg-open ' . shellescape(l:node.path.str()))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" vim: set sw=4 sts=4 et fdm=marker:
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ endfunction
|
|||||||
function! s:FindParentVCSRoot(path)
|
function! s:FindParentVCSRoot(path)
|
||||||
let l:path = a:path
|
let l:path = a:path
|
||||||
while !empty(l:path) &&
|
while !empty(l:path) &&
|
||||||
\ l:path._str() !~# '^\(\a:\\\|\/\)$' &&
|
\ l:path._str() !~# '^\(\a:[\\\/]\|\/\)$' &&
|
||||||
\ !isdirectory(l:path._str() . '/.git') &&
|
\ !isdirectory(l:path._str() . '/.git') &&
|
||||||
\ !isdirectory(l:path._str() . '/.svn') &&
|
\ !isdirectory(l:path._str() . '/.svn') &&
|
||||||
\ !isdirectory(l:path._str() . '/.hg') &&
|
\ !isdirectory(l:path._str() . '/.hg') &&
|
||||||
@@ -42,6 +42,6 @@ function! s:FindParentVCSRoot(path)
|
|||||||
\ !isdirectory(l:path._str() . '/_darcs')
|
\ !isdirectory(l:path._str() . '/_darcs')
|
||||||
let l:path = l:path.getParent()
|
let l:path = l:path.getParent()
|
||||||
endwhile
|
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
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user