nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Keep current PWD updated accross all buffers when changing directory in nvim-tree

ivankovnatsky opened this issue · comments

I came from NERDTree and if I miss something, please navigate me to setup this.

  1. when i do C-] the pwd in nvim-tree changes to what directory i entered
  2. i open a file from the tree, check the !pwd -- as expected
  3. go back to the tree and move up the hierarchy and choose another dir to enter
  4. go back to a file/buffer from another dir, the pwd is the same as in 2., not as in 3. as i would want

Can I configure nvim-tree in a such a way to control pwd in nvim-tree for all the buffers?

I see that if I open a buffer and open a new one, the pwd does get updated as expected. Do we need/want to sync pwd regardless of old buffer or new one?

I think that when you change directory within nvim-tree the global directory should also change. I usually first open a file, then, if I need so, I open nvim-tree to open some related files, maybe I cd into the repository root. new opened files have the "correct" cwd according to nvim-tree cwd, but the already opened one(s) retain their original cwd as local and I'd need to close and reopen. I find the way nvim-tree handles global/local cwd very frustrating and no options combination seems to work.

  • update_cwd should happen only on cd (Dirchanged global ...) not lcd
  • cd nvim-tree callback should execute :cd
  • a new lcd callback would be useful to change nvim-tree root locally, so global (other buffers') cwd is not updated
  • nvim-tree should never set the local cwd of a buffer, only manage the global cwd and its own local cwd
  • NvimTreeFindFile should always show the file, if the file is under the current root of nvim-tree then folds will be opened recursively, otherwise the local cwd of nvim-tree is changed to the one containing the file and no other buffers will be affected.
commented

fixed in #874