Add horizontal position options to g:NERDTreeWinPos (#1363)

This commit is contained in:
Ali Rezvani 2023-09-03 07:15:35 +03:30 committed by GitHub
parent 6895e5259e
commit 1f2e28d476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -1128,7 +1128,7 @@ setting is used.
------------------------------------------------------------------------------
*NERDTreeWinPos*
Values: "left" or "right"
Values: "left", "right", "top" or "bottom"
Default: "left".
This setting is used to determine where NERDTree window is placed on the
@ -1138,6 +1138,13 @@ This setting makes it possible to use two different explorer plugins
simultaneously. For example, you could have the taglist plugin on the left of
the window and the NERDTree on the right.
When setting this variable to "top" or "bottom" make sure to also change the
|NERDTreeWinSize| to a more reasonable size.
For example:
>
let g:NERDTreeWinSize = 15
<
------------------------------------------------------------------------------
*NERDTreeWinSize*
Values: a positive integer.

View File

@ -182,16 +182,17 @@ endfunction
" Initialize the NERDTree window. Open the window, size it properly, set all
" local options, etc.
function! s:Creator._createTreeWin()
let l:splitLocation = g:NERDTreeWinPos ==# 'left' ? 'topleft ' : 'botright '
let l:splitLocation = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'top' ? 'topleft ' : 'botright '
let l:splitDirection = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'right' ? 'vertical' : ''
let l:splitSize = g:NERDTreeWinSize
if !g:NERDTree.ExistsForTab()
let t:NERDTreeBufName = self._nextBufferName()
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new'
silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' new'
silent! execute 'edit ' . t:NERDTreeBufName
silent! execute 'vertical resize '. l:splitSize
silent! execute l:splitDirection . ' resize '. l:splitSize
else
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split'
silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' split'
silent! execute 'buffer ' . t:NERDTreeBufName
endif