nvim-tree.lua icon indicating copy to clipboard operation
nvim-tree.lua copied to clipboard

Shortcut to focus cwd after nagivating away

Open jeanlucthumm opened this issue 2 years ago • 5 comments

Describe the solution you'd like If you navigate away from the current working directory using something like -, it would be nice to have a shortcut that roots the tree back to the cwd

This is also useful if you've change the cwd via :cd ... and would like the tree to focus the new directory

Describe alternatives you've considered Couldn't find any issues describing this, and I didn't see anything in the help menu

jeanlucthumm avatar Jun 11 '22 22:06 jeanlucthumm

I used use a custom action cd_dot for this. I stopped after we added restrict_above_cwd.

We could add an action:

    {
      key = ".",
      action = "cd_cwd",
      desc = "change tree root to vim's cwd",
    },

@kyazdani42 ?

alex-courtis avatar Jun 12 '22 01:06 alex-courtis

Doesnt:

*nvim-tree.update_cwd*
Changes the tree root directory on `DirChanged` and refreshes the tree.
  Type: `boolean`, Default: `false`

Already do that ?

kyazdani42 avatar Jun 12 '22 10:06 kyazdani42

update_cwd changes the root nicely when you cd.

I think the user would like a way to change the root to cwd without having to explicitly change.

alex-courtis avatar Jun 13 '22 07:06 alex-courtis

I guess I could theoretically do :cd $PWD? But maybe the DirChanged doesn't fire on that cause technically the directory is still the same...

jeanlucthumm avatar Jun 15 '22 02:06 jeanlucthumm

But maybe the DirChanged doesn't fire

The only way to know would be to test ;)

Have you tried the action I specified above? It will go to vim.fn.getcwd(-1)

alex-courtis avatar Jun 18 '22 01:06 alex-courtis

Closing due to inactivity.

alex-courtis avatar Sep 03 '22 03:09 alex-courtis