Compare commits

...

10 Commits

Author SHA1 Message Date
Martin Grenfell
9aba1c17f6 switch to version 2.14.3 2008-12-13 11:29:30 +13:00
Martin Grenfell
0fc5d3f656 update changelog and credits 2008-12-13 11:29:21 +13:00
Martin Grenfell
729abf8e9b bugfix for read only node highlighting
previously, it wasnt highlighting the leading non-alphanumeric bits of RO files like   _foo.bar
2008-12-07 12:05:00 +13:00
Martin Grenfell
96215c5da6 use reletive paths for edit commands if possible 2008-11-30 20:05:54 +13:00
Martin Grenfell
f4c455bc2f fix a typo 2008-11-29 00:11:23 +13:00
Martin Grenfell
22904e41de allow relative paths for :NERDTree commands 2008-11-29 00:07:23 +13:00
Martin Grenfell
d49c742daf use the cwd instead of the dir of the current file for :NERDTree 2008-11-29 00:06:59 +13:00
Martin Grenfell
a59a2f6177 switch to version 2.14.2 2008-10-29 20:19:43 +13:00
Martin Grenfell
2f399b9ba4 update changelog and credits 2008-10-29 20:19:43 +13:00
Martin Grenfell
4b61723952 rename and fix s:windowIsUsable() 2008-10-29 10:07:32 +13:00
2 changed files with 88 additions and 42 deletions

View File

@@ -901,9 +901,26 @@ fridge for later ;)
==============================================================================
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
- compatibility bugfix for older version of vim, thanks to knekk for
helping me track it down
- 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
with other explorer plugins. Thanks to Ryan Penn, Simon Peter Nicholls
and Michael
- fix a bug where directories starting with a '+' char could not be opened.
Thanks to Tomasz Chomiuk.
- fix a bug where closing vim with :qa with a tree open in another tab
would break, thanks to Denis Pokataev.
- compatibility bugfix for older versions of vim, thanks to knekk for
helping me track it down and to Sean Chou.
2.14.1
- dont clobber &cpo. Thanks to godlygeek for the bug report.
@@ -1234,6 +1251,20 @@ Chur to godlygeek for reporting a bug where &cpo was getting clobbered.
Cheers to knekk for helping me track down a bug when overwriting dictionary
keys that only occurred in some versions of vim.
Thanks also to Sean Chou for the bug report about the above bug.
Thanks to Ryan Penn, Simon Peter Nicholls and Michael for pointing out an issue
where the script was splitting constantly when using the 'o' mapping while
other explorers were open.
Thanks to Tomasz Chomiuk for the bug report about the script failing when dir
names began with a +.
Thanks to Denis Pokataev for the bug report about the script failing when
closing vim with :qa with a tree open in another tab.
Thanks to tpope for his dope bug reporting.
==============================================================================
9. License *NERDTreeLicense*

View File

@@ -2,7 +2,7 @@
" File: NERD_tree.vim
" Description: vim global plugin that provides a nice tree explorer
" Maintainer: Martin Grenfell <martin_grenfell at msn dot com>
" Last Change: 20 July, 2008
" Last Change: 29 October, 2008
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
@@ -10,7 +10,7 @@
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
" ============================================================================
let s:NERD_tree_version = '2.14.1'
let s:NERD_tree_version = '2.14.3'
" SECTION: Script init stuff {{{1
"============================================================
@@ -1539,12 +1539,21 @@ endfunction
"Return: the string for this path that is suitable to be used with the :edit
"command
function! s:Path.strForEditCmd()
let p = self.str(1)
let cwd = getcwd()
if s:running_windows
return self.strForOS(0)
else
return self.str(1)
let p = tolower(self.strForOS(0))
let cwd = tolower(getcwd())
endif
"return a relative path if we can
if stridx(p, cwd) == 0
let p = strpart(p, strlen(cwd)+1)
endif
return p
endfunction
"FUNCTION: Path.strForGlob() {{{3
function! s:Path.strForGlob()
@@ -1668,8 +1677,14 @@ function! s:initNerdTree(name)
if s:Bookmark.BookmarkExistsFor(a:name)
let path = s:Bookmark.BookmarkFor(a:name).path
else
let dir = a:name == '' ? expand('%:p:h') : a:name
let dir = a:name == '' ? getcwd() : 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)
try
let path = s:Path.New(dir)
catch /NERDTree.Path.InvalidArguments/
@@ -2230,6 +2245,37 @@ endfunction
function! s:isTreeOpen()
return s:getTreeWinNum() != -1
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
" Args:
" direction: 0 if going to first child, 1 if going to last
@@ -2300,11 +2346,11 @@ function! s:openFileNode(treenode)
exec winnr . "wincmd w"
else
if s:windowIsUsable(winnr("#")) && s:firstNormalWindow() == -1
if !s:isWindowUsable(winnr("#")) && s:firstNormalWindow() == -1
call s:openFileNodeSplit(a:treenode)
else
try
if s:windowIsUsable(winnr("#"))
if !s:isWindowUsable(winnr("#"))
exec s:firstNormalWindow() . "wincmd w"
else
wincmd p
@@ -2644,7 +2690,7 @@ function! s:setupSyntaxHighlighting()
syn match treeHelp #^".*# contains=treeHelpKey,treeHelpTitle,treeFlag,treeToggleOff,treeToggleOn,treeHelpCommand
"highlighting for readonly files
syn match treeRO #[\/0-9a-zA-Z]\+.*\[RO\]# contains=treeFlag,treeBookmark
syn match treeRO #.*\[RO\]#hs=s+2 contains=treeFlag,treeBookmark,treePart,treePartFile
"highlighting for sym links
syn match treeLink #[^-| `].* -> # contains=treeBookmark,treeOpenable,treeClosable,treeDirSlash
@@ -2767,37 +2813,6 @@ function! s:toggle(dir)
call s:initNerdTree(a:dir)
endif
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
"============================================================
"FUNCTION: s:activateNode(forceKeepWindowOpen) {{{2