natecraddock / workspaces.nvim

a simple plugin to manage workspace directories in neovim
MIT License
309 stars 15 forks source link

Feat workspaces from dir #18

Closed ValJed closed 1 year ago

ValJed commented 1 year ago

Hello @natecraddock!

Here is my work to support directory subfolders as workspaces. There are some lint changes because i'm using stylua, I added a file config that match how the code was initially formatted to avoid big lint diffs but there are still tiny changes.

The Sync directories is just a command letting people manage it how they wish though autocmd (or by just running the command when needed). We could run it when opening nvim if needed.

When adding a directory, it stores it as directory, and registers its subfolders as workspaces. When removing a directory, it removes it as well as its subfolders from workspaces. When syncing directories, it deletes directory workspaces and recreates them to update everything.

Directories are stored at the same place than workspaces, a type column has been added to differentiate them. They have no date so no conflicts with workspaces sorted by date (they would not appear in results anyway).

I did not created any hook for directories because I didn't see any value, but it could be easily added if some people want it.

I tested this feature during my daily work and it seems working good, at least how I expected.

[update]: I improved the sync method that was just removing and recreating everything to not touch workspaces that was already existing, this way they keep their date and can be sorted.

natecraddock commented 1 year ago

Thanks for working on this, I'll review it soon!

natecraddock commented 1 year ago

Sorry I didn't have time to look at this until today, the code overall looks really great! I didn't realize how big of a feature this would be 😅 Thank you again for working on it!

I still need to do some local testing, but I think it's overall good.

I'm actually no longer using nvim as my main editor (I still use it occasionally), so this would be a pretty big maintenance burden for me by nearly doubling the line count for a feature I don't use. The only reason I still maintain this plugin is because it's so easy to maintain!

But I don't want to just throw out all of your work! And I do think this would be useful for other people. I do have a proposal for you: would you want to co-maintain this project with me? See https://github.com/natecraddock/workspaces.nvim/issues/19

I'm still willing to merge the PR if you say no, but I do think that would help me be confident that this plugin can stay up-to date with nvim :)

ValJed commented 1 year ago

No problem, thanks for reviewing it. I also thought it would be less code but here we are ahah. I just saw your post about co-maintaining this project and I guess that yes I can help you on that. 👍🏼

I know the code now and as you said given the size of the project it shouldn't be a burden for us to maintain it.

natecraddock commented 1 year ago

Alright, sorry again for the delay, this looks good and it works well in my tests.

Maybe one improvement for the future: Could hidden directories be ignored? It picked up many hidden directories in my testing and I don't expect that to be very useful.

I will add you as a contributor!