" ----------------------------------------------------------------------------
" vundle essentials
" ----------------------------------------------------------------------------

set nocompatible
filetype off

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim

call vundle#begin()
Plugin 'VundleVim/Vundle.vim'

" ADD PLUGINS HERE
Plugin 'jiangmiao/auto-pairs'
Plugin 'preservim/nerdtree'

call vundle#end()

filetype plugin indent on

" ----------------------------------------------------------------------------
" basic essentials
" ----------------------------------------------------------------------------

" don't make vim vi compatible (if not set you miss out on a lot of features!)
" you'll see this option set in most configuration files found online
set nocompatible

" enable filetype recognition plus indent and plugin (pretty much mandatory)
filetype plugin indent on    " required

" enable syntax highlighting
syntax on

" backspace can be a tricky thing and this setting make it work a lot better
set backspace=indent,eol,start

" when tab completing on the expert line you don't want to miss out on EDIT vs
" edit or nerdtree vs NERDTree and this setting ignores case completely
set ignorecase

" highlight your search patterns (very handy when building regexes)
set hlsearch

" highlight the search pattern as-you-go (tremendously helpful when
" constructing regexes)
set incsearch

" always show a status line at the bottom of your vim which shows some basic 
" information about the file, which line you're at etc
set laststatus=2

" show files in statusbar when opening via expert mode
set wildmenu

" also show all possible expert mode commands in the statusline
set wildmode=full

" reverse numbering (in the sideline) so you don't have to manually count how
" many lines you have to yank
set rnu

" it's also nice to still have your absolute line number in the sideline
set nu

" can do copy paste from the clipboard
set clipboard=unnamedplus

" automatically save buffers
set autowrite
set autowriteall 

" hide the documentation popup
set completeopt-=preview

" ----------------------------------------------------------------------------
" plugin configuration
" ----------------------------------------------------------------------------

" NERDTree
" --------

" map a keyboard shortcut to show and hide NERDTree
nnoremap <C-t> :NERDTreeToggle<CR>

" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
