When I start up neovim with a directory as argument, :pwd is still set to the directory from where I ran neovim. I would expect it to have cded to the argument's directory. I wouldn't expect that to happen for file arguments, but for directories, yes. NERDTree does open with the provided directory argument.
I've tried nvim --clean some/project/path too, it gives the same result.
This question is closely related Set current working directory when opening vim
However, running :cd $PWD on VimEnter does not seem to work for me. I've put in init.lua:
local aug_cd_working_dir = vim.api.nvim_create_augroup("__cd_working_dir__", { clear = true }) vim.api.nvim_create_autocmd("VimEnter", { group = aug_cd_working_dir, command = ":cd $PWD", }) It does not change the working directory, though. That makes sense, because if neovim cd's to the current directory of the shell on startup, $PWD should be exactly the same and not produce a different result.
Can anyone solve this?
I'm running neovim v0.9.5
autochdir?autochdir@D.BenKnoble. I'm wondering why it wouldn't be intended to change directory to a path argument. What's the point of a directory as path argument otherwise?