Skip to content

deprecate open_on_setup #1951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -427,21 +427,25 @@ Hijack netrw windows (overridden if |disable_netrw| is `true`)
Type: `boolean`, Default: `true`

*nvim-tree.open_on_setup*
Deprecated: please see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
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*
Deprecated: please see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
Will automatically open the tree when running setup if startup buffer is a file.
File window will be focused.
File will be found if update_focused_file is enabled.
Type: `boolean`, Default: `false`

*nvim-tree.ignore_buffer_on_setup*
Deprecated: please see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
Will ignore the buffer, when deciding to open the tree on setup.
Type: `boolean`, Default: `false`

*nvim-tree.ignore_ft_on_setup*
Deprecated: please see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
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).
Expand Down
13 changes: 12 additions & 1 deletion lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local collapse_all = require "nvim-tree.actions.tree-modifiers.collapse-all"
local git = require "nvim-tree.git"
local filters = require "nvim-tree.explorer.filters"
local modified = require "nvim-tree.modified"
local notify = require "nvim-tree.notify"

local _config = {}

Expand Down Expand Up @@ -900,7 +901,17 @@ function M.setup(conf)
M.setup_called = true

vim.schedule(function()
M.on_enter(netrw_disabled)
if
#opts.ignore_ft_on_setup > 0
or opts.open_on_setup == true
or opts.open_on_setup_file
or opts.ignore_buffer_on_setup
then
notify.info "open_on_setup behaviour has been deprecated, please see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect people might get upset, however I can't see any other way to do this.

M.on_enter(netrw_disabled)
else
M.initialized = true
end
vim.g.NvimTreeSetup = 1
vim.api.nvim_exec_autocmds("User", { pattern = "NvimTreeSetup" })
end)
Expand Down