mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 11:53:48 -05:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
090791407e | ||
|
|
cea02c6d98 |
@@ -901,15 +901,6 @@ fridge for later ;)
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
7. Changelog *NERDTreeChangelog*
|
7. Changelog *NERDTreeChangelog*
|
||||||
|
|
||||||
2.14.3
|
|
||||||
Thanks to tpope for the following:
|
|
||||||
- use relative paths when doing edit commands if possible (useful if you
|
|
||||||
have %f on your statusline for example)
|
|
||||||
- allow relative paths for :NERDTree commands, eg ":NERDTree ../foo"
|
|
||||||
- fix a bug where the script used the directory of the current buffer
|
|
||||||
instead of vims cwd for the :NERDTree command
|
|
||||||
- bugfix for read only node highlighting
|
|
||||||
|
|
||||||
2.14.2
|
2.14.2
|
||||||
- when opening a file (with 'o' or double click) dont split the window
|
- when opening a file (with 'o' or double click) dont split the window
|
||||||
unless we absolutely have to. This should make the script work better
|
unless we absolutely have to. This should make the script work better
|
||||||
@@ -1263,8 +1254,6 @@ names began with a +.
|
|||||||
Thanks to Denis Pokataev for the bug report about the script failing when
|
Thanks to Denis Pokataev for the bug report about the script failing when
|
||||||
closing vim with :qa with a tree open in another tab.
|
closing vim with :qa with a tree open in another tab.
|
||||||
|
|
||||||
Thanks to tpope for his dope bug reporting.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
9. License *NERDTreeLicense*
|
9. License *NERDTreeLicense*
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||||
"
|
"
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
let s:NERD_tree_version = '2.14.3'
|
let s:NERD_tree_version = '2.14.2'
|
||||||
|
|
||||||
" SECTION: Script init stuff {{{1
|
" SECTION: Script init stuff {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
@@ -1539,21 +1539,12 @@ endfunction
|
|||||||
"Return: the string for this path that is suitable to be used with the :edit
|
"Return: the string for this path that is suitable to be used with the :edit
|
||||||
"command
|
"command
|
||||||
function! s:Path.strForEditCmd()
|
function! s:Path.strForEditCmd()
|
||||||
let p = self.str(1)
|
|
||||||
let cwd = getcwd()
|
|
||||||
|
|
||||||
if s:running_windows
|
if s:running_windows
|
||||||
let p = tolower(self.strForOS(0))
|
return self.strForOS(0)
|
||||||
let cwd = tolower(getcwd())
|
else
|
||||||
|
return self.str(1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"return a relative path if we can
|
|
||||||
if stridx(p, cwd) == 0
|
|
||||||
let p = strpart(p, strlen(cwd)+1)
|
|
||||||
endif
|
|
||||||
|
|
||||||
return p
|
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.strForGlob() {{{3
|
"FUNCTION: Path.strForGlob() {{{3
|
||||||
function! s:Path.strForGlob()
|
function! s:Path.strForGlob()
|
||||||
@@ -1677,14 +1668,8 @@ function! s:initNerdTree(name)
|
|||||||
if s:Bookmark.BookmarkExistsFor(a:name)
|
if s:Bookmark.BookmarkExistsFor(a:name)
|
||||||
let path = s:Bookmark.BookmarkFor(a:name).path
|
let path = s:Bookmark.BookmarkFor(a:name).path
|
||||||
else
|
else
|
||||||
let dir = a:name == '' ? getcwd() : a:name
|
let dir = a:name == '' ? expand('%:p:h') : a:name
|
||||||
|
|
||||||
"hack to get an absolute path if a relative path is given
|
|
||||||
if dir =~ '^\.'
|
|
||||||
let dir = getcwd() . s:os_slash . dir
|
|
||||||
endif
|
|
||||||
let dir = resolve(dir)
|
let dir = resolve(dir)
|
||||||
|
|
||||||
try
|
try
|
||||||
let path = s:Path.New(dir)
|
let path = s:Path.New(dir)
|
||||||
catch /NERDTree.Path.InvalidArguments/
|
catch /NERDTree.Path.InvalidArguments/
|
||||||
@@ -2245,37 +2230,6 @@ endfunction
|
|||||||
function! s:isTreeOpen()
|
function! s:isTreeOpen()
|
||||||
return s:getTreeWinNum() != -1
|
return s:getTreeWinNum() != -1
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:isWindowUsable(winnumber) {{{2
|
|
||||||
"Returns 1 if opening a file from the tree in the given window requires it to
|
|
||||||
"be split
|
|
||||||
"
|
|
||||||
"Args:
|
|
||||||
"winnumber: the number of the window in question
|
|
||||||
function! s:isWindowUsable(winnumber)
|
|
||||||
"gotta split if theres only one window (i.e. the NERD tree)
|
|
||||||
if winnr("$") == 1
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
let oldwinnr = winnr()
|
|
||||||
exec a:winnumber . "wincmd p"
|
|
||||||
let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow')
|
|
||||||
let modified = &modified
|
|
||||||
exec oldwinnr . "wincmd p"
|
|
||||||
|
|
||||||
"if its a special window e.g. quickfix or another explorer plugin then we
|
|
||||||
"have to split
|
|
||||||
if specialWindow
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
if &hidden
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
return !modified || s:bufInWindows(winbufnr(a:winnumber)) >= 2
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" FUNCTION: s:jumpToChild(direction) {{{2
|
" FUNCTION: s:jumpToChild(direction) {{{2
|
||||||
" Args:
|
" Args:
|
||||||
" direction: 0 if going to first child, 1 if going to last
|
" direction: 0 if going to first child, 1 if going to last
|
||||||
@@ -2346,11 +2300,11 @@ function! s:openFileNode(treenode)
|
|||||||
exec winnr . "wincmd w"
|
exec winnr . "wincmd w"
|
||||||
|
|
||||||
else
|
else
|
||||||
if !s:isWindowUsable(winnr("#")) && s:firstNormalWindow() == -1
|
if s:windowIsUsable(winnr("#")) && s:firstNormalWindow() == -1
|
||||||
call s:openFileNodeSplit(a:treenode)
|
call s:openFileNodeSplit(a:treenode)
|
||||||
else
|
else
|
||||||
try
|
try
|
||||||
if !s:isWindowUsable(winnr("#"))
|
if s:windowIsUsable(winnr("#"))
|
||||||
exec s:firstNormalWindow() . "wincmd w"
|
exec s:firstNormalWindow() . "wincmd w"
|
||||||
else
|
else
|
||||||
wincmd p
|
wincmd p
|
||||||
@@ -2690,7 +2644,7 @@ function! s:setupSyntaxHighlighting()
|
|||||||
syn match treeHelp #^".*# contains=treeHelpKey,treeHelpTitle,treeFlag,treeToggleOff,treeToggleOn,treeHelpCommand
|
syn match treeHelp #^".*# contains=treeHelpKey,treeHelpTitle,treeFlag,treeToggleOff,treeToggleOn,treeHelpCommand
|
||||||
|
|
||||||
"highlighting for readonly files
|
"highlighting for readonly files
|
||||||
syn match treeRO #.*\[RO\]#hs=s+2 contains=treeFlag,treeBookmark,treePart,treePartFile
|
syn match treeRO #[\/0-9a-zA-Z]\+.*\[RO\]# contains=treeFlag,treeBookmark
|
||||||
|
|
||||||
"highlighting for sym links
|
"highlighting for sym links
|
||||||
syn match treeLink #[^-| `].* -> # contains=treeBookmark,treeOpenable,treeClosable,treeDirSlash
|
syn match treeLink #[^-| `].* -> # contains=treeBookmark,treeOpenable,treeClosable,treeDirSlash
|
||||||
@@ -2813,6 +2767,37 @@ function! s:toggle(dir)
|
|||||||
call s:initNerdTree(a:dir)
|
call s:initNerdTree(a:dir)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
"FUNCTION: s:windowIsUsable() {{{2
|
||||||
|
"Returns 1 if opening a file from the tree in the given window requires it to
|
||||||
|
"be split
|
||||||
|
"
|
||||||
|
"Args:
|
||||||
|
"winnumber: the number of the window in question
|
||||||
|
function! s:windowIsUsable(winnumber)
|
||||||
|
"gotta split if theres only one window (i.e. the NERD tree)
|
||||||
|
if winnr("$") == 1
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
let oldwinnr = winnr()
|
||||||
|
exec a:winnumber . "wincmd p"
|
||||||
|
let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow')
|
||||||
|
let modified = &modified
|
||||||
|
exec oldwinnr . "wincmd p"
|
||||||
|
|
||||||
|
"if its a special window e.g. quickfix or another explorer plugin then we
|
||||||
|
"have to split
|
||||||
|
if specialWindow
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
if &hidden
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
return modified && s:bufInWindows(winbufnr(a:winnumber)) < 2
|
||||||
|
endfunction
|
||||||
|
|
||||||
"SECTION: Interface bindings {{{1
|
"SECTION: Interface bindings {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
"FUNCTION: s:activateNode(forceKeepWindowOpen) {{{2
|
"FUNCTION: s:activateNode(forceKeepWindowOpen) {{{2
|
||||||
|
|||||||
Reference in New Issue
Block a user