Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make bookmarks remember state of tree #248

Closed
qstrahl opened this issue Apr 9, 2013 · 35 comments
Closed

Make bookmarks remember state of tree #248

qstrahl opened this issue Apr 9, 2013 · 35 comments
Assignees

Comments

@qstrahl
Copy link

qstrahl commented Apr 9, 2013

I often do :NERDTree <bookmark> then manually open the various subdirectories I want. It would be super convenient if NERDTree remembered the open/closed state of the tree when I create a bookmark so I don't have to do it myself.

@nomasprime
Copy link

+1

6 similar comments
@erichua23
Copy link

+1

@djdarkbeat
Copy link

+1

@Yavor-Ivanov
Copy link

+1

@jubalh
Copy link

jubalh commented Feb 19, 2015

+1

@gustavklopp
Copy link

+1

@protist
Copy link

protist commented Mar 19, 2015

+1

@hemantmits
Copy link

+1
sad so see this must have feature is pending from almost two year :(.

@alexandnpu
Copy link

+1

2 similar comments
@igormoreno
Copy link

+1

@bitzip
Copy link

bitzip commented May 16, 2015

+1

@scrooloose
Copy link
Collaborator

Gentlemen, I hear you and will be implementing this shortly.

@ghost
Copy link

ghost commented Jun 5, 2015

You all can use this plugin: https://github.com/jistr/vim-nerdtree-tabs
It works, but also "blinks" on my configuration, but you should try to use it!

UPD: probably it should correctly works with buffers, not tabs.

@JohnTortugo
Copy link

+1

1 similar comment
@brodieG
Copy link

brodieG commented Oct 20, 2015

+1

@scrooloose
Copy link
Collaborator

Hey all, I have been looking into this and have taken a stab at it here: https://gist.github.com/scrooloose/741b04b0a6dc8c69d043

Things to note:

  1. I have called the idea "projects" instead of "bookmarks" since that is the direction they are heading in.
  2. The concept is implemented as a nerdtree plugin at the moment. When the code/functionality stabilizes I will either add it to the core, or leave it as a plugin and hand it off to someone.
  3. The interface is just :commands at the moment, but this may get more snazzy later according to feedback.
  4. Currently, the only functionality that projects offer over bookmarks is remembering the state of the tree. I have other ideas and feature requests that may be implemented though.

Thoughts/feedback welcome.

@scrooloose
Copy link
Collaborator

Do you have the latest version of nerdtree? (I should have mentioned that)

@ghost
Copy link

ghost commented Nov 20, 2015

Do you have the latest version of nerdtree? (I should have mentioned that)

Sorry, I've just updated and it only requires to manually create the "touch ~/.NERDTreeProjects"

@ghost
Copy link

ghost commented Nov 20, 2015

I can offer this use case (I will add it by myself, but not now). It will give you dynamicaly synchronization between tabs (I hope):

  1. Add to .vimrc
autocmd BufNewFile,BufRead /home/user/projects/project1/* let project_name=project1
  1. Add to NERDTree this functionality:

on_NERDTree_open or on_[tab/buffer/NERDTree]_focus_in:

if (project_name) then NERDTreeProjectLoad project_name

on_NERDTree_close or on_[tab/buffer/NERDTree]_focus_out:

if (project_name)
then NERDTreeProjectSave project_name

And thank you for you job! <3

@ghost
Copy link

ghost commented Nov 20, 2015

Also now it has a bug with autocomplete of project names:

What I do:

:NERDTreeProjectLoad t<tab>

What I get (but it works!):

:NERDTreeProjectLoad test
test  test  test
:NERDTreeProjectLoad test

@scrooloose
Copy link
Collaborator

OK, I have fixed 2 bugs (see latest gist):

  1. The bug when .NERDTreeProjects didnt exist
  2. The naming bug you mention above. In your example above there are actually 3 test projects. Instead of updating the test project, the code was creating new project (due to the bug).

RE your idea above on_NERDTree_close or on_[tab/buffer/NERDTree]_focus_out: <save project>: This effectively already happens. If you use NERDTreeProjectLoad and then unload the nerdtree buffer (by closing vim, or :bunload etc) then the project you have loaded will be saved again.

RE automatically loading projects when you enter the root (or by some similar condition): This might be a good idea. Unfortunately I have been drinking and can't think hard enough now :D

@scrooloose
Copy link
Collaborator

If I understand you correctly, you can already use NERDTreeMirror to accomplish this. If you want one tree viewed in many tabs, this is what NERDTreeMirror is for. You will be viewing the same nerdtree buffer loaded in different windows.

Have I understood you correctly?

@scrooloose
Copy link
Collaborator

Hey all, FYI here is the latest version of the plugin above: https://github.com/scrooloose/nerdtree-project-plugin.

Its still a WIP really - but I have been using it for a couple of weeks. Would appreciate any feedback and ideas. If all goes well, I plan to merge this into the main repo and replace bookmarks.

@alessioalex
Copy link

@scrooloose I got an error with b:NERDTree does not exist when trying to save a project, even though I do have the latest version of NERDTree installed. Does that have to do with how bundle loads up the plugins, maybe the order..? Thanks

@rococode
Copy link

rococode commented Jan 8, 2018

Has this been added to NERDTree already? I'm not sure if I'm just missing something or if it's not quite ready yet.

@PhilRunninger
Copy link
Member

No, its still a separate project, and no attention has been given to it in the last couple of years. It needs some feedback and probably some work before it will be included with NERDTree, especially if it's purpose is to replace bookmarks.

@lifecrisis, tagging you for future development consideration.

@PhilRunninger
Copy link
Member

You can install it like you do any other plugin, and it should be ready for testing. (I haven't tried this myself, so your mileage may vary.)

@rococode
Copy link

rococode commented Jan 9, 2018

Okay, thanks for the info! I will probably give it a try. The main functionality, for me at least, is not so much the project-like functionality but simply just remembering which folder nodes have been opened - if there is a simple way to just keep track of folder states (expanded or collapsed) persisting through vim restarts that would be equally welcome to me.

@jackson-dean
Copy link

+1. I would like this too.

@MrMebelMan
Copy link

+1, yes, please :(

@carousel
Copy link

+1 me too

@gavinlynch
Copy link

+1 another vote, would double the usefulness of this plugin for my purposes

@wellyal
Copy link

wellyal commented Nov 8, 2018

any updates on this? Seems an old request

@PhilRunninger
Copy link
Member

Pull Request #929 should make the nerdtree-project-plugin work properly again.

@PhilRunninger
Copy link
Member

PhilRunninger commented Dec 12, 2018

As of a4dd4e1, @scrooloose 's project plugin will work once again. All you need to do is update your NERDTree and install the https://github.com/scrooloose/nerdtree-project-plugin.git plugin just like you do any other Vim plugin. Then use the commands defined in it to manage your projects:

  • Create a project from the current nerdtree with
    :NERDTreeProjectSave <name>
  • Load a project with
    :NERDTreeProjectLoad <name>
  • Load a project from the current CWD
    :NERDTreeProjectLoadFromCWD
  • Delete a project with
    :NERDTreeProjectRm <name>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests