4

I am using vim 7.3, the NERDTree 4.1 plugin and VCSCommand version 1.99.42.

To commit a directory in VCSCommand you need have the directory buffer open (it's the same with all commands on directories), however whenever I try to open a directory buffer with the NERD Tree plugin installed it refers to the buffer as Nerd_tree_* and not the directory name which I need to make a relevant commit.

How do I prevent this from happening? How do I open a standard directory buffer with NERD tree installed? How do I turn NERD Tree off periodically to perform the command?

Note: I am aware of this stackoverflow question where the dev says he disabled the NERD Tree plugin because he was using Command-T as a file explorer, but I would like to continue to use NERD Tree, there is no mention of disabling NERD Tree in the help.

Community
  • 1
  • 1
rogermushroom
  • 5,486
  • 4
  • 42
  • 68

3 Answers3

3

There is a solution but it required some coding.

You need to update netrw and NERDTree plugins with kind of enable/disable interface.

I create this gist for you with two files that have to be changed. The files itself are also attached.

  • netrwPlugin.vim resides in vim installation directory under.
  • NERD_tree shall be in your ~/.vim/plugin directory (unless you use pathogen).

With this change you can use

call DisableNERDTree()

to disable NERD and make vim use netrw (it's original file manage) and

call HijackNERTW()

To restore NERDTree again.

Of course you alsoneed do call the functions before and after related VCS command either by using your own wrapper functions or modifying VCS itself.

Hope this helped.

Edit 2011-03-17:

Calling those functions manually works well. I.e:

  1. you call call DisableNERDTree()
  2. then you edit the folder
  3. then you use VCS command
  4. and finally call HijackNERTW()

I updated the patch so those functions could be used in automated way. DisableNERDTree() now changes directory to the one opened. E.g.:

fun! NewVCSadd()
   call DisableNERDTree()
   :e . "start netrw
   :VCSAdd<CR>
   call HijackNERTW()
   :e . "start NERDTree
endfunction
devemouse
  • 5,302
  • 5
  • 22
  • 22
  • So as an example I could create a command in my .vimrc like this - command :newVCSCommand DisableNERDTree() | VCSAdd | HijackNERTW()? – rogermushroom Mar 16 '11 at 14:38
  • Also could you give a really simple of example of how I might include in a function, at the moment I have this: fun! Add() call DisableNERDTree() s exec 'VCSCommit' endfunction but the s which is supposed to open the dir using netrw doesn't seem to be working – rogermushroom Mar 17 '11 at 00:05
1

I use a simple combination: When I'm planning for recursive Diff or recursive Commit - I run command :Hexplore, which opens netrw in split-window, navigate to necessary directory and run :VCSCommit or :VCSDiff. That's a simple fix without additional changes or complex manipulations :).

Ardens
  • 11
  • 1
0

Devemouse changes and function example allowed me to construct the following 2 wrapper functions, which perform VCS command and then returns vim to it's previous state

" ------------------ Functions ------------------------------

" Wrapper function for VCSAdd to enable it to work with Nerd tree
fun! NewVCSAdd()
   call DisableNERDTree()
   edit . "start netrw
   execute 'VCSAdd'
   call HijackNERTW()
   quit " quit add windows 
   quit " quit out of netrw-NerdTree window (we want it pure)
   NERDTree . 
endfunction

" Wrapper function for VCSCommit to enable it to work with Nerd tree
fun! NewVCSCommit(comment)
   call DisableNERDTree()
   edit . "start netrw
   execute 'VCSCommit ' . a:comment
   call HijackNERTW()
   quit " quit commit windows 
   quit " quit out of netrw-NerdTree window (we want it pure)
   NERDTree .
endfunction
rogermushroom
  • 5,486
  • 4
  • 42
  • 68