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

Directory does not change when changing projects through Telescope #150

Open
shalawfatah opened this issue Mar 27, 2024 · 5 comments
Open

Comments

@shalawfatah
Copy link

This plugin works well and I enjoy it, great work.
I run nvim anywhere and I hit certain keys to open :Telescope projects, which opens project list,
I open a project, and run :!pwd, sure thing, the directory change has happened.
However, if I change the project again through the same keybinding (:Telescope projects), the change happens and every other plugin works with it, including telescope, but running !pwd shows that I'm still on the first opened project.
I wonder how to solve this?
This is an issue for me becuase I want to start Tmux sessions based on the current project I work on.
Best

@aburak621
Copy link

I have the same problem. After opening up a project with the telescope picker, going to my lua config with the ":e" command doesn't change the cwd. So when I try to search for a file in my config, files from the previous project comes up.

@shalawfatah
Copy link
Author

@aburak621 For me, everything works fine, like the projects load and if I do telescope, it shows the files and the folders for the correct place, the only problem is after the first time, the plugin does not cd into new projects (or at least the shell does not recognize it).

@qlibp
Copy link

qlibp commented Dec 30, 2024

I have the same problem. After opening up a project with the telescope picker, going to my lua config with the ":e" command doesn't change the cwd. So when I try to search for a file in my config, files from the previous project comes up.

same problem, any updates?

@ro0gr
Copy link

ro0gr commented Dec 30, 2024

Looks like it does not relate to the telescope plugin. I've noticed the same happens if I just open a dir via e /path/to/a/project or tabe /path/to/a/project.

So when the directory opens we end up in the on_buffer_enter handler of the project.nvim. And that's where the issue happens:

local current_dir = vim.fn.expand("%:p:h", true)
if not path.exists(current_dir) or path.is_excluded(current_dir) then
return
end

In my case I have oil.nvim as my default file explorer. So vim.fn.expand("%:p:h", true) adds the oil:// protocol to the file name. In turn it fails the file existance check cause there is no such a file like oil:///path/to/a/project.

I'm not sure about the right fix here, but it feels like project.nvim should be able to deal with the protocols somehow, maybe ignore custom protocols? IDK yet..

@ro0gr
Copy link

ro0gr commented Dec 30, 2024

FWIW, everything works fine with the default Netrw explorer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants