telescope-project.nvim
telescope-project.nvim copied to clipboard
Feature Request: Equivalent of `:lcd path_to_project` and "no(l)cd" (improve documentation)
- The behavior of how
cwdis changed is underspecified. Neovim offers 1.:cdand 2.:lcdto change paths. But one could also think of 3. not changing the path for only opening the file [ie to compare stuff]. - I think even changing the default to
:lcdwould be more optimal, to run things in the script or:e pathtofileon the correct project folder
use cases
- My simple project for using associated script folders I am frequently looking and copy your code to modify it. Having
PATHcluttered makes this annoying for quick lookups. - My project intends to make script running usable from the git root of the project. Its very unnatural to have
cwdnot being set to the project git root, when one wants to run quick scripts or modifies stuff etc. - In future I want to make PATH navigation possible (in neovim and shell associated to project) to get restricted to a local project scope. Having correct
cwdset is a basic building block for that.
I have also some other remarks on the structure of the project to make re-usage simpler, but this is not imminent. Thanks for the plugin and let me know what you think on this.
yeah, I think it's better to add option to choose between cd, lcd, tcd and no cd
I don't like that plugin cd whole nvim to selected folder
I also wanted something like lcd but for a buffer scope instead of a window scope. Just an idea:
local M = {}
local history = {}
vim.api.nvim_exec(
[[
augroup TrackCWD
autocmd!
autocmd BufEnter * lua require"thisfilepath".on_enter()
autocmd BufLeave * lua require"thisfilepath".on_leave()
augroup end
]],
false
)
function M.on_enter()
local buf = vim.api.nvim_get_current_buf()
if not vim.api.nvim_buf_get_option(buf, "buflisted") then
return
end
local last_path = history[buf]
if last_path then
vim.fn.execute("cd " .. last_path, "silent")
-- require("nvim-tree").change_dir(last_path) --update nvimtree
end
end
function M.on_leave()
local buf = vim.api.nvim_get_current_buf()
if not vim.api.nvim_buf_get_option(buf, "buflisted") then
return
end
history[buf] = vim.fn.getcwd(-1, -1)
end
return M
buffer scope instead of a window scope
Please try to explain your use case in harpoon, since the plugin is more tailored to buffer navigation. Project stuff is more logical to do inside windows to have a static reference point (by setting the cwd).
Ideally even fixing the buffers "to have a link" to the window path, so that cwd is set accordingly upon switching to them.
+1 for having an option to choose between :cd and :lcd, I like to have one tab per project and using cd when switching to another project in a new tab messes up the paths in all other project tabs.
still no updates to this issue? seems like it's time to learn lua
changing this line here to lcd works for me for the time being
Check MR #103 which resolves this at least for me
Any progress on this? Does the suggested PR solve the problem? It's really annoying that it changes the global cwd and not just the buffer cwd or tab cwd if you choose to open the file in a new tab. Also could we stop the behavior by just selecting the project to also change cwd. Many times I may cancel the command but cwd is already changed. Preferably it could change after selecting a file to open?
Thanks @l4zygreed for resolving this