feature: add feature to increase/decrease size (#1048)
This commit is contained in:
parent
ceadf83809
commit
7cb689795e
@ -90,7 +90,12 @@ let g:nvim_tree_icons = {
|
|||||||
nnoremap <C-n> :NvimTreeToggle<CR>
|
nnoremap <C-n> :NvimTreeToggle<CR>
|
||||||
nnoremap <leader>r :NvimTreeRefresh<CR>
|
nnoremap <leader>r :NvimTreeRefresh<CR>
|
||||||
nnoremap <leader>n :NvimTreeFindFile<CR>
|
nnoremap <leader>n :NvimTreeFindFile<CR>
|
||||||
" NvimTreeOpen, NvimTreeClose, NvimTreeFocus, NvimTreeFindFileToggle, and NvimTreeResize are also available if you need them
|
" More available functions:
|
||||||
|
" NvimTreeOpen
|
||||||
|
" NvimTreeClose
|
||||||
|
" NvimTreeFocus
|
||||||
|
" NvimTreeFindFileToggle
|
||||||
|
" NvimTreeResize
|
||||||
|
|
||||||
set termguicolors " this variable must be enabled for colors to be applied properly
|
set termguicolors " this variable must be enabled for colors to be applied properly
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,11 @@ Print clipboard content for both cut and copy
|
|||||||
|:NvimTreeResize| *:NvimTreeResize*
|
|:NvimTreeResize| *:NvimTreeResize*
|
||||||
|
|
||||||
Resize the NvimTree window to the given size. Example: `:NvimTreeResize 50`
|
Resize the NvimTree window to the given size. Example: `:NvimTreeResize 50`
|
||||||
resizes the window to the width of 50.
|
resizes the window to the width of 50. If the size starts with "+" or "-" it
|
||||||
|
adds or removes the given value to the current window width.
|
||||||
|
Example `:NvimTreeResize -20` removes the value 20 from the current width. And
|
||||||
|
`:NvimTreeResize +20` adds the value 20 to the current width.
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
SETUP *nvim-tree.setup*
|
SETUP *nvim-tree.setup*
|
||||||
|
|||||||
@ -276,7 +276,7 @@ local function setup_vim_commands()
|
|||||||
command! NvimTreeClipboard lua require'nvim-tree.actions.copy-paste'.print_clipboard()
|
command! NvimTreeClipboard lua require'nvim-tree.actions.copy-paste'.print_clipboard()
|
||||||
command! NvimTreeFindFile lua require'nvim-tree'.find_file(true)
|
command! NvimTreeFindFile lua require'nvim-tree'.find_file(true)
|
||||||
command! NvimTreeFindFileToggle lua require'nvim-tree'.toggle(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
|
end
|
||||||
|
|
||||||
|
|||||||
@ -175,6 +175,24 @@ function M.open(options)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.resize(size)
|
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
|
if size then
|
||||||
M.View.width = size
|
M.View.width = size
|
||||||
M.View.height = size
|
M.View.height = size
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user