telescope-repo.nvim icon indicating copy to clipboard operation
telescope-repo.nvim copied to clipboard

Change work dir

Open molleweide opened this issue 4 years ago • 10 comments

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.

molleweide avatar Nov 01 '21 17:11 molleweide

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..

molleweide avatar Nov 01 '21 18:11 molleweide

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.

molleweide avatar Nov 01 '21 18:11 molleweide

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.

molleweide avatar Nov 01 '21 18:11 molleweide

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.

molleweide avatar Nov 01 '21 18:11 molleweide

if type == 'default' then ... means if user presses <CR>, right? This is super cool. I am starting to get it.

molleweide avatar Nov 01 '21 19:11 molleweide

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.

cljoly avatar Nov 01 '21 22:11 cljoly

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

cljoly avatar Nov 01 '21 22:11 cljoly

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.

cljoly avatar Nov 01 '21 22:11 cljoly

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.

molleweide avatar Nov 02 '21 05:11 molleweide

Maybe autocommand matching on the repository would be a way: https://stackoverflow.com/a/2437878/4253785

I’ll try…

cljoly avatar Jan 14 '22 21:01 cljoly