agoodshort / telescope-git-submodules.nvim

Telescope extension for git submodules
MIT License
16 stars 2 forks source link

Feature suggestion: is it possible to make it useful for non-submodule repos? #3

Open patricorgi opened 9 months ago

patricorgi commented 9 months ago

My workspace is a bit untypical. The root directory is not a git repo, but provides commands to automate git clone and make several interdependent projects with specified branch name of the repo of these projects.

For instance, when Imake ProjectC, which depends on ProjectA and ProjectB, the root repo will perform git clone and set proper CMAKE_PREFIX_PATH to compile ProjectC. However, the cloned ProjectA/B/C are not really submodules to the root repo.

At the moment, this plugins does not work in my workspace as it relies on .git and .gitmodules if I understand it correctly. I'm wondering if it's possible to make it also work for my case?

agoodshort commented 9 months ago

You are correct, at the moment the plugin only relies on .git and .gitmodules of the current working directory.

In your scenario we'd be looking to implement something similar to this stackoverflow question.

I suggest the below:

find_subdirectories = {
    enabled = false,
    depth = 1
}

Will this cover your use case? Do you see anything else to add?

patricorgi commented 9 months ago

Totally. Thanks for replying and considering my suggestion. I actually forked your repo and make it independent of .git and .gitmodules in the root directory. It simply replaces the git submodule for each with a short bash snippet to print the exact same content. This may not be the most elegant way, so feel free to suggest anything else. I'm new to the lua language, so I didn't make it to support options of different settings.

Sorry, I also removed the previewer part to make the telescope appear faster, because what I really want is to display the repos and their branches, and be able to open any of them in lazygit as fast as possible. Speaking of speed, my another suggestion, if it is not something too difficult, would be to make it async, so I don't have to wait for the entire list to be created until the telescope prompt can be displayed.

agoodshort commented 9 months ago

Wow, this is great feedback and suggestions. Thank yo very much.

I will slowly start working on the suggested changes in my comment above. Shouldn't take too long, but I don't have too much free time these days.


Sorry, I also removed the previewer part to make the telescope appear faster, because what I really want is to display the repos and their branches, and be able to open any of them in lazygit as fast as possible.

This makes a lot of sense. I created a branch to add a config parameter to enable/disable the previewer. I will test it tomorrow on my work machine.

Edit: This is now tested an added to main


Speaking of speed, my another suggestion, if it is not something too difficult, would be to make it async, so I don't have to wait for the entire list to be created until the telescope prompt can be displayed.

I like the idea, I also think the logic I wrote could be a little bit more efficient (e.g. the crazy if elseif statement) to generate the submodule list.

agoodshort commented 8 months ago

I created a new branch and PR #5 for this feature, @patricorgi would you mind testing/reviewing it?

patricorgi commented 8 months ago

Hi, many thanks for implementing this! I saw your message a week ago, but I have been too busy recently to test it. Hopefully I can find sometime this week...