Clean up the commentary in "creator.vim"
This commit is contained in:
parent
3cb90cb18d
commit
d9074c2753
@ -1,11 +1,17 @@
|
|||||||
"CLASS: Creator
|
" ============================================================================
|
||||||
"Creates tab/window/mirror nerdtree windows. Sets up all the window and
|
" CLASS: Creator
|
||||||
"buffer options and key mappings etc.
|
"
|
||||||
"============================================================
|
" This class is responsible for creating NERDTree instances. The new NERDTree
|
||||||
|
" may be a tab tree, a window tree, or a mirrored tree. In the process of
|
||||||
|
" creating a NERDTree, it sets up all of the window and buffer options and key
|
||||||
|
" mappings etc.
|
||||||
|
" ============================================================================
|
||||||
|
|
||||||
|
|
||||||
let s:Creator = {}
|
let s:Creator = {}
|
||||||
let g:NERDTreeCreator = s:Creator
|
let g:NERDTreeCreator = s:Creator
|
||||||
|
|
||||||
"FUNCTION: s:Creator._bindMappings() {{{1
|
" FUNCTION: s:Creator._bindMappings() {{{1
|
||||||
function! s:Creator._bindMappings()
|
function! s:Creator._bindMappings()
|
||||||
"make <cr> do the same as the activate node mapping
|
"make <cr> do the same as the activate node mapping
|
||||||
nnoremap <silent> <buffer> <cr> :call nerdtree#ui_glue#invokeKeyMap(g:NERDTreeMapActivateNode)<cr>
|
nnoremap <silent> <buffer> <cr> :call nerdtree#ui_glue#invokeKeyMap(g:NERDTreeMapActivateNode)<cr>
|
||||||
@ -22,7 +28,7 @@ function! s:Creator._bindMappings()
|
|||||||
command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write()
|
command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator._broadcastInitEvent() {{{1
|
" FUNCTION: s:Creator._broadcastInitEvent() {{{1
|
||||||
function! s:Creator._broadcastInitEvent()
|
function! s:Creator._broadcastInitEvent()
|
||||||
silent doautocmd User NERDTreeInit
|
silent doautocmd User NERDTreeInit
|
||||||
endfunction
|
endfunction
|
||||||
@ -32,14 +38,14 @@ function! s:Creator.BufNamePrefix()
|
|||||||
return 'NERD_tree_'
|
return 'NERD_tree_'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.CreateTabTree(a:name) {{{1
|
" FUNCTION: s:Creator.CreateTabTree(a:name) {{{1
|
||||||
function! s:Creator.CreateTabTree(name)
|
function! s:Creator.CreateTabTree(name)
|
||||||
let creator = s:Creator.New()
|
let creator = s:Creator.New()
|
||||||
call creator.createTabTree(a:name)
|
call creator.createTabTree(a:name)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.createTabTree(a:name) {{{1
|
" FUNCTION: s:Creator.createTabTree(a:name) {{{1
|
||||||
"name: the name of a bookmark or a directory
|
" name: the name of a bookmark or a directory
|
||||||
function! s:Creator.createTabTree(name)
|
function! s:Creator.createTabTree(name)
|
||||||
let path = self._pathForString(a:name)
|
let path = self._pathForString(a:name)
|
||||||
|
|
||||||
@ -74,13 +80,13 @@ function! s:Creator.createTabTree(name)
|
|||||||
call self._broadcastInitEvent()
|
call self._broadcastInitEvent()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.CreateWindowTree(dir) {{{1
|
" FUNCTION: s:Creator.CreateWindowTree(dir) {{{1
|
||||||
function! s:Creator.CreateWindowTree(dir)
|
function! s:Creator.CreateWindowTree(dir)
|
||||||
let creator = s:Creator.New()
|
let creator = s:Creator.New()
|
||||||
call creator.createWindowTree(a:dir)
|
call creator.createWindowTree(a:dir)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.createWindowTree(dir) {{{1
|
" FUNCTION: s:Creator.createWindowTree(dir) {{{1
|
||||||
function! s:Creator.createWindowTree(dir)
|
function! s:Creator.createWindowTree(dir)
|
||||||
try
|
try
|
||||||
let path = g:NERDTreePath.New(a:dir)
|
let path = g:NERDTreePath.New(a:dir)
|
||||||
@ -177,9 +183,9 @@ function! s:Creator.createMirror()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator._createTreeWin() {{{1
|
" FUNCTION: s:Creator._createTreeWin() {{{1
|
||||||
"Inits the NERD tree window. ie. opens it, sizes it, sets all the local
|
" Inits the NERD tree window. ie. opens it, sizes it, sets all the local
|
||||||
"options etc
|
" options etc
|
||||||
function! s:Creator._createTreeWin()
|
function! s:Creator._createTreeWin()
|
||||||
"create the nerd tree window
|
"create the nerd tree window
|
||||||
let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright "
|
let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright "
|
||||||
@ -198,7 +204,7 @@ function! s:Creator._createTreeWin()
|
|||||||
call self._setCommonBufOptions()
|
call self._setCommonBufOptions()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator._isBufHidden(nr) {{{1
|
" FUNCTION: s:Creator._isBufHidden(nr) {{{1
|
||||||
function! s:Creator._isBufHidden(nr)
|
function! s:Creator._isBufHidden(nr)
|
||||||
redir => bufs
|
redir => bufs
|
||||||
silent ls!
|
silent ls!
|
||||||
@ -207,7 +213,7 @@ function! s:Creator._isBufHidden(nr)
|
|||||||
return bufs =~ a:nr . '..h'
|
return bufs =~ a:nr . '..h'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.New() {{{1
|
" FUNCTION: s:Creator.New() {{{1
|
||||||
function! s:Creator.New()
|
function! s:Creator.New()
|
||||||
let newCreator = copy(self)
|
let newCreator = copy(self)
|
||||||
return newCreator
|
return newCreator
|
||||||
@ -232,8 +238,8 @@ function! s:Creator._nextBufferNumber()
|
|||||||
return s:Creator._NextBufNum
|
return s:Creator._NextBufNum
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator._pathForString(str) {{{1
|
" FUNCTION: s:Creator._pathForString(str) {{{1
|
||||||
"find a bookmark or adirectory for the given string
|
" find a bookmark or adirectory for the given string
|
||||||
function! s:Creator._pathForString(str)
|
function! s:Creator._pathForString(str)
|
||||||
let path = {}
|
let path = {}
|
||||||
if g:NERDTreeBookmark.BookmarkExistsFor(a:str)
|
if g:NERDTreeBookmark.BookmarkExistsFor(a:str)
|
||||||
@ -278,7 +284,7 @@ function! s:Creator._removeTreeBufForTab()
|
|||||||
unlet t:NERDTreeBufName
|
unlet t:NERDTreeBufName
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator._setCommonBufOptions() {{{1
|
" FUNCTION: s:Creator._setCommonBufOptions() {{{1
|
||||||
function! s:Creator._setCommonBufOptions()
|
function! s:Creator._setCommonBufOptions()
|
||||||
"throwaway buffer options
|
"throwaway buffer options
|
||||||
setlocal noswapfile
|
setlocal noswapfile
|
||||||
@ -310,7 +316,7 @@ function! s:Creator._setCommonBufOptions()
|
|||||||
setlocal filetype=nerdtree
|
setlocal filetype=nerdtree
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator._setupStatusline() {{{1
|
" FUNCTION: s:Creator._setupStatusline() {{{1
|
||||||
function! s:Creator._setupStatusline()
|
function! s:Creator._setupStatusline()
|
||||||
if g:NERDTreeStatusline != -1
|
if g:NERDTreeStatusline != -1
|
||||||
let &l:statusline = g:NERDTreeStatusline
|
let &l:statusline = g:NERDTreeStatusline
|
||||||
@ -335,19 +341,19 @@ function! s:Creator._tabpagevar(tabnr, var)
|
|||||||
return v
|
return v
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.ToggleTabTree(dir) {{{1
|
" FUNCTION: s:Creator.ToggleTabTree(dir) {{{1
|
||||||
function! s:Creator.ToggleTabTree(dir)
|
function! s:Creator.ToggleTabTree(dir)
|
||||||
let creator = s:Creator.New()
|
let creator = s:Creator.New()
|
||||||
call creator.toggleTabTree(a:dir)
|
call creator.toggleTabTree(a:dir)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:Creator.toggleTabTree(dir) {{{1
|
" FUNCTION: s:Creator.toggleTabTree(dir) {{{1
|
||||||
"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is
|
" Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is
|
||||||
"closed it is restored or initialized (if it doesnt exist)
|
" closed it is restored or initialized (if it doesnt exist)
|
||||||
"
|
"
|
||||||
"Args:
|
" Args:
|
||||||
"dir: the full path for the root node (is only used if the NERD tree is being
|
" dir: the full path for the root node (is only used if the NERD tree is being
|
||||||
"initialized.
|
" initialized.
|
||||||
function! s:Creator.toggleTabTree(dir)
|
function! s:Creator.toggleTabTree(dir)
|
||||||
if g:NERDTree.ExistsForTab()
|
if g:NERDTree.ExistsForTab()
|
||||||
if !g:NERDTree.IsOpen()
|
if !g:NERDTree.IsOpen()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user