Added a new option auto_reload_on_write to allow users to disable it for performance reasons (#956)

This commit is contained in:
Steve Vermeulen
2022-02-09 20:06:07 +00:00
committed by GitHub
parent 5744c469a6
commit 4ec8c9f364
3 changed files with 40 additions and 30 deletions

View File

@@ -45,6 +45,7 @@ require'nvim-tree'.setup {
open_on_setup = false,
ignore_ft_on_setup = {},
auto_close = false,
auto_reload_on_write = true,
open_on_tab = false,
hijack_cursor = false,
update_cwd = false,

View File

@@ -80,6 +80,7 @@ function.
auto_open = true,
},
auto_close = false,
auto_reload_on_write = true,
open_on_tab = false,
hijack_cursor = false,
update_cwd = false,
@@ -171,6 +172,11 @@ Here is a list of the options available in the setup call:
type: `boolean`
default: `false`
*nvim-tree.auto_reload_on_write*
- |auto_reload_on_write|: reloads the explorer every time a buffer is written to
type: `boolean`
default: `true`
*nvim-tree.open_on_tab*
- |open_on_tab|: opens the tree automatically when switching tabpage or opening a new
tabpage if the tree was previously open.

View File

@@ -280,7 +280,9 @@ local function setup_autocommands(opts)
-- reset highlights when colorscheme is changed
vim.cmd "au ColorScheme * lua require'nvim-tree'.reset_highlight()"
if opts.auto_reload_on_write then
vim.cmd "au BufWritePost * lua require'nvim-tree.actions.reloaders'.reload_explorer()"
end
vim.cmd "au User FugitiveChanged,NeogitStatusRefreshed lua require'nvim-tree.actions.reloaders'.reload_git()"
if opts.auto_close then
@@ -318,6 +320,7 @@ local DEFAULT_OPTS = {
auto_open = true,
},
auto_close = false,
auto_reload_on_write = true,
hijack_cursor = false,
update_cwd = false,
hide_root_folder = false,