feature: add feature to increase/decrease size (#1048)
This commit is contained in:
committed by
GitHub
parent
ceadf83809
commit
7cb689795e
@@ -276,7 +276,7 @@ local function setup_vim_commands()
|
||||
command! NvimTreeClipboard lua require'nvim-tree.actions.copy-paste'.print_clipboard()
|
||||
command! NvimTreeFindFile lua require'nvim-tree'.find_file(true)
|
||||
command! NvimTreeFindFileToggle lua require'nvim-tree'.toggle(true)
|
||||
command! -nargs=1 NvimTreeResize lua require'nvim-tree'.resize(<args>)
|
||||
command! -nargs=1 NvimTreeResize lua require'nvim-tree'.resize("<args>")
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
@@ -175,6 +175,24 @@ function M.open(options)
|
||||
end
|
||||
|
||||
function M.resize(size)
|
||||
if type(size) == "string" then
|
||||
size = vim.trim(size)
|
||||
local first_char = size:sub(1, 1)
|
||||
size = tonumber(size)
|
||||
|
||||
if first_char == "+" or first_char == "-" then
|
||||
size = M.View.width + size
|
||||
end
|
||||
end
|
||||
|
||||
if type(size) ~= "number" then
|
||||
return
|
||||
end
|
||||
|
||||
if size <= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
if size then
|
||||
M.View.width = size
|
||||
M.View.height = size
|
||||
|
||||
Reference in New Issue
Block a user