mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 11:53:48 -05:00
Compare commits
6 Commits
7.1.1
...
broken-sym
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62884a4005 | ||
|
|
9eeacfd04b | ||
|
|
6ad85ec29b | ||
|
|
f3a4d8eaa8 | ||
|
|
bdf81a086d | ||
|
|
60b5e602e9 |
@@ -13,6 +13,9 @@
|
|||||||
- Pull Request Title n (PR Author) [PR Number](Link to PR)
|
- Pull Request Title n (PR Author) [PR Number](Link to PR)
|
||||||
-->
|
-->
|
||||||
#### 7.1
|
#### 7.1
|
||||||
|
- **.2**:
|
||||||
|
- fix: GetWinNum regex pattern. (rzvxa) [#1409](https://github.com/preservim/nerdtree/pull/1409)
|
||||||
|
- fix: session restore for nerdtree buffers. (rzvxa) [#1405](https://github.com/preservim/nerdtree/pull/1405)
|
||||||
- **.1**:
|
- **.1**:
|
||||||
- fix: change default binding of filelines to `FL`. (rzvxa) [#1400](https://github.com/preservim/nerdtree/pull/1400)
|
- fix: change default binding of filelines to `FL`. (rzvxa) [#1400](https://github.com/preservim/nerdtree/pull/1400)
|
||||||
- fix: toggle zoom resizing. (ds2606) [#1395](https://github.com/preservim/nerdtree/pull/1395)
|
- fix: toggle zoom resizing. (ds2606) [#1395](https://github.com/preservim/nerdtree/pull/1395)
|
||||||
|
|||||||
@@ -234,6 +234,38 @@ function! nerdtree#pathEquals(lhs, rhs) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: nerdtree#onBufLeave() {{{2
|
||||||
|
" used for handling the nerdtree BufLeave/WinLeave events.
|
||||||
|
function! nerdtree#onBufLeave() abort
|
||||||
|
" detect whether we are in the middle of sourcing a session.
|
||||||
|
" if it is a buffer from the sourced session we need to restore it.
|
||||||
|
if exists('g:SessionLoad') && !exists('b:NERDTree')
|
||||||
|
let bname = bufname('%')
|
||||||
|
" is the buffer for a tab tree?
|
||||||
|
if bname =~# '^' . g:NERDTreeCreator.BufNamePrefix() . 'tab_\d\+$'
|
||||||
|
" rename loaded buffer and mark it as trash to prevent this event
|
||||||
|
" getting fired again
|
||||||
|
exec 'file TRASH_' . bname
|
||||||
|
" delete the trash buffer
|
||||||
|
exec 'bwipeout!'
|
||||||
|
" rescue the tab tree at the current working directory
|
||||||
|
call g:NERDTreeCreator.CreateTabTree(getcwd())
|
||||||
|
" is the buffer for a window tree?
|
||||||
|
elseif bname =~# '^' . g:NERDTreeCreator.BufNamePrefix(). 'win_\d\+$'
|
||||||
|
" rescue the window tree at the current working directory
|
||||||
|
call g:NERDTreeCreator.CreateWindowTree(getcwd())
|
||||||
|
else " unknown buffer type
|
||||||
|
" rename buffer to mark it as broken.
|
||||||
|
exec 'file BROKEN_' . bname
|
||||||
|
call nerdtree#echoError('Failed to restore "' . bname . '" from session. Is this session created with an older version of NERDTree?')
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if g:NERDTree.IsOpen()
|
||||||
|
call b:NERDTree.ui.saveScreenState()
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
" SECTION: View Functions {{{1
|
" SECTION: View Functions {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ function! nerdtree#ui_glue#createDefaultBindings() abort
|
|||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': 'Node', 'callback': s.'jumpToPrevSibling' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': 'Node', 'callback': s.'jumpToPrevSibling' })
|
||||||
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpBookmarks, 'scope': 'all', 'callback': s.'jumpToBookmarks' })
|
||||||
|
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' })
|
||||||
@@ -496,6 +497,21 @@ function! s:jumpToSibling(node, forward) abort
|
|||||||
call b:NERDTree.ui.centerView()
|
call b:NERDTree.ui.centerView()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:jumpToBookmarks() {{{1
|
||||||
|
" moves the cursor to the bookmark table
|
||||||
|
function! s:jumpToBookmarks() abort
|
||||||
|
try
|
||||||
|
if b:NERDTree.ui.getShowBookmarks()
|
||||||
|
call g:NERDTree.CursorToBookmarkTable()
|
||||||
|
else
|
||||||
|
call b:NERDTree.ui.setShowBookmarks(1)
|
||||||
|
endif
|
||||||
|
catch /^NERDTree/
|
||||||
|
call nerdtree#echoError('Failed to jump to the bookmark table')
|
||||||
|
return
|
||||||
|
endtry
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
|
" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
|
||||||
" Open the Bookmark that has the specified name. This function provides the
|
" Open the Bookmark that has the specified name. This function provides the
|
||||||
" implementation for the :OpenBookmark command.
|
" implementation for the :OpenBookmark command.
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ function! s:Creator.createWindowTree(dir)
|
|||||||
|
|
||||||
"we need a unique name for each window tree buffer to ensure they are
|
"we need a unique name for each window tree buffer to ensure they are
|
||||||
"all independent
|
"all independent
|
||||||
exec g:NERDTreeCreatePrefix . ' edit ' . self._nextBufferName()
|
exec g:NERDTreeCreatePrefix . ' edit ' . self._nextBufferName('win')
|
||||||
|
|
||||||
call self._createNERDTree(path, 'window')
|
call self._createNERDTree(path, 'window')
|
||||||
let b:NERDTree._previousBuf = bufnr(previousBuf)
|
let b:NERDTree._previousBuf = bufnr(previousBuf)
|
||||||
@@ -210,7 +210,7 @@ function! s:Creator._createTreeWin()
|
|||||||
let l:splitSize = g:NERDTreeWinSize
|
let l:splitSize = g:NERDTreeWinSize
|
||||||
|
|
||||||
if !g:NERDTree.ExistsForTab()
|
if !g:NERDTree.ExistsForTab()
|
||||||
let t:NERDTreeBufName = self._nextBufferName()
|
let t:NERDTreeBufName = self._nextBufferName('tab')
|
||||||
silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' new'
|
silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' new'
|
||||||
silent! execute 'edit ' . t:NERDTreeBufName
|
silent! execute 'edit ' . t:NERDTreeBufName
|
||||||
silent! execute l:splitDirection . ' resize '. l:splitSize
|
silent! execute l:splitDirection . ' resize '. l:splitSize
|
||||||
@@ -244,10 +244,22 @@ function! s:Creator.New()
|
|||||||
return newCreator
|
return newCreator
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:Creator._nextBufferName() {{{1
|
" FUNCTION: s:Creator._nextBufferName(type='') {{{1
|
||||||
" returns the buffer name for the next nerd tree
|
" gets an optional buffer type of either 'tab' or 'win'.
|
||||||
function! s:Creator._nextBufferName()
|
" returns the buffer name for the next nerd tree of such type.
|
||||||
let name = s:Creator.BufNamePrefix() . self._nextBufferNumber()
|
function! s:Creator._nextBufferName(...)
|
||||||
|
if a:0 > 0
|
||||||
|
let type = a:1
|
||||||
|
else
|
||||||
|
let type = ''
|
||||||
|
end
|
||||||
|
let name = s:Creator.BufNamePrefix()
|
||||||
|
if type ==# 'tab'
|
||||||
|
let name = name . 'tab_'
|
||||||
|
elseif type ==# 'win'
|
||||||
|
let name = name . 'win_'
|
||||||
|
endif
|
||||||
|
let name = name . self._nextBufferNumber()
|
||||||
return name
|
return name
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ function! s:NERDTree.GetWinNum()
|
|||||||
|
|
||||||
" If WindowTree, there is no t:NERDTreeBufName variable. Search all windows.
|
" If WindowTree, there is no t:NERDTreeBufName variable. Search all windows.
|
||||||
for w in range(1,winnr('$'))
|
for w in range(1,winnr('$'))
|
||||||
if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$'
|
if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . 'win_\d\+$'
|
||||||
return w
|
return w
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
@@ -62,7 +62,11 @@ function! s:Path.cacheDisplayString() abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if self.isSymLink
|
if self.isSymLink
|
||||||
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' -> ' . self.symLinkDest
|
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' -> '
|
||||||
|
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . self.symLinkDest
|
||||||
|
if self.isBroken
|
||||||
|
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . g:NERDTreeGlyphBroken
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !self.isDirectory && b:NERDTree.ui.getShowFileLines() != 0
|
if !self.isDirectory && b:NERDTree.ui.getShowFileLines() != 0
|
||||||
@@ -607,24 +611,33 @@ function! s:Path.readInfoFromDisk(fullpath)
|
|||||||
|
|
||||||
let fullpath = s:Path.WinToUnixPath(a:fullpath)
|
let fullpath = s:Path.WinToUnixPath(a:fullpath)
|
||||||
|
|
||||||
if getftype(fullpath) ==# 'fifo'
|
let ftype = getftype(fullpath)
|
||||||
|
|
||||||
|
if ftype ==# 'fifo'
|
||||||
throw 'NERDTree.InvalidFiletypeError: Cant handle FIFO files: ' . a:fullpath
|
throw 'NERDTree.InvalidFiletypeError: Cant handle FIFO files: ' . a:fullpath
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let self.pathSegments = filter(split(fullpath, '/'), '!empty(v:val)')
|
let self.pathSegments = filter(split(fullpath, '/'), '!empty(v:val)')
|
||||||
|
|
||||||
let self.isReadOnly = 0
|
|
||||||
if isdirectory(a:fullpath)
|
if isdirectory(a:fullpath)
|
||||||
let self.isDirectory = 1
|
let self.isDirectory = 1
|
||||||
|
let self.isReadOnly = 0
|
||||||
|
let self.isBroken = 0
|
||||||
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
|
||||||
|
let self.isBroken = 0
|
||||||
|
elseif ftype ==# 'link'
|
||||||
|
let self.isDirectory = 0
|
||||||
|
let self.isReadOnly = 0
|
||||||
|
let self.isBroken = 1
|
||||||
else
|
else
|
||||||
|
call nerdtree#echoWarning('invalid ' . a:fullpath . 'file type: ' . ftype)
|
||||||
throw 'NERDTree.InvalidArgumentsError: Invalid path = ' . a:fullpath
|
throw 'NERDTree.InvalidArgumentsError: Invalid path = ' . a:fullpath
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let self.isExecutable = 0
|
let self.isExecutable = 0
|
||||||
if !self.isDirectory
|
if !self.isDirectory && !self.isBroken
|
||||||
let self.isExecutable = getfperm(a:fullpath) =~# 'x'
|
let self.isExecutable = getfperm(a:fullpath) =~# 'x'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ function! s:TreeDirNode._glob(pattern, all)
|
|||||||
" See ':h version7.txt' and ':h version8.txt' for details on the
|
" See ':h version7.txt' and ':h version8.txt' for details on the
|
||||||
" development of the glob() and globpath() functions.
|
" development of the glob() and globpath() functions.
|
||||||
if v:version > 704 || (v:version ==# 704 && has('patch654'))
|
if v:version > 704 || (v:version ==# 704 && has('patch654'))
|
||||||
let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1, 0)
|
let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1, 1)
|
||||||
elseif v:version ==# 704 && has('patch279')
|
elseif v:version ==# 704 && has('patch279')
|
||||||
let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1)
|
let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1)
|
||||||
elseif v:version > 702 || (v:version ==# 702 && has('patch051'))
|
elseif v:version > 702 || (v:version ==# 702 && has('patch051'))
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ function! s:UI._dumpHelp()
|
|||||||
let help .= "\"\n\" ----------------------------\n"
|
let help .= "\"\n\" ----------------------------\n"
|
||||||
let help .= "\" Bookmark table mappings~\n"
|
let help .= "\" Bookmark table mappings~\n"
|
||||||
let help .= "\" double-click,\n"
|
let help .= "\" double-click,\n"
|
||||||
|
let help .= '" '. g:NERDTreeMapJumpBookmarks .": jump to bookmark table\n"
|
||||||
let help .= '" '. g:NERDTreeMapActivateNode .": open bookmark\n"
|
let help .= '" '. g:NERDTreeMapActivateNode .": open bookmark\n"
|
||||||
let help .= '" '. g:NERDTreeMapPreview .": preview file\n"
|
let help .= '" '. g:NERDTreeMapPreview .": preview file\n"
|
||||||
let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n"
|
let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n"
|
||||||
@@ -482,10 +483,10 @@ function! s:UI.toggleIgnoreFilter()
|
|||||||
call self.centerView()
|
call self.centerView()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
|
" FUNCTION: s:UI.setShowBookmarks() {{{1
|
||||||
" Toggle the visibility of the Bookmark table.
|
" Sets the visibility of the Bookmark table.
|
||||||
function! s:UI.toggleShowBookmarks()
|
function! s:UI.setShowBookmarks(value)
|
||||||
let self._showBookmarks = !self._showBookmarks
|
let self._showBookmarks = a:value
|
||||||
|
|
||||||
if self.getShowBookmarks()
|
if self.getShowBookmarks()
|
||||||
call self.nerdtree.render()
|
call self.nerdtree.render()
|
||||||
@@ -503,6 +504,12 @@ function! s:UI.toggleShowBookmarks()
|
|||||||
call self.centerView()
|
call self.centerView()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
|
||||||
|
" Toggle the visibility of the Bookmark table.
|
||||||
|
function! s:UI.toggleShowBookmarks()
|
||||||
|
call self.setShowBookmarks(!self._showBookmarks)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:UI.toggleShowFiles() {{{1
|
" FUNCTION: s:UI.toggleShowFiles() {{{1
|
||||||
" toggles the display of hidden files
|
" toggles the display of hidden files
|
||||||
function! s:UI.toggleShowFiles()
|
function! s:UI.toggleShowFiles()
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ let g:NERDTreeSortOrder = get(g:, 'NERDTreeSortOrder', ['\/$', '*', '\.swp$',
|
|||||||
let g:NERDTreeOldSortOrder = []
|
let g:NERDTreeOldSortOrder = []
|
||||||
|
|
||||||
let g:NERDTreeGlyphReadOnly = get(g:, 'NERDTreeGlyphReadOnly', 'RO')
|
let g:NERDTreeGlyphReadOnly = get(g:, 'NERDTreeGlyphReadOnly', 'RO')
|
||||||
|
let g:NERDTreeGlyphBroken = get(g:, 'NERDTreeGlyphBroken', ' [*broken]')
|
||||||
|
|
||||||
if has('conceal')
|
if has('conceal')
|
||||||
let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\x07")
|
let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\x07")
|
||||||
@@ -101,6 +102,7 @@ endif
|
|||||||
|
|
||||||
"SECTION: Init variable calls for key mappings {{{2
|
"SECTION: Init variable calls for key mappings {{{2
|
||||||
let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '<CR>')
|
let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '<CR>')
|
||||||
|
let g:NERDTreeMapJumpBookmarks = get(g:, 'NERDTreeMapJumpBookmarks', 'gb')
|
||||||
let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o')
|
let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o')
|
||||||
let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C')
|
let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C')
|
||||||
let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd')
|
let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd')
|
||||||
@@ -151,7 +153,7 @@ call nerdtree#ui_glue#setupCommands()
|
|||||||
"============================================================
|
"============================================================
|
||||||
augroup NERDTree
|
augroup NERDTree
|
||||||
"Save the cursor position whenever we close the nerd tree
|
"Save the cursor position whenever we close the nerd tree
|
||||||
exec 'autocmd BufLeave,WinLeave '. g:NERDTreeCreator.BufNamePrefix() .'* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif'
|
exec 'autocmd BufLeave,WinLeave '. g:NERDTreeCreator.BufNamePrefix() .'* call nerdtree#onBufLeave()'
|
||||||
|
|
||||||
"disallow insert mode in the NERDTree
|
"disallow insert mode in the NERDTree
|
||||||
exec 'autocmd BufEnter,WinEnter '. g:NERDTreeCreator.BufNamePrefix() .'* stopinsert'
|
exec 'autocmd BufEnter,WinEnter '. g:NERDTreeCreator.BufNamePrefix() .'* stopinsert'
|
||||||
|
|||||||
Reference in New Issue
Block a user