Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizontal positioning for the g:NERDTreeWinPos #1363

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion doc/NERDTree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
9 changes: 5 additions & 4 deletions lib/nerdtree/creator.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down