Skip to content
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

git submodules and git project within git projects #5

Closed
molleweide opened this issue Oct 29, 2021 · 18 comments
Closed

git submodules and git project within git projects #5

molleweide opened this issue Oct 29, 2021 · 18 comments
Labels
question Further information is requested

Comments

@molleweide
Copy link
Contributor

molleweide commented Oct 29, 2021

Hi there,

I post here just to document that a git repo within a git repo is not found, and also submodules are not found.

Scenario:

I use a bash framework within which I have my own user repo which is ignored in the parent framework repo.
Also within my user repo I have subdirs such as doom-nvim. So this would kind of be three levels of git projects

bash-framework
    user-repo
        submodule doom-nvim

and ideally it'd be nice if each of these showed up in telescope-repo. I might take a look at this myself
later also.

@molleweide
Copy link
Contributor Author

also, another newbie question:

If I load telescope-repo in my telescope config, does this mean that all the repos are cached so that when I open repo list they all should show up at the same time?

@cljoly
Copy link
Owner

cljoly commented Oct 30, 2021

The subrepo case is interesting! Maybe there is something we can do, I'll think a bit more about it.

does this mean that all the repos are cached so that when I open repo list they all should show up at the same time?

No, the repo list is built on each call of the extension (doing it in nvim config would slow down each start). We do benefit from the os cache however so subsequent calls to repo list are much faster. The main reason for this is that it's much easier to have an up to date list by using the os cache.

Furthermore, there is #3 to consider using a different cache for when rebuilding everything is too slow, at the expense of a possibly outdated list.

@molleweide
Copy link
Contributor Author

Cool! It will be exciting to see what ideas you come up with.
I am just learning how to get local plugins working with nvim myself so that I also can help out some.

@cljoly
Copy link
Owner

cljoly commented Oct 31, 2021

I think I was able to reproduce your problem. In your example, if user-repo is gitignored, then it is not found by telescope-repo.nvim. However, you get the behavior you expect if user-repo is not in the .gitignore file, i.e. bash-framework, bash-framework/user-repo and bash-framework/user-repo/doom-nvim.

I assume you have good reasons not to remove user-repo from your .gitignore. So I’ve added a feature to make fd ignore the .gitignores. I’ve tried to document an example in the PR: https://github.com/cljoly/telescope-repo.nvim/pull/7/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R127. Please let me know if the documentation is unclear, for instance by letting a comment in the PR!

@cljoly
Copy link
Owner

cljoly commented Oct 31, 2021

I am just learning how to get local plugins working with nvim myself so that I also can help out some.

Thanks!
You can use the following lua code (it’s what I have in my config):

vim.opt.runtimepath:append("~/ghq/github.com/cljoly/telescope-repo.nvim")

assuming you have cloned the repo in ~/ghq/github.com/cljoly/telescope-repo.nvim. You may also want to checkout the branch of the PR to test the new feature I’ve described above.

Don’t hesitate to let me know if you need further help!

@molleweide
Copy link
Contributor Author

Thanks for your replies! I will try to get things running and get back to you with more thoughts and reflections.

@molleweide
Copy link
Contributor Author

One thing I realize is that it could be dangerous to ignore the ignorefile, right? I am imagining that this would
add, eg. nodes_modules and other stuff to the search which is not good.

@cljoly
Copy link
Owner

cljoly commented Oct 31, 2021

Right, I did not think of the node_modules case. --exclude node_modules could be passed to fd, but there are many other things that would need to be excluded like this. Ideally, we would have a way to just include user-repo (from your example). Yet --ignore-file is too low priority and -E !user-repo doesn’t work.

The only option left that I can see is to add a folder argument to fd, like so:

fd [options] [patterns] dir1 ignored-dir1 ignored-dir2

where ignored-dir1 would be user-repo in your example. In your current setup, do you have many user-repo files? Would it be too much maintenance to list them all in the argument to the command?

@molleweide
Copy link
Contributor Author

Hey I realize also that I could rearrange my stuff so that it works better because it feels like
this would otherwise be too much work for just my tiny use case. So you can ignore this I think for now.
I have to think more about if my dir structure makes sense. I might put user-repo under xdg config home.

Another thing that I noted now is that my repos that are symlinked into $HOME/.config are
not recognized. And some of these symlinks are git submodules from within my user-repo.
user-repo is kind of like my dotiles dir. So I think that it still would make sense to add submodules
to the search, but leave repos within repos for now.

Also, I noticed that the plugin ~/plugins/lazygit.nvim does not show up but I am wondering if this has
something to do with telescope ignoring dirs containing the string *git* because I have
noticed this in other places with telescope as well.

@cljoly
Copy link
Owner

cljoly commented Oct 31, 2021

Hey I realize also that I could rearrange my stuff so that it works better because it feels like
this would otherwise be too much work for just my tiny use case

I’ve tried to solve this use case in a generic manner :) I’ll thus probably still merge the custom options for fd PR, plus it’s something I’ve meant to do for some time.

So I think that it still would make sense to add submodules
to the search

I believe submodules are properly recognized already, at least in the tests I’ve performed locally with the current master branch. So in what you observe, there is probably some other factor at play, maybe the symlinks you mentioned. From fd’s manual:

       -L, --follow
              By  default,  fd does not descend into symlinked directories. Using this flag, symbolic links are also
              traversed.

From what I could test locally, this should work (from the fd-opts branch):

:lua require'telescope'.extensions.repo.list{fd_opts={'-L'}}

the plugin ~/plugins/lazygit.nvim does not show up

This might be related to an unfortunate interaction with some other part of your config. Locally, when I

~> mkdir -p ~/plugins/
~> git init ~/plugins/lazygit.nvim
Initialized empty Git repository in /home/cj/plugins/lazygit.nvim/.git/

this empty lazygit repository is found by telescope-repo.nvim.

Finally, if you are not aware already, do you know chezmoi for configuration management? You might find it suitable for your use cases. If not, no worries, one size doesn’t fit all :)

@molleweide
Copy link
Contributor Author

hmm based on this I have to do more research and find out why mines are't recognized.

Cool, I've heard of chez moi. Currently I am using a project called dorothy. But I'll check it out.

@cljoly
Copy link
Owner

cljoly commented Oct 31, 2021

hmm based on this I have to do more research and find out why mines are't recognized.

Sure, I would be curious to know why it did not work / if the commands I’ve suggested work.

I’ll check dorothy out, thanks for sharing!

@molleweide
Copy link
Contributor Author

Nice, I don't know if dorothy can be called a dotfiles management system but it is more like
a nice parent repo with lots of very nice prewritten bash functions and goodies.

@molleweide
Copy link
Contributor Author

okay so moving user dots out of dorothy makes it searcheable, BUT lazygit is not found still.

These are my telescope configs:

file_ignore_patterns = { ".git", "node_modules", "__pycache__" },

and this shouldn't ignore git but only .git, right?

@molleweide
Copy link
Contributor Author

Dude, I tried removing ".git". pattern and now it shows. Is this a bug do you think??

@molleweide
Copy link
Contributor Author

I filed a bug report because files containing the sting git only shows up if they start fith git string and are located at same path as I ran nvim command.

@molleweide
Copy link
Contributor Author

It turns out the corect ignore pattern is "%.git"...

@cljoly
Copy link
Owner

cljoly commented Nov 1, 2021

okay so moving user dots out of dorothy makes it searcheable

So the -L trick did not work?

@cljoly cljoly added the question Further information is requested label Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants