Neovim cwd changing when opening a file

I am having an issue that when i open a file (either through neotree or telescope) my working directory changes from what i was in to my home directory and neotree and telescope display all the files in my home directory aswell. how do i fix this?

Its not standard behaviour so whatever is happening its part of your configuration / installed plugins.

Hi,

Look for something like this:

                          'autochdir' 'acd' 'noautochdir' 'noacd'
  'autochdir' 'acd'       boolean (default off)
                          global
          When on, Vim will change the current working directory whenever you
          open a file, switch buffers, delete a buffer or open/close a window.
          It will change to the directory containing the file which was opened
          or selected.  When a buffer has no name it also has no directory, thus
          the current directory won't change when navigating to it.
          Note: When this option is on some plugins may not work.

You can check i with: :set autochdir?

I had the same issue. On my end, it was caused by calling vim.cmd("silent! mkview") on BufWinLeave and calling vim.cmd("silent! loadview") on BufWinEnter. Some views contain a line lcd ~ which sets the the directory for the current window when that specific file is loaded into a buffer. Removing the lcd lines from view files fixed the issue for me.

In my case, the view files are located in ~/.local/state/nvim/view.