File tree 2 files changed +8
-2
lines changed 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -491,7 +491,8 @@ Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
491
491
Type: `boolean ` , Default: `false`
492
492
493
493
*nvim-tree.hijack_directories* (previously `update_to_buf_dir` )
494
- hijacks new directory buffers when they are opened (`:e dir`).
494
+ hijacks new directory buffers when they are opened (`:e dir`) or if a
495
+ directory is opened on startup e.g. `nvim .`
495
496
496
497
*nvim-tree.hijack_directories.enable*
497
498
Enable the feature.
Original file line number Diff line number Diff line change @@ -257,13 +257,18 @@ function M.on_enter(netrw_disabled)
257
257
end
258
258
end
259
259
260
+ local should_hijack = _config .hijack_directories .enable
261
+ and _config .hijack_directories .auto_open
262
+ and is_dir
263
+ and not should_be_preserved
264
+
260
265
-- Session that left a NvimTree Buffer opened, reopen with it
261
266
local existing_tree_wins = find_existing_windows ()
262
267
if existing_tree_wins [1 ] then
263
268
api .nvim_set_current_win (existing_tree_wins [1 ])
264
269
end
265
270
266
- if should_open or existing_tree_wins [1 ] ~= nil then
271
+ if should_open or should_hijack or existing_tree_wins [1 ] ~= nil then
267
272
lib .open (cwd )
268
273
269
274
if should_focus_other_window then
You can’t perform that action at this time.
0 commit comments