fix: add config for preserving window proportions on open file (#999)
This commit is contained in:
parent
61b57e3676
commit
3486c48225
@ -151,6 +151,7 @@ require'nvim-tree'.setup {
|
||||
hide_root_folder = false,
|
||||
side = 'left',
|
||||
auto_resize = false,
|
||||
preserve_window_proportions = false,
|
||||
mappings = {
|
||||
custom_only = false,
|
||||
list = {}
|
||||
|
||||
@ -113,6 +113,7 @@ function.
|
||||
height = 30,
|
||||
side = 'left',
|
||||
auto_resize = false,
|
||||
preserve_window_proportions = false,
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
signcolumn = "yes",
|
||||
@ -332,17 +333,23 @@ Here is a list of the options available in the setup call:
|
||||
|
||||
- |view.auto_resize|: auto resize the tree after opening a file
|
||||
type: `boolean`
|
||||
default: false
|
||||
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.
|
||||
type: `boolean`
|
||||
default: `false`
|
||||
|
||||
- |view.number|: print the line number in front of each line.
|
||||
type: `boolean`
|
||||
default: false
|
||||
default: `false`
|
||||
|
||||
- |view.relativenumber|: show the line number relative to the line with the
|
||||
cursor in front of each line. If the option `view.number` is also `true`,
|
||||
the number on the cursor line will be the line number instead of `0`.
|
||||
type: `boolean`
|
||||
default: false
|
||||
default: `false`
|
||||
|
||||
- |view.signcolumn|: show diagnostic sign column. Value can be `"yes"`,
|
||||
`"auto"`, `"no"`
|
||||
@ -354,11 +361,11 @@ Here is a list of the options available in the setup call:
|
||||
- |view.mappings.custom_only|: will use only the provided user mappings and not the default
|
||||
otherwise, extends the default mappings with the provided user mappings
|
||||
type: `boolean`
|
||||
default: false
|
||||
default: `false`
|
||||
|
||||
- |view.mappings.list|: a list of keymaps that will extend or override the default keymaps
|
||||
type: list of `{ key: table of strings or string, mode: string (vim-mode), cb: callback function as a string }`
|
||||
default: {}
|
||||
default: `{}`
|
||||
|
||||
*nvim-tree.filters*
|
||||
|filters|: filtering options
|
||||
|
||||
@ -368,7 +368,7 @@ local DEFAULT_OPTS = {
|
||||
exclude = vim.g.nvim_tree_window_picker_exclude,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
local function merge_options(conf)
|
||||
|
||||
@ -179,7 +179,10 @@ function M.resize(size)
|
||||
else
|
||||
a.nvim_win_set_height(M.get_winnr(), get_size())
|
||||
end
|
||||
vim.cmd ":wincmd ="
|
||||
|
||||
if not M.View.preserve_window_proportions then
|
||||
vim.cmd(":wincmd =")
|
||||
end
|
||||
end
|
||||
|
||||
function M.reposition_window()
|
||||
@ -321,6 +324,7 @@ local DEFAULT_CONFIG = {
|
||||
height = 30,
|
||||
side = 'left',
|
||||
auto_resize = false,
|
||||
preserve_window_proportions = false,
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
signcolumn = 'yes'
|
||||
@ -333,6 +337,7 @@ function M.setup(opts)
|
||||
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
|
||||
M.View.winopts.signcolumn = options.signcolumn
|
||||
|
||||
Loading…
Reference in New Issue
Block a user