telescope-repo.nvim
telescope-repo.nvim copied to clipboard
Change work dir
This is on of the features that I think would be really nice:
To have the ability to change work dir so that I can use eg. lazygit.nvim in the new location to check some stuff and then jump back.
I guess, on the other hand that this could also just be a regular vimrc function that I'd create myself to update the cwd.
actually it turns out lazygit.nvim opens correctly for telescope-repo so that part can be ignored BUT regular telescope searching does not operatate on the jumped-to repo..
I tried this command cd %:p:h and it works for setting the active file to cwd
which then makes telescope search in the new dir BUT it should be modied to set
to the git dir one is jumping to. Then you could have a custom mapping to
jump-to-and-change-dir with telescope-repo. That would be really nice
actually. I believe that would make it fully feel like you have changed project
and not just open up a new file from another dir.
I am asking also on discourse to see if it is possible to make it so that the whole nvim instance moves to the new dir
so that you can :suspend out into the new pwd.
I found this. (you might already know this but since you wrote this plugin)
"<cmd>cd %:h | cd `git rev-parse --show-toplevel`<CR><cmd>pwd<CR>"
This sets the pwd to git root dir from whatever subdir. So I think that it would be a good idea to add the ability to run this command when jumping with t-repo.
if type == 'default' then ... means if user presses <CR>, right?
This is super cool. I am starting to get it.
I found this. (you might already know this but since you wrote this plugin)
I actually use https://github.com/airblade/vim-rooter, so opening the file changes to the directory for the current buffer (using lcd) as well. That’s a great find though. I’m a little surprise by the final <cmd>pwd<CR>, I would have thought it would be unnecessary but whatever.
So I think that it would be a good idea to add the ability to run this command when jumping with t-repo.
I agree, I guess the best way to provide this flexibility is with a function in the setup function.
if type == 'default' then ... means if user presses <CR>, right?
Yes :)
This shows you some other options: https://github.com/nvim-telescope/telescope-ghq.nvim/blob/1d26edf00d0efb969f0693e6134dae7d06e23f57/lua/telescope/_extensions/ghq_builtin.lua#L118
Feel free to open a PR if you want to discuss your code to change cwd after the jump btw. In principle, I think that would make a good feature, even though I’m not currently using it. So I would be theoretically willing to merge such a PR.
ive never used ghq but it seems pretty badass!!! I'll check out rooter also. it looks like a good tiny plugin also for learning plug dev.
Feel free to open a PR if you want to discuss your code to change cwd after the jump btw. In principle, I think that would make a good feature, even though I’m not currently using it. So I would be theoretically willing to merge such a PR.
Yeah maybe I'll try to add this.
Maybe autocommand matching on the repository would be a way: https://stackoverflow.com/a/2437878/4253785
I’ll try…