Add NvimTreeResize to resize the NvimTree window (#497)

This commit is contained in:
Kassio Borges 2021-07-10 09:52:20 +01:00 committed by GitHub
parent 102c4c2332
commit 07dd10663a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -49,6 +49,11 @@ It will also open the leafs of the tree leading to the file in the buffer
Print clipboard content for both cut and copy Print clipboard content for both cut and copy
|:NvimTreeResize| *:NvimTreeResize*
Resize the NvimTree window to the given size. Example: `:NvimTreeresize 50`
resizes the window to the width of 50.
============================================================================== ==============================================================================
OPTIONS *nvim-tree-options* OPTIONS *nvim-tree-options*

View File

@ -158,6 +158,11 @@ function M.find_file(with_open)
lib.set_index_and_redraw(filepath) lib.set_index_and_redraw(filepath)
end end
function M.resize(size)
view.View.width = size
view.resize()
end
function M.on_leave() function M.on_leave()
vim.defer_fn(function() vim.defer_fn(function()
if not view.win_open() then if not view.win_open() then

View File

@ -40,6 +40,7 @@ command! NvimTreeToggle lua require'nvim-tree'.toggle()
command! NvimTreeRefresh lua require'nvim-tree'.refresh() command! NvimTreeRefresh lua require'nvim-tree'.refresh()
command! NvimTreeClipboard lua require'nvim-tree'.print_clipboard() command! NvimTreeClipboard lua require'nvim-tree'.print_clipboard()
command! NvimTreeFindFile lua require'nvim-tree'.find_file(true) command! NvimTreeFindFile lua require'nvim-tree'.find_file(true)
command! -nargs=1 NvimTreeResize lua require'nvim-tree'.resize(<args>)
let &cpo = s:save_cpo let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo