Commits

Randy Stauner committed ec96d06

Lazy load nerdtree and configure netrw in its absence

Comments (0)

Files changed (1)

 nnoremap <F12> :GundoToggle<CR>
 
 " }}}
-" file browser
-Bundle 'scrooloose/nerdtree'
+" [ file browser ] {{{
+" [ netrw ] (built-in) {{{
+
+let g:netrw_home         = s:cache
+let g:netrw_liststyle    = 3  " Use tree-mode as default view
+let g:netrw_browse_split = 2  " vsplit
+let g:netrw_preview      = 1  " preview window shown in a vertical split
+let g:netrw_winsize      = 20 " inital size of new browser
+
+" }}}
+" [ nerdtree ] {{{
+
+let g:NERDTreeHijackNetrw     = 1
+let g:NERDTreeShowHidden      = 1
+let g:NERDTreeShowLineNumbers = 1
+let g:NERDTreeBookmarksFile   = s:cache . '/.NERDTreeBookmarks'
+
+LazyCommand -nargs=* -complete=dir NERDTree 'scrooloose/nerdtree'
+
+if g:NERDTreeHijackNetrw
+  " tell netrw to forget it
+  let g:loaded_netrwPlugin = "nerdtree!"
+  " fake netrw's augroup so nerdtree will replace it
+  augroup FileExplorer
+    au!
+    au BufEnter,VimEnter * if isdirectory(expand("<amatch>")) | unlet g:loaded_netrwPlugin | exe "NERDTree " . expand("<amatch>") | wincmd p | wincmd q | exe 'au! FileExplorer' | endif
+  augroup END
+endif
+
 "function StartUp() | if 0 == argc() | NERDTree | end | endfunction
 "autocmd VimEnter * call StartUp()
 
+" }}}
+" }}}
 " [ git ] {{{
 
 " get the latest fixes for vim files
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.