Skip to content

Commit

Permalink
fix(#1668): revert all startup behaviour changes back to 540055b
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-courtis committed Oct 18, 2022
1 parent 4e24505 commit 3a2f68b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
28 changes: 8 additions & 20 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ Subsequent calls to setup will replace the previous configuration.
open_on_setup = false,
open_on_setup_file = false,
open_on_tab = false,
focus_empty_on_setup = false,
ignore_buf_on_tab_change = {},
sort_by = "name",
root_dirs = {},
Expand Down Expand Up @@ -391,33 +390,28 @@ Hijack netrw windows (overridden if |disable_netrw| is `true`)
Type: `boolean`, Default: `true`

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

*nvim-tree.open_on_setup_file*
Will automatically open the tree when running setup if startup buffer is a
file.
Will automatically open the tree when running setup if startup buffer is a file.
File window will be focused.
File will be found if |nvim-tree.update_focused_file| is enabled.
File will be found if update_focused_file is enabled.
Type: `boolean`, Default: `false`

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

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

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

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

*nvim-tree.focus_empty_on_setup*
When the tree opens as a result of |nvim-tree.open_on_setup| or
|nvim-tree.open_on_tab| and the buffer is empty, focus the buffer.
Type: `boolean`, Default: `false`

*nvim-tree.sort_by*
Changes how files within the same directory are sorted.
Can be one of `name`, `case_sensitive`, `modification_time`, `extension` or a
Expand Down Expand Up @@ -491,8 +480,7 @@ Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
Type: `boolean`, Default: `false`

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

*nvim-tree.hijack_directories.enable*
Enable the feature.
Expand Down
13 changes: 5 additions & 8 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ end

local function find_existing_windows()
return vim.tbl_filter(function(win)
return utils.is_nvim_tree_buf(api.nvim_win_get_buf(win))
local buf = api.nvim_win_get_buf(win)
return api.nvim_buf_get_name(buf):match "NvimTree" ~= nil
end, api.nvim_list_wins())
end

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

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

local should_open = false
local should_focus_other_window = false
local should_find = false
if (_config.open_on_setup or _config.open_on_setup_file) and not should_be_preserved then
if not buf_has_content and _config.open_on_setup then
should_open = true
should_focus_other_window = _config.focus_empty_on_setup
elseif buf_is_dir and _config.open_on_setup then
if buf_is_dir or buf_is_empty then
should_open = true
elseif is_file and _config.open_on_setup_file then
should_open = true
should_focus_other_window = true
should_find = _config.update_focused_file.enable
elseif _config.ignore_buffer_on_setup and _config.open_on_setup then
elseif _config.ignore_buffer_on_setup then
should_open = true
should_focus_other_window = true
end
Expand Down Expand Up @@ -459,7 +458,6 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
open_on_setup = false,
open_on_setup_file = false,
open_on_tab = false,
focus_empty_on_setup = false,
ignore_buf_on_tab_change = {},
sort_by = "name",
root_dirs = {},
Expand Down Expand Up @@ -734,7 +732,6 @@ function M.setup(conf)
_config.update_focused_file = opts.update_focused_file
_config.open_on_setup = opts.open_on_setup
_config.open_on_setup_file = opts.open_on_setup_file
_config.focus_empty_on_setup = opts.focus_empty_on_setup
_config.ignore_buffer_on_setup = opts.ignore_buffer_on_setup
_config.ignore_ft_on_setup = opts.ignore_ft_on_setup
_config.ignore_buf_on_tab_change = opts.ignore_buf_on_tab_change
Expand Down
5 changes: 5 additions & 0 deletions lua/nvim-tree/legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ local function removed(opts)
utils.notify.warn "auto close feature has been removed, see note in the README (tips & reminder section)"
opts.auto_close = nil
end

if opts.focus_empty_on_setup then
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"
end
opts.focus_empty_on_setup = nil
end

function M.migrate_legacy_options(opts)
Expand Down

0 comments on commit 3a2f68b

Please sign in to comment.