Skip to content

Commit d1ff893

Browse files
committed
fix: disable update_to_buf_dir when netrw is not disabled
fixes #718
1 parent e1c3744 commit d1ff893

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

doc/nvim-tree-lua.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ Here is a list of the options available in the setup call:
181181
- |update_to_buf_dir|: hijacks new directory buffers when they are opened (`:e dir`).
182182

183183
- |update_to_buf_dir.enable|: enable the feature. Disable this option if you
184-
use vim-dirvish or dirbuf.nvim.
184+
use vim-dirvish or dirbuf.nvim. If |hijack_netrw| and |disable_netrw| are
185+
`false`, this feature will be disabled.
185186
type: `boolean`
186187
default: `true`
187188

lua/nvim-tree.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function M.hijack_current_window()
8787
vim.defer_fn(remove_empty_buffer, 100)
8888
end
8989

90-
function M.on_enter(opts)
90+
function M.on_enter(netrw_disabled)
9191
local bufnr = api.nvim_get_current_buf()
9292
local bufname = api.nvim_buf_get_name(bufnr)
9393
local buftype = api.nvim_buf_get_option(bufnr, 'filetype')
@@ -100,8 +100,6 @@ function M.on_enter(opts)
100100
cwd = vim.fn.expand(bufname)
101101
end
102102

103-
local netrw_disabled = opts.disable_netrw or opts.hijack_netrw
104-
105103
local lines = not is_dir and api.nvim_buf_get_lines(bufnr, 0, -1, false) or {}
106104
local buf_has_content = #lines > 1 or (#lines == 1 and lines[1] ~= "")
107105

@@ -351,11 +349,13 @@ function M.setup(conf)
351349
local opts = vim.tbl_deep_extend('force', DEFAULT_OPTS, conf or {})
352350

353351
manage_netrw(opts.disable_netrw, opts.hijack_netrw)
352+
local netrw_disabled = opts.disable_netrw or opts.hijack_netrw
354353

355354
_config.update_focused_file = opts.update_focused_file
356355
_config.open_on_setup = opts.open_on_setup
357356
_config.ignore_ft_on_setup = opts.ignore_ft_on_setup
358357
_config.update_to_buf_dir = opts.update_to_buf_dir
358+
_config.update_to_buf_dir.enable = _config.update_to_buf_dir.enable and netrw_disabled
359359

360360
require'nvim-tree.colors'.setup()
361361
require'nvim-tree.actions'.setup(opts)
@@ -367,7 +367,7 @@ function M.setup(conf)
367367
setup_autocommands(opts)
368368
setup_vim_commands()
369369

370-
M.on_enter(opts)
370+
M.on_enter(netrw_disabled)
371371
end
372372

373373
return M

0 commit comments

Comments
 (0)