Skip to content

feat (fs_actions): add brace expansion for creating files / folders #661

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

Merged
merged 2 commits into from
Dec 26, 2022
Merged

feat (fs_actions): add brace expansion for creating files / folders #661

merged 2 commits into from
Dec 26, 2022

Conversation

pysan3
Copy link
Collaborator

@pysan3 pysan3 commented Dec 17, 2022

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.

Input Output
"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

@codecov
Copy link

codecov bot commented Dec 17, 2022

Codecov Report

Merging #661 (3f182dc) into main (73a90f6) will decrease coverage by 0.67%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #661      +/-   ##
==========================================
- Coverage   50.28%   49.60%   -0.68%     
==========================================
  Files          47       47              
  Lines        6227     6304      +77     
==========================================
- Hits         3131     3127       -4     
- Misses       3096     3177      +81     
Impacted Files Coverage Δ
lua/neo-tree/sources/filesystem/lib/fs_actions.lua 3.81% <0.00%> (-0.03%) ⬇️
lua/neo-tree/utils.lua 38.88% <0.00%> (-7.43%) ⬇️
lua/neo-tree/sources/filesystem/init.lua 64.40% <0.00%> (-1.70%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@etrnal70
Copy link

Hello, sorry for the late response. I'm daily driving it and it works great ! I'll try to find some more edge case this weekend

Copy link
Contributor

@cseickel cseickel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ready to merge this based on code and functionality, but I don't want to add to the documentation problem I already have by adding more undocumented features.

Can you please add some explanation to the help file?

You can also add it to the README if you want, or just reference the entry in the help file.

@pysan3
Copy link
Collaborator Author

pysan3 commented Dec 26, 2022

I'm daily driving it and it works great !

@etrnal70 Thanks for testing!

Can you please add some explanation to the help file?
You can also add it to the README if you want, or just reference the entry in the help file.

@cseickel I have added some documentation for the brace expansion feature in the help file and README.

@cseickel
Copy link
Contributor

Look good @pysan3, thanks!

@cseickel cseickel merged commit a9f2140 into nvim-neo-tree:main Dec 26, 2022
@pysan3 pysan3 deleted the add-brace-expansion branch December 26, 2022 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants