Skip to content

Commit 3a2f68b

Browse files
committed
fix(#1668): revert all startup behaviour changes back to 540055b
1 parent 4e24505 commit 3a2f68b

File tree

3 files changed

+18
-28
lines changed

3 files changed

+18
-28
lines changed

doc/nvim-tree-lua.txt

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ Subsequent calls to setup will replace the previous configuration.
175175
open_on_setup = false,
176176
open_on_setup_file = false,
177177
open_on_tab = false,
178-
focus_empty_on_setup = false,
179178
ignore_buf_on_tab_change = {},
180179
sort_by = "name",
181180
root_dirs = {},
@@ -391,33 +390,28 @@ Hijack netrw windows (overridden if |disable_netrw| is `true`)
391390
Type: `boolean`, Default: `true`
392391

393392
*nvim-tree.open_on_setup*
394-
Will automatically open the tree when running setup if startup buffer is a
395-
directory, empty or unnamed.
396-
nvim-tree window will be focused.
397-
See |nvim-tree.focus_empty_on_setup|
393+
Will automatically open the tree when running setup if startup buffer is
394+
a directory, is empty or is unnamed. nvim-tree window will be focused.
398395
Type: `boolean`, Default: `false`
399396

400397
*nvim-tree.open_on_setup_file*
401-
Will automatically open the tree when running setup if startup buffer is a
402-
file.
398+
Will automatically open the tree when running setup if startup buffer is a file.
403399
File window will be focused.
404-
File will be found if |nvim-tree.update_focused_file| is enabled.
400+
File will be found if update_focused_file is enabled.
405401
Type: `boolean`, Default: `false`
406402

407403
*nvim-tree.ignore_buffer_on_setup*
408-
Always open the tree when |nvim-tree.open_on_setup| is enabled, regardless of
409-
the startup buffer.
410-
Buffer window will be focused.
404+
Will ignore the buffer, when deciding to open the tree on setup.
411405
Type: `boolean`, Default: `false`
412406

413407
*nvim-tree.ignore_ft_on_setup*
414-
List of filetypes that will prevent |nvim-tree.open_on_setup_file|.
408+
List of filetypes that will prevent `open_on_setup` to open.
415409
You can use this option if you don't want the tree to open
416410
in some scenarios (eg using vim startify).
417411
Type: {string}, Default: `{}`
418412

419413
*nvim-tree.ignore_buf_on_tab_change*
420-
List of filetypes or buffer names that will prevent |nvim-tree.open_on_tab|.
414+
List of filetypes or buffer names that will prevent `open_on_tab` to open.
421415
Type: {string}, Default: `{}`
422416

423417
*nvim-tree.auto_reload_on_write*
@@ -434,11 +428,6 @@ Opens the tree automatically when switching tabpage or opening a new tabpage
434428
if the tree was previously open.
435429
Type: `boolean`, Default: `false`
436430

437-
*nvim-tree.focus_empty_on_setup*
438-
When the tree opens as a result of |nvim-tree.open_on_setup| or
439-
|nvim-tree.open_on_tab| and the buffer is empty, focus the buffer.
440-
Type: `boolean`, Default: `false`
441-
442431
*nvim-tree.sort_by*
443432
Changes how files within the same directory are sorted.
444433
Can be one of `name`, `case_sensitive`, `modification_time`, `extension` or a
@@ -491,8 +480,7 @@ Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
491480
Type: `boolean`, Default: `false`
492481

493482
*nvim-tree.hijack_directories* (previously `update_to_buf_dir`)
494-
hijacks new directory buffers when they are opened (`:e dir`) or if a
495-
directory is opened on startup e.g. `nvim .`
483+
hijacks new directory buffers when they are opened (`:e dir`).
496484

497485
*nvim-tree.hijack_directories.enable*
498486
Enable the feature.

lua/nvim-tree.lua

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ end
135135

136136
local function find_existing_windows()
137137
return vim.tbl_filter(function(win)
138-
return utils.is_nvim_tree_buf(api.nvim_win_get_buf(win))
138+
local buf = api.nvim_win_get_buf(win)
139+
return api.nvim_buf_get_name(buf):match "NvimTree" ~= nil
139140
end, api.nvim_list_wins())
140141
end
141142

@@ -236,22 +237,20 @@ function M.on_enter(netrw_disabled)
236237
local buf_has_content = #lines > 1 or (#lines == 1 and lines[1] ~= "")
237238

238239
local buf_is_dir = is_dir and netrw_disabled
240+
local buf_is_empty = bufname == "" and not buf_has_content
239241
local should_be_preserved = vim.tbl_contains(ft_ignore, buftype)
240242

241243
local should_open = false
242244
local should_focus_other_window = false
243245
local should_find = false
244246
if (_config.open_on_setup or _config.open_on_setup_file) and not should_be_preserved then
245-
if not buf_has_content and _config.open_on_setup then
246-
should_open = true
247-
should_focus_other_window = _config.focus_empty_on_setup
248-
elseif buf_is_dir and _config.open_on_setup then
247+
if buf_is_dir or buf_is_empty then
249248
should_open = true
250249
elseif is_file and _config.open_on_setup_file then
251250
should_open = true
252251
should_focus_other_window = true
253252
should_find = _config.update_focused_file.enable
254-
elseif _config.ignore_buffer_on_setup and _config.open_on_setup then
253+
elseif _config.ignore_buffer_on_setup then
255254
should_open = true
256255
should_focus_other_window = true
257256
end
@@ -459,7 +458,6 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
459458
open_on_setup = false,
460459
open_on_setup_file = false,
461460
open_on_tab = false,
462-
focus_empty_on_setup = false,
463461
ignore_buf_on_tab_change = {},
464462
sort_by = "name",
465463
root_dirs = {},
@@ -734,7 +732,6 @@ function M.setup(conf)
734732
_config.update_focused_file = opts.update_focused_file
735733
_config.open_on_setup = opts.open_on_setup
736734
_config.open_on_setup_file = opts.open_on_setup_file
737-
_config.focus_empty_on_setup = opts.focus_empty_on_setup
738735
_config.ignore_buffer_on_setup = opts.ignore_buffer_on_setup
739736
_config.ignore_ft_on_setup = opts.ignore_ft_on_setup
740737
_config.ignore_buf_on_tab_change = opts.ignore_buf_on_tab_change

lua/nvim-tree/legacy.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ local function removed(opts)
295295
utils.notify.warn "auto close feature has been removed, see note in the README (tips & reminder section)"
296296
opts.auto_close = nil
297297
end
298+
299+
if opts.focus_empty_on_setup then
300+
utils.notify.warn "focus_empty_on_setup has been removed and will be replaced by a new startup configuration. Please remove this option. See https://bit.ly/3S7BtqP and https://bit.ly/3yJch2T"
301+
end
302+
opts.focus_empty_on_setup = nil
298303
end
299304

300305
function M.migrate_legacy_options(opts)

0 commit comments

Comments
 (0)