" Vundle plugins {{{ " ============================================================================ " set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " let Vundle manage Vundle, required Plugin 'gmarik/Vundle.vim' Plugin 'tpope/vim-fugitive' Plugin 'ctrlpvim/ctrlp.vim' Plugin 'bling/vim-airline' Plugin 'scrooloose/nerdtree' Plugin 'Shougo/vimproc.vim' Plugin 'tpope/vim-markdown' Plugin 'altercation/vim-colors-solarized' Plugin 'chriskempson/base16-vim' Plugin 'Valloric/YouCompleteMe' Plugin 'junegunn/vim-easy-align' "Plugin 'LaTeX-Box-Team/LaTeX-Box' Plugin 'chase/vim-ansible-yaml' Plugin 'rust-lang/rust.vim' Plugin 'easymotion/vim-easymotion' " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " Put your non-Plugin stuff after this line " Configuring NerdTree noremap :NERDTreeToggle let NERDTreeIgnore=[ \ ".*\\.class$", \ ".*\\.o$", \ ".*\\.hi$", \ ".*\\.pyc$" \ ] let mapleader=';' " Configuring ctrlp nnoremap l :CtrlP noremap :CtrlP nnoremap o :CtrlPBuffer noremap :CtrlPBuffer let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'] " Configuring Airline let g:airline_powerline_fonts=1 " Configuring YouCompleteMe let g:ycm_global_ycm_extra_conf = '~/.vim/ycm_extra_conf.py' let g:ycm_server_keep_logfiles = 1 let g:ycm_server_log_level = 'debug' set completeopt=menu " Loading Solarized set t_Co=256 let g:solarized_termcolors=256 let g:solarized_contrast="normal" let g:solarized_underline=0 let g:solarized_termtrans=1 " Loaing base16 let base16colorspace=256 " Configuring LaTeX-Box "let g:LatexBox_Folding = 1 " Configuring EasyMotion let g:EasyMotion_do_mapping = 0 " Disable default mappings nmap w (easymotion-w) nmap s (easymotion-s) nmap j (easymotion-j) nmap k (easymotion-k) " }}} " General Options {{{ " ================================================================== " syntax enable set background=dark colorscheme desert silent! colorscheme base16-3024 " conditional colorscheme set number " line numbers on the right side set showcmd " show the commands while typing set splitright " open new splits on the right set splitbelow " open new splits below set autoread " autoreload file on change set scrolloff=8 " keep the cursor 8 lines away from the top/bottom set ruler " show the lines/% bottomright set encoding=utf-8 " set default encoding set laststatus=2 " always show the status line " wrap lines at 70 characters set formatprg=par\ -w70 set formatoptions=tcrqnlj set textwidth=70 " indentation set tabstop=4 " tab is 4 width set softtabstop=4 " tab is 4 width set shiftwidth=4 " for use with > and < set expandtab " tab key puts spaces set autoindent " in case filetype indent is wrong filetype plugin indent on set list " if tabs, show them with 2 spaces set listchars=tab:\·\ ,trail:· " display tabs with a leading \cdot " trailing whitespace looks like \cdot " Don't save tmp/swap files in the current directory. set directory=~/.vim/tmp/swap/ set backupdir=~/.vim/tmp/backup/ " Learning to use decent vim. noremap noremap noremap noremap " Keep selection after indenting vnoremap > >gv vnoremap < " center screen with noremap zz " rewrite file with sudo cmap w!! w !sudo tee % >/dev/null " paste the clipboard noremap p :r!xclip -sel c -o noremap y :w !xclip -sel c " Unfold everything upon opening a new file "autocmd BufRead * normal zR set foldlevelstart=2 " }}} " Filetype specific configuration. {{{ " ================================================================== " " Haskell {{{ " ------------------------------------------------------------------ " autocmd FileType haskell call HaskellHook() autocmd BufRead,BufNewFile *.lhs call HaskellHook() autocmd BufRead,BufNewFile *.hsc set filetype=haskell function HaskellHook() " Ghci shortcut noremap :!ghci -Wall '%' " Haskell Styling noremap :%!stylish-haskell noremap :!hlint % " Vim-hoogle noremap :Hoogle noremap :HoogleClose endfunction " }}} " Java {{{ " ------------------------------------------------------------------ " autocmd FileType java call JavaHook() function JavaHook() " Javac shortcut noremap :!javac % " Java shortcut noremap :!java %:r endfunction " }}} " Shell {{{ " ------------------------------------------------------------------ " autocmd FileType sh call ShellHook() function ShellHook() " Execute in subshell noremap :!bash --init-file ./% endfunction " }}} " C {{{ " ------------------------------------------------------------------ " autocmd FileType c call CHook() function CHook() " gcc shortcut noremap :!gcc % -o %:r " execute noremap :!./%:r endfunction " }}} " JavaScript {{{ " ------------------------------------------------------------------ " autocmd FileType javascript call JavaScriptHook() function JavaScriptHook() setlocal tabstop=2 setlocal shiftwidth=2 setlocal softtabstop=2 endfunction " }}} " Ruby {{{ " ------------------------------------------------------------------ " autocmd FileType ruby call RubyHook() autocmd FileType eruby call RubyHook() function RubyFold(lnum) if getline(a:lnum) =~ '^\s*def\s' || getline(a:lnum) =~ '^\s*class\s' || getline(a:lnum) =~ '^\s*module\s' return indent(a:lnum) / 2 + 1 endif if getline(a:lnum) =~ '^\s*end' return indent(a:lnum) / 2 + 1 endif if getline(a:lnum - 1) =~ '^\s*end' return indent(a:lnum - 1) / 2 endif return '=' endfunction function RubyFoldText() return getline(v:foldstart) . ' +' endfunction function RubyHook() setlocal tabstop=2 setlocal shiftwidth=2 set softtabstop=2 noremap :!irb -Ilib -r ./% " Use rake as makeprogram set makeprg=rake " Folding set foldmethod=expr set foldexpr=RubyFold(v:lnum) set foldtext=RubyFoldText() endfunction " }}} " R {{{ " ------------------------------------------------------------------ " autocmd FileType r call RHook() function RHook() " Interactive shortcut noremap :'<,'>w !R --no-save --interactive endfunction " }}} " Latex {{{ " ------------------------------------------------------------------ " autocmd FileType tex call TexHook() function TexHook() setlocal tabstop=2 setlocal shiftwidth=2 setlocal softtabstop=2 " setlocal foldmethod=marker " Make a pdf noremap :!pdflatex -shell-escape '%' noremap :!rifle '%:p:r.pdf' endfunction " }}} " Markdown {{{ " ------------------------------------------------------------------ " autocmd Filetype markdown call MarkdownHook() function MarkdownHook() " Making and showing html noremap :!markdown '%:p' > '%:p:r.html' noremap :!rifle '%:p:r.html' setlocal textwidth=0 setlocal wrapmargin=0 setlocal colorcolumn=0 setlocal wrap setlocal linebreak setlocal nolist endfunction " }}} " Python {{{ " ------------------------------------------------------------------ " autocmd FileType python call PythonHook() function Pylint() silent !pylint --reports=n --output-format=parseable '%' > errors.err 2> /dev/null cfile silent !rm errors.err redraw! copen endfunction function PythonFold(lnum) if getline(a:lnum-1) =~ '^\s*def\s' || getline(a:lnum-1) =~ '^\s*class\s' return indent(a:lnum-1) / 4 + 1 endif if getline(a:lnum) =~ '^\s*def\s' || getline(a:lnum) =~ '^\s*class\s' return indent(a:lnum) / 4 endif if getline(a:lnum+1) =~ '^\s*def\s' || getline(a:lnum+1) =~ '^\s*class\s' return indent(a:lnum + 1) / 4 endif if getline(a:lnum+1) =~ '^\S.*$' return '0' endif return '=' endfunction function PythonFoldText() return repeat(' ', indent(v:foldstart - 1) + 4) . '+' endfunction function PythonHook() set formatoptions+=rq noremap :!python -i '%' noremap :call Pylint() " Uncomment to fold. Slows down SuperTab extremely set foldmethod=expr set foldexpr=PythonFold(v:lnum) set foldtext=PythonFoldText() endfunction " }}} " }}} " vim: foldmethod=marker