Utility code to create a tree

2 views
Skip to first unread message

Kannan

unread,
Sep 9, 2014, 12:55:27 AM9/9/14
to ecli...@googlegroups.com
Eric,
  In order to display tree like structure, I am relying on vim folds. But I like the NERDTree way of pressing Enter to open the folds. Also, if I need to run a command when user expands a fold, I am not sure how I can do that with normal VIM folds. Is this even possible?

  To address these 2 concerns, I was thinking of creating a simple utility script called tree.vim. It will have function to add a child node with right indentation and icon. But I want to know if you already have anything like this. Or, do you have any better suggestions? NERDTree doesn't seem to be generic to be extensible for our use case.

  Another question ... Do you know if there is a way to name an unnamed buffer? Here is the use case. I want to pre-create 2 buffers and then populate them as the debug session progresses. There will be only window though for showing them. So I want to be able to show buffer 1, and then switch to buffer 2 when user prompts for it. I can do this by using the buffer number. But when I do so, the window title shows "[No Name]". I want to give it a proper name. How can I do this?

 
-- 
Kannan

Eric Van Dewoestine

unread,
Sep 9, 2014, 8:18:12 AM9/9/14
to ecli...@googlegroups.com
On 2014-09-08 21:55:26, Kannan wrote:
> Eric,
> In order to display tree like structure, I am relying on vim folds. But I like the NERDTree way of pressing Enter to open the folds. Also, if I need to run a command when user expands a fold, I am not sure how I can do that with normal VIM folds. Is this even possible?

I don't think you can accurately detect when a user has opened a fold
since there are a lot of different ways in which a user can do so.

> To address these 2 concerns, I was thinking of creating a simple utility script called tree.vim. It will have function to add a child node with right indentation and icon. But I want to know if you already have anything like this. Or, do you have any better suggestions? NERDTree doesn't seem to be generic to be extensible for our use case.

I have an eclim#tree in org.eclim.core, but it is biased towards
working with the file system. It can be extended a bit, as seen by
eclim#project#tree, but for your use case I think something much more
simple would suffice.

> Another question ... Do you know if there is a way to name an unnamed buffer? Here is the use case. I want to pre-create 2 buffers and then populate them as the debug session progresses. There will be only window though for showing them. So I want to be able to show buffer 1, and then switch to buffer 2 when user prompts for it. I can do this by using the buffer number. But when I do so, the window title shows "[No Name]". I want to give it a proper name. How can I do this?

When you create the window/buffer, create it with a name, then set
all the necessary local options, just like eclim#util#TempWindow does.

> --
> Kannan

--
eric

Kannan

unread,
Sep 10, 2014, 1:00:11 AM9/10/14
to ecli...@googlegroups.com
I took a cursory look at tree.vim. If its not too much effort, can you briefly describe how the folding and unfolding works? It seems like you are using VIM fold methods foldopen, foldclose. But when I run the "za" command after opening ProjectTree, it says no fold. So I am wondering how you have done it.
 
-- 
Kannan


--
You received this message because you are subscribed to the Google Groups "eclim-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eclim-dev+unsub...@googlegroups.com.
To post to this group, send email to ecli...@googlegroups.com.
Visit this group at http://groups.google.com/group/eclim-dev.
For more options, visit https://groups.google.com/d/optout.

Eric Van Dewoestine

unread,
Sep 10, 2014, 11:49:33 AM9/10/14
to ecli...@googlegroups.com
On 2014-09-09 22:00:10, Kannan wrote:
> I took a cursory look at tree.vim. If its not too much effort, can you briefly describe how the folding and unfolding works? It seems like you are using VIM fold methods foldopen, foldclose. But when I run the "za" command after opening ProjectTree, it says no fold. So I am wondering how you have done it.

The project tree allows already expanded directories to be optionally
closed via a fold instead of fully collapsing it. However, the fold
isn't created until the user indicates that they want to do so using
the 'o' key binding. You can hit the '?' key when the tree is open to
view all the tree's custom key bindings.

> --
> Kannan
>
>
> On Tuesday, September 9, 2014 5:18 AM, Eric Van Dewoestine <erva...@gmail.com> wrote:
>
>
>
> On 2014-09-08 21:55:26, Kannan wrote:
> > Eric,
> > In order to display tree like structure, I am relying on vim folds. But I like the NERDTree way of pressing Enter to open the folds. Also, if I need to run a command when user expands a fold, I am not sure how I can do that with normal VIM folds. Is this even possible?
>
> I don't think you can accurately detect when a user has opened a fold
> since there are a lot of different ways in which a user can do so.
>
> > To address these 2 concerns, I was thinking of creating a simple utility script called tree.vim. It will have function to add a child node with right indentation and icon. But I want to know if you already have anything like this. Or, do you have any better suggestions? NERDTree doesn't seem to be generic to be extensible for our use case.
>
> I have an eclim#tree in org.eclim.core, but it is biased towards
> working with the file system. It can be extended a bit, as seen by
> eclim#project#tree, but for your use case I think something much more
> simple would suffice.
>
> > Another question ... Do you know if there is a way to name an unnamed buffer? Here is the use case. I want to pre-create 2 buffers and then populate them as the debug session progresses. There will be only window though for showing them. So I want to be able to show buffer 1, and then switch to buffer 2 when user prompts for it. I can do this by using the buffer number. But when I do so, the window title shows "[No Name]". I want to give it a proper name. How can I do this?
>
> When you create the window/buffer, create it with a name, then set
> all the necessary local options, just like eclim#util#TempWindow does.
>
> > --
> > Kannan
>
>
> --
> eric
>
> --
> You received this message because you are subscribed to the Google Groups "eclim-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to eclim-dev+...@googlegroups.com.
> To post to this group, send email to ecli...@googlegroups.com.
> Visit this group at http://groups.google.com/group/eclim-dev.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups "eclim-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to eclim-dev+...@googlegroups.com.
> To post to this group, send email to ecli...@googlegroups.com.
> Visit this group at http://groups.google.com/group/eclim-dev.
> For more options, visit https://groups.google.com/d/optout.

--
eric
Reply all
Reply to author
Forward
0 new messages