" github.com/samnang/dotfiles/blob/master/vimrc
" http://nvie.com/posts/how-i-boosted-my-vim/
" http://learnvimscriptthehardway.stevelosh.com/chapters/52.html
" May install in the future:
" Git wrapper, similar to magit: 'https://github.com/tpope/vim-fugitive'

let mapleader="," " set leader early as otherwise it wouldn't work

" ----- NeoBundle -----
let reinstall=0
if !filereadable(expand('~/.vim/bundle/neobundle.vim/README.md'))
	" if vundle isn't currently installed
	silent !git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
	let reinstall=1
endif

if has('vim_starting')
	if &compatible
		set nocompatible " Be iMproved
	endif

	set runtimepath+=/home/xramses/.vim/bundle/neobundle.vim/
endif

call neobundle#begin(expand('/home/xramses/.vim/bundle'))

" Let NeoBundle manage NeoBundle
NeoBundleFetch 'Shougo/neobundle.vim'

" Add or remove your Bundles here:
NeoBundle 'Shougo/vimproc.vim', {
\ 'build' : {
\     'windows' : 'tools\\update-dll-mingw',
\     'cygwin' : 'make -f make_cygwin.mak',
\     'mac' : 'make -f make_mac.mak',
\     'linux' : 'make',
\     'unix' : 'gmake',
\    },
\ }
NeoBundle 'Lokaltog/vim-distinguished'
NeoBundle 'xolox/vim-reload'
NeoBundle 'xolox/vim-misc'
NeoBundle 'Shougo/unite.vim'
NeoBundle 'bling/vim-airline'
NeoBundle 'scrooloose/syntastic'
NeoBundle 'scrooloose/nerdcommenter'
NeoBundle 'tpope/vim-surround'
"NeoBundle 'msanders/snipmate.vim'
NeoBundle 'davidhalter/jedi-vim'
NeoBundle 'wting/rust.vim'
"NeoBundle 'godlygeek/tabular'
"NeoBundle 'plasticboy/vim-markdown'

call neobundle#end()

filetype plugin indent on

" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck

" ----- general settings -----
set encoding=utf-8
set ff=unix
set number
set clipboard=unnamedplus
set showmatch " show matching brackets

set incsearch " Find as you type search
set hlsearch " Highlight search terms
set ignorecase " Case-insensitive searching.
set smartcase " But case-sensitive if expression contains a capital letter.

set history=1000 " remember more commands and search history
set undolevels=1000 " use many levels of undo

set nobackup
set noswapfile

set tabstop=4
set shiftwidth=4
set textwidth=80
set cc=81

set list
set listchars=tab:>-,trail:~

map <silent> <leader>1 :diffget 2<CR> :diffupdate<CR>
map <silent> <leader>2 :diffget 3<CR> :diffupdate<CR>
map <silent> <leader>3 :diffget 4<CR> :diffupdate<CR>

autocmd InsertEnter * :let @/=""
autocmd InsertLeave * :let @/=""

"set expandtab

map Q @
map <S-m> :tabprevious<CR>
map m :tabnext<CR>

syntax enable
set background=dark
colorscheme distinguished

" remove trailing whitespaces on save
autocmd BufWritePre * :%s/\s\+$//e

" Markdown
autocmd BufRead,BufNew *.md set filetype=markdown

" airline
set laststatus=2
let g:airline_theme = 'powerlineish'
"let g:airline#extensions#tabline#enabled = 1 " make tabs look crazy
" only enable trailing whitespace checking
let g:airline#extensions#whitespace#checks = [ 'trailing' ]
let g:airline#extensions#syntastic#enabled = 0

" Unite
nnoremap <C-p> :Unite file_rec/async<cr>

if !has('clipboard')
	echo "Clipboard not supported!"
endif