commit f0a97209f1d5a630f30506e4243d09a7254f71df
parent 97433edd43f3a4a95c84389bcaafbe7a047cf756
Author: Jason Franklin <j_fra@fastmail.us>
Date: Sat, 11 Nov 2017 08:29:09 -0500
Clean up the NERDTreeOpener constructor
This method needed some love. The internals were simplified and
reformatted, and the comment was edited for additional readability.
Diffstat:
1 file changed, 18 insertions(+), 27 deletions(-)
diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim
@@ -126,38 +126,29 @@ function! s:Opener._isWindowUsable(winnumber)
endfunction
" FUNCTION: Opener.New(path, opts) {{{1
+" Instantiate a new NERDTreeOpener object.
" Args:
-"
-" a:path: The path object that is to be opened.
-"
-" a:opts:
-"
-" A dictionary containing the following keys (all optional):
-" 'where': Specifies whether the node should be opened in new split/tab or in
-" the previous window. Can be either 'v' or 'h' or 't' (for open in
-" new tab)
-" 'reuse': if a window is displaying the file then jump the cursor there. Can
-" 'all', 'currenttab' or empty to not reuse.
-" 'keepopen': dont close the tree window
-" 'stay': open the file, but keep the cursor in the tree win
+" a:path: the path object that is to be opened
+" a:opts: a dictionary containing the following optional keys...
+" 'where': specifies whether the node should be opened in new split, in
+" a new tab or, in the last window; takes values "v", "h", or "t"
+" 'reuse': if file is already shown in a window, jump there; takes values
+" "all", "currenttab", or empty
+" 'keepopen': boolean (0 or 1); if true, the tree window will not be closed
+" 'stay': boolean (0 or 1); if true, remain in tree window after opening
function! s:Opener.New(path, opts)
- let newObj = copy(self)
+ let l:newOpener = copy(self)
- let newObj._path = a:path
- let newObj._stay = nerdtree#has_opt(a:opts, 'stay')
-
- if has_key(a:opts, 'reuse')
- let newObj._reuse = a:opts['reuse']
- else
- let newObj._reuse = ''
- endif
+ let l:newOpener._keepopen = nerdtree#has_opt(a:opts, 'keepopen')
+ let l:newOpener._nerdtree = b:NERDTree
+ let l:newOpener._path = a:path
+ let l:newOpener._reuse = has_key(a:opts, 'reuse') ? a:opts['reuse'] : ''
+ let l:newOpener._stay = nerdtree#has_opt(a:opts, 'stay')
+ let l:newOpener._where = has_key(a:opts, 'where') ? a:opts['where'] : ''
- let newObj._keepopen = nerdtree#has_opt(a:opts, 'keepopen')
- let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : ''
- let newObj._nerdtree = b:NERDTree
- call newObj._saveCursorPos()
+ call l:newOpener._saveCursorPos()
- return newObj
+ return l:newOpener
endfunction
" FUNCTION: Opener._newSplit() {{{1