From 6a0d269cc7e43eeea27e1406d70fdcc575ae1bea Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 29 Jan 2023 14:27:59 +1100 Subject: [PATCH 1/2] deprecate open_on_startup behaviour --- lua/nvim-tree.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 12ccef4da99..c59252ae475 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -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 = {} @@ -216,8 +217,10 @@ end M.resize = view.resize function M.open_on_directory() + require "amc.log".line("open_on_directory") local should_proceed = M.initialized and (_config.hijack_directories.auto_open or view.is_visible()) if not should_proceed then + require "amc.log".line("open_on_directory exit early") return end @@ -306,12 +309,16 @@ function M.on_enter(netrw_disabled) local cwd if is_dir then cwd = vim.fn.expand(vim.fn.fnameescape(bufname)) + require "amc.log".line("cd %s", cwd) -- INFO: could potentially conflict with rooter plugins vim.cmd("noautocmd cd " .. vim.fn.fnameescape(cwd)) end lib.open { path = cwd } + require "amc.log".line("should_hijack = %s", should_hijack) + require "amc.log".line("should_focus_other_window = %s", should_focus_other_window) + if should_focus_other_window then vim.cmd "noautocmd wincmd p" if should_find then @@ -900,7 +907,12 @@ 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" + M.on_enter(netrw_disabled) + else + M.initialized = true + end vim.g.NvimTreeSetup = 1 vim.api.nvim_exec_autocmds("User", { pattern = "NvimTreeSetup" }) end) From 6632b72219beee1888b9b2771980ab34377ce63a Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 29 Jan 2023 14:32:56 +1100 Subject: [PATCH 2/2] deprecate open_on_startup behaviour --- doc/nvim-tree-lua.txt | 4 ++++ lua/nvim-tree.lua | 13 ++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 6576bb5748d..bda7d45d10e 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -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). diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index c59252ae475..9a6e820ae68 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -217,10 +217,8 @@ end M.resize = view.resize function M.open_on_directory() - require "amc.log".line("open_on_directory") local should_proceed = M.initialized and (_config.hijack_directories.auto_open or view.is_visible()) if not should_proceed then - require "amc.log".line("open_on_directory exit early") return end @@ -309,16 +307,12 @@ function M.on_enter(netrw_disabled) local cwd if is_dir then cwd = vim.fn.expand(vim.fn.fnameescape(bufname)) - require "amc.log".line("cd %s", cwd) -- INFO: could potentially conflict with rooter plugins vim.cmd("noautocmd cd " .. vim.fn.fnameescape(cwd)) end lib.open { path = cwd } - require "amc.log".line("should_hijack = %s", should_hijack) - require "amc.log".line("should_focus_other_window = %s", should_focus_other_window) - if should_focus_other_window then vim.cmd "noautocmd wincmd p" if should_find then @@ -907,7 +901,12 @@ function M.setup(conf) M.setup_called = true vim.schedule(function() - 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 + 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" M.on_enter(netrw_disabled) else