chore: move auto_resize to actions.open_file.resize_window

fixes #1034
This commit is contained in:
kiyan
2022-03-01 20:07:36 +01:00
parent 9ec710e338
commit 6af2d5a720
6 changed files with 14 additions and 12 deletions

View File

@@ -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",

View File

@@ -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

View File

@@ -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,
}

View File

@@ -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,8 +209,10 @@ function M.fn(mode, filename)
cmd = cmd .. vim.fn.fnameescape(filename)
api.nvim_set_current_win(target_winid)
pcall(vim.cmd, cmd)
if M.resize_window then
view.resize()
end
end
if mode == "preview" then
view.focus()

View File

@@ -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,

View File

@@ -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