Nvim-tree.lua: Change root to the current working directory?

Created on 27 Dec 2020  路  5Comments  路  Source: kyazdani42/nvim-tree.lua

Sometimes I got carried away using cd (<C-]>) mapping to traverse among directories and at some point I want to cd into the directory where I was before which is my root directory. So, is there any way to achieve this via a mapping or a function call? vim's :cd command also raises this problem because it effectively changes the current working directory.

Most helpful comment

hum i had to cancel this commit because it introduced bugs. The startup of the tree is quite old and not really easy to modify. I think i'll do the rewrite bit by bit, it'll be easier this way

All 5 comments

i don't think i actually change the vim directory when doing <C-]>. root path handling is not well synced with neovim, i want to fix this in the rewrite but lately i really have not much time to fix this.
And maybe a <C-o> based function would help a little indeed, i find mysef needing this too sometimes.

i don't think i actually change the vim directory when doing <C-]>.

I mean, consider this, you're currently at ~/some-folder/ and LuaTree open, if you go and type :cd ~/other-project you have to manually go that folder via LuaTree to show files/folders there.

defx provides a workaround for this:

nnoremap <buffer><silent><expr> gh defx#do_action('cd', getcwd())

oh yes i didn't bind the change_dir to DirChanged, now fixed in master.

Perfect! Thanks a lot.

hum i had to cancel this commit because it introduced bugs. The startup of the tree is quite old and not really easy to modify. I think i'll do the rewrite bit by bit, it'll be easier this way

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DimitrisMilonopoulos picture DimitrisMilonopoulos  路  5Comments

afonsocarlos picture afonsocarlos  路  3Comments

seblj picture seblj  路  6Comments

gmr458 picture gmr458  路  5Comments

CantoroMC picture CantoroMC  路  7Comments