diff --git a/README.md b/README.md index e5886973aec..a920cf37e6e 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS open_on_tab = false, sort_by = "name", update_cwd = false, + reload_on_bufenter = false, view = { width = 30, height = 30, @@ -156,7 +157,7 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS icons = { webdev_colors = true, git_placement = "before", - } + }, }, hijack_directories = { enable = true, diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 36fdc78969e..7847e9e94ae 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -96,6 +96,7 @@ Values may be functions. Warning: this may result in unexpected behaviour. open_on_tab = false, sort_by = "name", update_cwd = false, + reload_on_bufenter = false, view = { width = 30, height = 30, @@ -124,7 +125,7 @@ Values may be functions. Warning: this may result in unexpected behaviour. icons = { webdev_colors = true, git_placement = "before", - } + }, }, hijack_directories = { enable = true, @@ -259,6 +260,10 @@ Keeps the cursor on the first letter of the filename when moving in the tree. Changes the tree root directory on `DirChanged` and refreshes the tree. Type: `boolean`, Default: `false` +*nvim-tree.reload_on_bufenter* +Automatically reloads the tree on `BufEnter` nvim-tree. + Type: `boolean`, Default: `false` + *nvim-tree.hijack_directories* hijacks new directory buffers when they are opened (`:e dir`). diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 81326b52c71..287f242a207 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -336,6 +336,10 @@ local function setup_autocommands(opts) if opts.hijack_directories.enable then create_nvim_tree_autocmd({ "BufEnter", "BufNewFile" }, { callback = M.open_on_directory }) end + + if opts.reload_on_bufenter then + create_nvim_tree_autocmd("BufEnter", { pattern = "NvimTree_*", callback = reloaders.reload_explorer }) + end end local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS @@ -350,6 +354,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS open_on_tab = false, sort_by = "name", update_cwd = false, + reload_on_bufenter = false, view = { width = 30, height = 30,