diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index bb6a7935..cf7c4974 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -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 +|: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* diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 086442ff..08088e58 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -158,6 +158,11 @@ function M.find_file(with_open) lib.set_index_and_redraw(filepath) end +function M.resize(size) + view.View.width = size + view.resize() +end + function M.on_leave() vim.defer_fn(function() if not view.win_open() then diff --git a/plugin/tree.vim b/plugin/tree.vim index 8e202496..e025ce6b 100644 --- a/plugin/tree.vim +++ b/plugin/tree.vim @@ -40,6 +40,7 @@ command! NvimTreeToggle lua require'nvim-tree'.toggle() command! NvimTreeRefresh lua require'nvim-tree'.refresh() command! NvimTreeClipboard lua require'nvim-tree'.print_clipboard() command! NvimTreeFindFile lua require'nvim-tree'.find_file(true) +command! -nargs=1 NvimTreeResize lua require'nvim-tree'.resize() let &cpo = s:save_cpo unlet s:save_cpo