telescope.nvim
telescope.nvim copied to clipboard
Is there any options for change the searching directory when the command `cd` is used?
Is your feature request related to a problem? Please describe.
I use cd
command but telescope still searches in the directory I opened up.
Describe the solution you'd like
I need telescope to change the base searching directory after changing the directory by cd
(and confirmed by pwd
).
Describe alternatives you've considered
I've just found the option cwd
for the find_files
and grep
, but it's tedious to modify this option for all the possible functionalities.
What do you mean cwd
command?
Telescope sets the cwd
option for Telescope to the cwd vim.loop.cwd()
if the option is not explicitly set.
So if you open nvim in a/
but you :cd b/
then do :Telescope find_files
, Telescope will use cwd=b/
.
@jamestrew I have the following mapping:
vim.keymap.set("n", "<leader>cc", ":exec 'cd' . expand('%:p:h')<CR>", { noremap = true, silent = true })
According to your comment, the find_files
subcommand should search in the new directory, but it doesn't.
I'm not able to reproduce your claim with this minimal config
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
},
config = function()
require("telescope").setup({})
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.keymap.set("n", "<leader>cc", ":exec 'cd' . expand('%:p:h')<CR>", { noremap = true, silent = true })
https://github.com/nvim-telescope/telescope.nvim/assets/66286082/4384cc6f-68c4-4630-b3d2-d7dc4900b519
I opened a file in a subdirectory and used your <leader>cc
bind to change the cwd and afterward I don't see the min.lua file in the original cwd (the parent of the new cwd).
Can you try with this minimal config?
Closing due to lack of response.