mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
Support tab-specific CWDs (#1032)
* Change CWD when switching tabs to the tab's NERDTree root. * Remove commented-out code. * List the new possible value for NERDTreeChDirMode in doc. * Add new option to select between `:cd` and `:tcd`. * Document the new NERDTreeUseTCD option. * Update version number in change log.
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
|
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
#### 6.2
|
||||||
|
- **.0**: Support tab-specific CWDs (PhilRunninger) [#1032](https://github.com/scrooloose/nerdtree/pull/1032)
|
||||||
#### 6.1
|
#### 6.1
|
||||||
- **.4**: Add VIM built-in package management to read me file. (pesarkhobeee) [#1049](https://github.com/scrooloose/nerdtree/pull/1049)
|
- **.4**: Add VIM built-in package management to read me file. (pesarkhobeee) [#1049](https://github.com/scrooloose/nerdtree/pull/1049)
|
||||||
- **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/scrooloose/nerdtree/pull/1048)
|
- **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/scrooloose/nerdtree/pull/1048)
|
||||||
|
|||||||
@@ -849,9 +849,17 @@ above nodes would then be sorted like this: >
|
|||||||
z110.txt
|
z110.txt
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeChDirMode*
|
*NERDTreeUseTCD*
|
||||||
|
Values: 0 or 1.
|
||||||
|
Default: 0.
|
||||||
|
|
||||||
Values: 0, 1 or 2.
|
By default, NERDTree will use the `:cd` command to change the current working
|
||||||
|
directory. If this setting is turned on, and the `:tcd` command is available, it
|
||||||
|
will be used instead.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*NERDTreeChDirMode*
|
||||||
|
Values: 0, 1, 2, or 3.
|
||||||
Default: 0.
|
Default: 0.
|
||||||
|
|
||||||
Use this setting to tell the script when (if at all) to change the current
|
Use this setting to tell the script when (if at all) to change the current
|
||||||
@@ -871,6 +879,9 @@ the CWD is changed whenever the tree root is changed. For example, if the CWD
|
|||||||
is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new
|
is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new
|
||||||
root then the CWD will become /home/marty/foobar/baz.
|
root then the CWD will become /home/marty/foobar/baz.
|
||||||
|
|
||||||
|
If the set to 3, then it behaves the same as if set to 2, and the CWD is
|
||||||
|
changed whenever changing tabs to whatever the tree root is on that tab.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeHighlightCursorline*
|
*NERDTreeHighlightCursorline*
|
||||||
Values: 0 or 1.
|
Values: 0 or 1.
|
||||||
@@ -980,7 +991,6 @@ then (to single click activate it) you must click somewhere in
|
|||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeQuitOnOpen*
|
*NERDTreeQuitOnOpen*
|
||||||
|
|
||||||
Values: 0,1,2 or 3.
|
Values: 0,1,2 or 3.
|
||||||
Default: 0
|
Default: 0
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function! s:NERDTree.changeRoot(node)
|
|||||||
call self.root.open()
|
call self.root.open()
|
||||||
|
|
||||||
"change dir to the dir of the new root if instructed to
|
"change dir to the dir of the new root if instructed to
|
||||||
if g:NERDTreeChDirMode ==# 2
|
if g:NERDTreeChDirMode >= 2
|
||||||
call self.root.path.changeToDir()
|
call self.root.path.changeToDir()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,13 @@ function! s:Path.changeToDir()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
try
|
try
|
||||||
|
if g:NERDTreeUseTCD && exists(":tcd") == 2
|
||||||
|
execute "tcd " . dir
|
||||||
|
call nerdtree#echo("Tab's CWD is now: " . getcwd())
|
||||||
|
else
|
||||||
execute "cd " . dir
|
execute "cd " . dir
|
||||||
call nerdtree#echo("CWD is now: " . getcwd())
|
call nerdtree#echo("CWD is now: " . getcwd())
|
||||||
|
endif
|
||||||
catch
|
catch
|
||||||
throw "NERDTree.PathChangeError: cannot change CWD to " . dir
|
throw "NERDTree.PathChangeError: cannot change CWD to " . dir
|
||||||
endtry
|
endtry
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
|
|||||||
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
|
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
|
||||||
call s:initVariable("g:NERDTreeNaturalSort", 0)
|
call s:initVariable("g:NERDTreeNaturalSort", 0)
|
||||||
call s:initVariable("g:NERDTreeSortHiddenFirst", 1)
|
call s:initVariable("g:NERDTreeSortHiddenFirst", 1)
|
||||||
|
call s:initVariable("g:NERDTreeUseTCD", 0)
|
||||||
call s:initVariable("g:NERDTreeChDirMode", 0)
|
call s:initVariable("g:NERDTreeChDirMode", 0)
|
||||||
call s:initVariable("g:NERDTreeCreatePrefix", "silent")
|
call s:initVariable("g:NERDTreeCreatePrefix", "silent")
|
||||||
call s:initVariable("g:NERDTreeMinimalUI", 0)
|
call s:initVariable("g:NERDTreeMinimalUI", 0)
|
||||||
@@ -183,6 +184,12 @@ if g:NERDTreeHijackNetrw
|
|||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if g:NERDTreeChDirMode == 3
|
||||||
|
augroup NERDTreeChDirOnTabSwitch
|
||||||
|
autocmd TabEnter * if g:NERDTree.ExistsForTab()|call g:NERDTree.ForCurrentTab().getRoot().path.changeToDir()|endif
|
||||||
|
augroup END
|
||||||
|
endif
|
||||||
|
|
||||||
" SECTION: Public API {{{1
|
" SECTION: Public API {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
function! NERDTreeAddMenuItem(options)
|
function! NERDTreeAddMenuItem(options)
|
||||||
|
|||||||
Reference in New Issue
Block a user