set nocompatible
filetype off

" Initialize Vundle
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" Base 
Plugin 'gmarik/Vundle.vim'
Plugin 'scrooloose/syntastic'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-commentary'

" UI
Plugin 'chriskempson/base16-vim'
Plugin 'itchyny/lightline.vim'
Plugin 'mike-hearn/base16-vim-lightline'
Plugin 'dracula/vim'

" Navigation
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'kien/ctrlp.vim'
Plugin 'mileszs/ack.vim'
Plugin 'scrooloose/nerdtree'

" Git
Plugin 'airblade/vim-gitgutter'
Plugin 'tpope/vim-fugitive'

" Language Plugins
Plugin 'derekwyatt/vim-scala'
Plugin 'hashivim/vim-hashicorp-tools'
Plugin 'fatih/vim-go'
Plugin 'mxw/vim-jsx'
Plugin 'pangloss/vim-javascript'
Plugin 'posva/vim-vue'
Plugin 'leafgarland/typescript-vim'
Plugin 'ianks/vim-tsx'

" --> PHP
Plugin 'tpope/vim-dispatch'             "| Optional
Plugin 'tpope/vim-projectionist'        "|
Plugin 'noahfrederick/vim-composer'     "|
Plugin 'noahfrederick/vim-laravel'
Plugin 'jwalton512/vim-blade'

call vundle#end()
filetype plugin indent on

" Custom Settings
" =====================================================================
syntax enable
set number
set tabstop=2
set shiftwidth=2
set expandtab
set backspace=indent,eol,start " backspace over everything in insert mode
set timeoutlen=1000 ttimeoutlen=0
set linespace=5
set tags=tags;/
set autoread

augroup reload_vimrc
  autocmd!
  autocmd bufwritepost $MYVIMRC nested source $MYVIMRC
augroup END
autocmd! reload_vimrc

" Color Settings
" =====================================================================
if has("gui_running")
  set t_Co=256
else
  let g:CSApprox_loaded = 1
end


"set background=dark
set guifont=FiraCode-Regular:h16
set laststatus=2

set termguicolors
"highlight Normal ctermbg=None

" Custom Settings to GUI (macvim or gvim)
" =====================================================================
set guioptions-=r
set guioptions-=L
set guioptions-=T

   "let base16colorspace=256

" iTerm Settings
" =====================================================================
if exists('$ITERM_PROFILE')
  " let base16colorspace=256
  if exists('$TMUX')
    let &t_SI = "\<Esc>[3 q"
    let &t_EI = "\<Esc>[0 q"
  else
    let &t_SI = "\<Esc>]50;CursorShape=1\x7"
    let &t_EI = "\<Esc>]50;CursorShape=0\x7"
  endif
endif

let g:dracula_colorterm = 0
let g:dracula_italic = 0
color dracula

 let g:gitgutter_override_sign_column_highlight = 0
" highlight LineNr ctermbg=None
" highlight SignColumn ctermbg=0
" highlight GitGutterAdd ctermbg=0
" highlight GitGutterChange ctermbg=0
" highlight GitGutterDelete ctermbg=0
" highlight GitGutterChangeDelete ctermbg=0

" Custom Mappings
" =====================================================================

" Simple mappings to split windows
nnoremap <silent> vv <C-w>v
nnoremap <silent> ss <C-w>s

" Plugin Settings
" =====================================================================

" Airline

let g:lightline = {
      \ 'colorscheme': 'dracula',
      \ }

" NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let g:NERDTreeWinSize = 30

map <C-\> :NERDTreeToggle<CR>
map <C-n> :NERDTreeFind<CR>

" CtrlP
let g:ctrlp_custom_ignore = '\v[\/](node_modules|bower_components|target|dist|vendor|ashes\/lib)|(\.(swp|ico|git|svn))$'

" Ack
let g:ackprg = 'ag --vimgrep'

set nobackup
set noswapfile

" vim-go
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1

" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']

let g:syntastic_mode_map = { "mode": "active",
                           \ "active_filetypes": [],
                           \ "passive_filetypes": ["scala"] }

" Custom mappings
autocmd FileType scala imap <buffer> => ⇒
autocmd FileType scala imap <buffer> <- ←
autocmd FileType scala imap <buffer> <* ← * <~
autocmd FileType scala imap <buffer> -> →
imap jk <Esc>

" Neocomplete
let g:neocomplete#enable_at_startup = 1

" Tagbar
let g:tagbar_type_go = {  
    \ 'ctagstype' : 'go',
    \ 'kinds'     : [
        \ 'p:package',
        \ 'i:imports:1',
        \ 'c:constants',
        \ 'v:variables',
        \ 't:types',
        \ 'n:interfaces',
        \ 'w:fields',
        \ 'e:embedded',
        \ 'm:methods',
        \ 'r:constructor',
        \ 'f:functions'
    \ ],
    \ 'sro' : '.',
    \ 'kind2scope' : {
        \ 't' : 'ctype',
        \ 'n' : 'ntype'
    \ },
    \ 'scope2kind' : {
        \ 'ctype' : 't',
        \ 'ntype' : 'n'
    \ },
    \ 'ctagsbin'  : 'gotags',
    \ 'ctagsargs' : '-sort -silent'
\ }

let g:syntastic_mode_map = { "mode": "active",
                           \ "active_filetypes": [],
                           \ "passive_filetypes": ["scala"] }
