2013-01-05 09:08:06 +08:00
|
|
|
if exists("g:loaded_nerdtree_autoload")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let g:loaded_nerdtree_autoload = 1
|
|
|
|
|
|
|
|
function! nerdtree#version()
|
|
|
|
return '4.2.0'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" SECTION: General Functions {{{1
|
|
|
|
"============================================================
|
|
|
|
|
|
|
|
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
|
|
|
|
"inits a secondary nerd tree in the current buffer if appropriate
|
|
|
|
function! nerdtree#checkForBrowse(dir)
|
|
|
|
if a:dir != '' && isdirectory(a:dir)
|
2013-01-09 08:41:34 +08:00
|
|
|
call g:NERDTreeCreator.CreateSecondary(a:dir)
|
2013-01-05 09:08:06 +08:00
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" FUNCTION: nerdtree#completeBookmarks(A,L,P) {{{2
|
|
|
|
" completion function for the bookmark commands
|
|
|
|
function! nerdtree#completeBookmarks(A,L,P)
|
|
|
|
return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"')
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
"FUNCTION: nerdtree#compareBookmarks(dir) {{{2
|
|
|
|
function! nerdtree#compareBookmarks(first, second)
|
|
|
|
return a:first.compareTo(a:second)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
"FUNCTION: nerdtree#compareNodes(dir) {{{2
|
|
|
|
function! nerdtree#compareNodes(n1, n2)
|
|
|
|
return a:n1.path.compareTo(a:n2.path)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" FUNCTION: nerdtree#deprecated(func, [msg]) {{{2
|
|
|
|
" Issue a deprecation warning for a:func. If a second arg is given, use this
|
|
|
|
" as the deprecation message
|
|
|
|
function! nerdtree#deprecated(func, ...)
|
|
|
|
let msg = a:0 ? a:func . ' ' . a:1 : a:func . ' is deprecated'
|
|
|
|
|
|
|
|
if !exists('s:deprecationWarnings')
|
|
|
|
let s:deprecationWarnings = {}
|
|
|
|
endif
|
|
|
|
if !has_key(s:deprecationWarnings, a:func)
|
|
|
|
let s:deprecationWarnings[a:func] = 1
|
|
|
|
echomsg msg
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" FUNCTION: nerdtree#exec(cmd) {{{2
|
|
|
|
" same as :exec cmd but eventignore=all is set for the duration
|
|
|
|
function! nerdtree#exec(cmd)
|
|
|
|
let old_ei = &ei
|
|
|
|
set ei=all
|
|
|
|
exec a:cmd
|
|
|
|
let &ei = old_ei
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" FUNCTION: nerdtree#has_opt(options, name) {{{2
|
|
|
|
function! nerdtree#has_opt(options, name)
|
|
|
|
return has_key(a:options, a:name) && a:options[a:name] == 1
|
|
|
|
endfunction
|
|
|
|
|
2013-04-14 03:32:25 +08:00
|
|
|
" FUNCTION: nerdtree#loadClassFiles() {{{2
|
|
|
|
function! nerdtree#loadClassFiles()
|
|
|
|
runtime lib/nerdtree/path.vim
|
|
|
|
runtime lib/nerdtree/menu_controller.vim
|
|
|
|
runtime lib/nerdtree/menu_item.vim
|
|
|
|
runtime lib/nerdtree/key_map.vim
|
|
|
|
runtime lib/nerdtree/bookmark.vim
|
|
|
|
runtime lib/nerdtree/tree_file_node.vim
|
|
|
|
runtime lib/nerdtree/tree_dir_node.vim
|
|
|
|
runtime lib/nerdtree/opener.vim
|
|
|
|
runtime lib/nerdtree/creator.vim
|
2014-07-06 03:51:21 +08:00
|
|
|
runtime lib/nerdtree/flag_set.vim
|
2014-07-08 05:59:28 +08:00
|
|
|
runtime lib/nerdtree/nerdtree.vim
|
|
|
|
runtime lib/nerdtree/ui.vim
|
2014-07-18 03:16:57 +08:00
|
|
|
runtime lib/nerdtree/event.vim
|
|
|
|
runtime lib/nerdtree/notifier.vim
|
2013-04-14 03:32:25 +08:00
|
|
|
endfunction
|
|
|
|
|
2013-01-05 09:08:06 +08:00
|
|
|
" FUNCTION: nerdtree#postSourceActions() {{{2
|
|
|
|
function! nerdtree#postSourceActions()
|
|
|
|
call g:NERDTreeBookmark.CacheBookmarks(0)
|
2014-07-08 02:36:34 +08:00
|
|
|
call nerdtree#ui_glue#createDefaultBindings()
|
2013-01-05 09:08:06 +08:00
|
|
|
|
|
|
|
"load all nerdtree plugins
|
|
|
|
runtime! nerdtree_plugin/**/*.vim
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
"FUNCTION: nerdtree#runningWindows(dir) {{{2
|
|
|
|
function! nerdtree#runningWindows()
|
|
|
|
return has("win16") || has("win32") || has("win64")
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" SECTION: View Functions {{{1
|
|
|
|
"============================================================
|
2014-07-08 03:12:05 +08:00
|
|
|
|
2013-01-05 09:08:06 +08:00
|
|
|
"FUNCTION: nerdtree#echo {{{2
|
|
|
|
"A wrapper for :echo. Appends 'NERDTree:' on the front of all messages
|
|
|
|
"
|
|
|
|
"Args:
|
|
|
|
"msg: the message to echo
|
|
|
|
function! nerdtree#echo(msg)
|
|
|
|
redraw
|
|
|
|
echomsg "NERDTree: " . a:msg
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
"FUNCTION: nerdtree#echoError {{{2
|
|
|
|
"Wrapper for nerdtree#echo, sets the message type to errormsg for this message
|
|
|
|
"Args:
|
|
|
|
"msg: the message to echo
|
|
|
|
function! nerdtree#echoError(msg)
|
|
|
|
echohl errormsg
|
|
|
|
call nerdtree#echo(a:msg)
|
|
|
|
echohl normal
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
"FUNCTION: nerdtree#echoWarning {{{2
|
|
|
|
"Wrapper for nerdtree#echo, sets the message type to warningmsg for this message
|
|
|
|
"Args:
|
|
|
|
"msg: the message to echo
|
|
|
|
function! nerdtree#echoWarning(msg)
|
|
|
|
echohl warningmsg
|
|
|
|
call nerdtree#echo(a:msg)
|
|
|
|
echohl normal
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
"FUNCTION: nerdtree#putCursorOnBookmarkTable(){{{2
|
|
|
|
"Places the cursor at the top of the bookmarks table
|
|
|
|
function! nerdtree#putCursorOnBookmarkTable()
|
|
|
|
if !b:NERDTreeShowBookmarks
|
|
|
|
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
|
|
|
|
endif
|
|
|
|
|
|
|
|
if g:NERDTreeMinimalUI
|
|
|
|
return cursor(1, 2)
|
|
|
|
endif
|
|
|
|
|
2014-07-08 05:59:28 +08:00
|
|
|
let rootNodeLine = b:NERDTree.ui.getRootLineNum()
|
2013-01-05 09:08:06 +08:00
|
|
|
|
|
|
|
let line = 1
|
|
|
|
while getline(line) !~# '^>-\+Bookmarks-\+$'
|
|
|
|
let line = line + 1
|
|
|
|
if line >= rootNodeLine
|
|
|
|
throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table"
|
|
|
|
endif
|
|
|
|
endwhile
|
|
|
|
call cursor(line, 2)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
"FUNCTION: nerdtree#putCursorInTreeWin(){{{2
|
|
|
|
"Places the cursor in the nerd tree window
|
|
|
|
function! nerdtree#putCursorInTreeWin()
|
2015-05-02 21:44:32 +08:00
|
|
|
call g:NERDTree.MustBeOpen()
|
2015-05-02 21:31:57 +08:00
|
|
|
call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w")
|
2013-01-05 09:08:06 +08:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
"FUNCTION: nerdtree#renderBookmarks {{{2
|
|
|
|
function! nerdtree#renderBookmarks()
|
|
|
|
|
|
|
|
if g:NERDTreeMinimalUI == 0
|
|
|
|
call setline(line(".")+1, ">----------Bookmarks----------")
|
|
|
|
call cursor(line(".")+1, col("."))
|
|
|
|
endif
|
|
|
|
|
|
|
|
for i in g:NERDTreeBookmark.Bookmarks()
|
|
|
|
call setline(line(".")+1, i.str())
|
|
|
|
call cursor(line(".")+1, col("."))
|
|
|
|
endfor
|
|
|
|
|
|
|
|
call setline(line(".")+1, '')
|
|
|
|
call cursor(line(".")+1, col("."))
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
"FUNCTION: nerdtree#renderView {{{2
|
|
|
|
function! nerdtree#renderView()
|
2014-07-08 05:59:28 +08:00
|
|
|
call b:NERDTree.render()
|
2013-01-05 09:08:06 +08:00
|
|
|
endfunction
|
|
|
|
"
|
|
|
|
"FUNCTION: nerdtree#stripMarkupFromLine(line, removeLeadingSpaces){{{2
|
|
|
|
"returns the given line with all the tree parts stripped off
|
|
|
|
"
|
|
|
|
"Args:
|
|
|
|
"line: the subject line
|
|
|
|
"removeLeadingSpaces: 1 if leading spaces are to be removed (leading spaces =
|
|
|
|
"any spaces before the actual text of the node)
|
|
|
|
function! nerdtree#stripMarkupFromLine(line, removeLeadingSpaces)
|
|
|
|
let line = a:line
|
|
|
|
"remove the tree parts and the leading space
|
2015-05-02 19:42:59 +08:00
|
|
|
let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","")
|
2013-01-05 09:08:06 +08:00
|
|
|
|
|
|
|
"strip off any read only flag
|
|
|
|
let line = substitute (line, ' \[RO\]', "","")
|
|
|
|
|
|
|
|
"strip off any bookmark flags
|
|
|
|
let line = substitute (line, ' {[^}]*}', "","")
|
|
|
|
|
|
|
|
"strip off any executable flags
|
|
|
|
let line = substitute (line, '*\ze\($\| \)', "","")
|
|
|
|
|
2014-07-05 07:29:45 +08:00
|
|
|
"strip off any generic flags
|
|
|
|
let line = substitute (line, '\[[^]]*\]', "","")
|
|
|
|
|
2013-01-05 09:08:06 +08:00
|
|
|
let wasdir = 0
|
|
|
|
if line =~# '/$'
|
|
|
|
let wasdir = 1
|
|
|
|
endif
|
|
|
|
let line = substitute (line,' -> .*',"","") " remove link to
|
|
|
|
if wasdir ==# 1
|
|
|
|
let line = substitute (line, '/\?$', '/', "")
|
|
|
|
endif
|
|
|
|
|
|
|
|
if a:removeLeadingSpaces
|
|
|
|
let line = substitute (line, '^ *', '', '')
|
|
|
|
endif
|
|
|
|
|
|
|
|
return line
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" vim: set sw=4 sts=4 et fdm=marker:
|