elihunter173/dirbuf.nvim

Feature: Expand, modify, and create nested directories

elihunter173 opened this issue · 4 comments

This is closely related to #3 but slightly different.

Sometimes I would like to be able to use Dirbuf to easily move a bunch of files from a subdirectory to my current directory. Ideally I'd like to do this by just expanding the subdirectory within my current dirbuf, deleting the leading path, and saving to move all the files I changed into my current directory.

I want it to feel like folding, where you're just "unfolding" a directory to expand it and folding it to close it. I want to be able to expand a directory, move some files to my current directory, and close the directory and have all the files I didn't move get hidden again and all the files I moved to stay. Ideally it should just work how you think it does.

For a concrete example in pseudo-dirbuf, consider you're in a directory containing only the directory foo/ which itself contains bar and baz. You open the directory and see

#1 foo/

You "unfold" foo/ and see

#1 foo/
#2 foo/bar
#3 foo/baz

Then you make the following edit

#1 foo/
#2 bar
#3 foo/baz

Then you close foo to get

#1 foo/
#2 bar

Upon saving, this should result in the syncing plan being mv 'foo/bar' 'bar'.

Open Questions

  • Can we easily hook into neovim's native folding functionality or will we have to invent are own? I'd prefer to just Neovim's folding so the user only has to configure one set of keybindings. But I fear it probably won't work because our folding actually modifies the contents of the directory. Maybe having a <Plug>(dirbuf_expand_directory) and ``(dirbuf_close_directory)` would be find.
  • How do we fold/unfold in a modified buffer? We could make this illegal but it certainly seems desirable. However, it runs into the same issue as leaving modified dirbufs, where using a potentially invalid buffer that doesn't represent the filesystem is difficult. Unfolding is easier but re-folding is difficult. I think we could just remove all lines that are textually part of that directory (i.e. starting with the/directory/). The issue there is both the buffer has to be legal (or maybe we ignore illegal lines?) and we still have to track the files in that buffer. For example, suppose someone unfolds a directory, moves a file into that directory, re-folds the directory, and then saves. Obviously they expect the file to be moved into that directory but if we don't track the files in that re-folded directory then we'll just delete that file which sucks.

First of all, thank you so much for this plugin. It's the best plugin for file navigation I've ever use (I was using dirvish for years and now your plugin is just so much better, omg I love it)

One thing I miss from Dirvish is creating multiple files at once, I think would be cool to have this feature as well. I don't know if here is the best place to suggest this, but I think its related.

index.js
ResponsiveImage.{js,test.js}

When :w this, would create the following files:

#00000001	index.js
#00000002	ResponsiveImage.js
#00000003	ResponsiveImage.test.js

or something like:

ResponsiveImage/index.js
ResponsiveImage/ResponsiveImage.{js,test.js}

:w

#00000001	ResponsiveImage/index.js
#00000002	ResponsiveImage/ResponsiveImage.js
#00000003	ResponsiveImage/ResponsiveImage.test.js

Let me know if it's better to suggest this on a separated issue instead of here. Thank you so much again!

Let me know if it's better to suggest this on a separated issue instead of here. Thank you so much again!

Could you open a separate issue? I think this is a super interesting idea!

now also with nvim column you can also have some nice folds in the left to really explain you are expanding inside a directory

You "unfold" foo/ and see
#1 foo/
#2 foo/bar
#3 foo/baz

Yes, it should be so simple to do — though I like the option of using indents rather than reiterating the parent folder.