diff --git a/README.md b/README.md index a2b45dbe..749dc4e4 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,6 @@ require'nvim-tree'.setup { height = 30, hide_root_folder = false, side = 'left', - auto_resize = false, preserve_window_proportions = false, mappings = { custom_only = false, @@ -172,6 +171,7 @@ require'nvim-tree'.setup { }, open_file = { quit_on_open = false, + resize_window = false, window_picker = { enable = true, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 0148d075..1f5a2b77 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -113,7 +113,6 @@ function. width = 30, height = 30, side = 'left', - auto_resize = false, preserve_window_proportions = false, number = false, relativenumber = false, @@ -138,6 +137,7 @@ function. }, open_file = { quit_on_open = false, + resize_window = false, window_picker = { enable = true, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", @@ -336,10 +336,6 @@ Here is a list of the options available in the setup call: type: `string` default: 'left' - - |view.auto_resize|: auto resize the tree after opening a file - type: `boolean` - default: `false` - - |view.preserve_window_proportions|: preserve window proportions when opening a file. If `false`, the height and width of windows other than nvim-tree will be equalized. @@ -418,6 +414,10 @@ Here is a list of the options available in the setup call: type: `boolean` default: `false` + - |actions.open_file.resize_window|: resizes the tree when opening a file + type: `boolean` + default: `false` + - |actions.open_file.window_picker|: window picker configuration - |actions.open_file.window_picker.enable|: Enable the feature. If the diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 08a2c651..2a6c0cea 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -380,6 +380,7 @@ local DEFAULT_OPTS = { }, open_file = { quit_on_open = vim.g.nvim_tree_quit_on_open == 1, + resize_window = false, window_picker = { enable = true, } diff --git a/lua/nvim-tree/actions/open-file.lua b/lua/nvim-tree/actions/open-file.lua index 204cb827..7695ae9f 100644 --- a/lua/nvim-tree/actions/open-file.lua +++ b/lua/nvim-tree/actions/open-file.lua @@ -6,6 +6,7 @@ local view = require'nvim-tree.view' local M = { quit_on_open = false, + resize_window = false, window_picker = { enable = true, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", @@ -208,7 +209,9 @@ function M.fn(mode, filename) cmd = cmd .. vim.fn.fnameescape(filename) api.nvim_set_current_win(target_winid) pcall(vim.cmd, cmd) - view.resize() + if M.resize_window then + view.resize() + end end if mode == "preview" then diff --git a/lua/nvim-tree/legacy.lua b/lua/nvim-tree/legacy.lua index e6abcd3c..d4ee5cfb 100644 --- a/lua/nvim-tree/legacy.lua +++ b/lua/nvim-tree/legacy.lua @@ -87,9 +87,9 @@ local migrations = { end, nvim_tree_auto_resize = function(o) - utils.table_create_missing(o, "view") - if o.view.auto_resize == nil then - o.view.auto_resize = vim.g.nvim_tree_auto_resize ~= 0 + utils.table_create_missing(o, "actions.open_file") + if o.actions.open_file.resize_window == nil then + o.actions.open_file.resize_window = vim.g.nvim_tree_auto_resize ~= 0 end end, diff --git a/lua/nvim-tree/view.lua b/lua/nvim-tree/view.lua index fad56eec..872e0b89 100644 --- a/lua/nvim-tree/view.lua +++ b/lua/nvim-tree/view.lua @@ -324,7 +324,6 @@ local DEFAULT_CONFIG = { width = 30, height = 30, side = 'left', - auto_resize = false, preserve_window_proportions = false, number = false, relativenumber = false, @@ -337,7 +336,6 @@ function M.setup(opts) M.View.width = options.width M.View.height = options.height M.View.hide_root_folder = options.hide_root_folder - M.View.auto_resize = options.auto_resize M.View.preserve_window_proportions = options.preserve_window_proportions M.View.winopts.number = options.number M.View.winopts.relativenumber = options.relativenumber