nvim-tree.lua icon indicating copy to clipboard operation
nvim-tree.lua copied to clipboard

Allow creating directories when renaming files (behavior like create file)

Open SimonEggert opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe. I recently discovered that it is currently not possible to rename a file and move it to another folder via nvim-tree's rename operation. I had hoped it worked the way creating files works where you can use foo/bar to create a new folder foo with a bar file inside it. Rename just creates a file called foo/bar instead.

Describe the solution you'd like When renaming a file ./bar I want to be able to edit the "file name" to ./foo/bar and have the file be nested in the created folder.

Describe alternatives you've considered A colleague mentioned that VSCode had this feature when renaming files.

Additional context The issue is not a big deal but I expected the two operations "rename" and "create" to be similar in behavior. Could this be done in a similar way in the code? I think the folder creation happens in this loop.

Thanks for considering and keep up the great work! 🙂

SimonEggert avatar Jan 15 '24 07:01 SimonEggert

This could be added to any similar operation we find.

alex-courtis avatar Jan 16 '24 04:01 alex-courtis

This could be implemented, but it also produces a problem of typos being enhanced

If a user wants to rename a file and make it go into a long nested directory. If a typo is found in the root level directory of the new directory, then it shall result in the creation of many unnecessary nested directories and the initial file/folder being moved into this new directory tree. Creating and then moving files does not create this problem.

mohamedarish avatar Jan 28 '24 17:01 mohamedarish

If a typo is found in the root level directory of the new directory, then it shall result in the creation of many unnecessary nested directories and the initial file/folder being moved into this new directory tree.

Indeed. We can't really warn as it's not possible to determine the user's desired behaviour.

We can use completion = "dir" to assist the user when using existing directories.

alex-courtis avatar Jan 28 '24 23:01 alex-courtis