feat (fs_actions): add brace expansion for creating files / folders #661
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, big thanks for the nice plugin again.
This PR aims to implement the brace expansion feature just like BASH (probly POSIX compatible?) shell as suggested in #647.
The core implementation is in
require("neo-tree.utils").brace_expand(s)
which handles all expansion and return a list of strings being expanded. If no expansion is found, it returns a one-element list with the raw input.The calculation is not done by using the shell or anything and is just emulated inside lua, meaning that Windows users can also use this feature with the bash syntax.
More Testing Needed!!
I am pretty sure I was able to cover all edge cases but it would be nice if anyone could double check if I hadn't screwed up anything.
The basic syntax of bash brace expansion can be found here or here or by googling.
Here are some examples I checked myself.
"x{a..e..2}"
{ "xa", "xc", "xe" }
"file.txt{,.bak}"
{ "file.txt", "file.txt.bak" }
"./{a,b}/{00..02}.lua"
{ "./a/00.lua", "./a/01.lua", "./a/02.lua", "./b/00.lua", "./b/01.lua", "./b/02.lua" }
README
I would be very happy if you could mention this feature in the README.
I do not know any other file explorer-like plugin in vim / neovim that has this feature and I think this would be a killing feature against the other options :)
Best,
pysan3