configuration/vim/vimrc

337 lines
8.0 KiB
VimL
Raw Normal View History

2014-11-27 20:52:06 +01:00
" 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 'kien/ctrlp.vim'
Plugin 'bling/vim-airline'
Plugin 'scrooloose/nerdtree'
Plugin 'Shougo/vimproc.vim'
Plugin 'tpope/vim-markdown'
Plugin 'altercation/vim-colors-solarized'
2015-05-04 20:23:46 +02:00
Plugin 'chriskempson/base16-vim'
2014-12-21 22:57:35 +01:00
Plugin 'Valloric/YouCompleteMe'
2015-03-05 17:58:21 +01:00
Plugin 'junegunn/vim-easy-align'
2015-05-18 14:17:09 +02:00
Plugin 'LaTeX-Box-Team/LaTeX-Box'
2015-09-04 11:21:04 +02:00
Plugin 'chase/vim-ansible-yaml'
2014-11-27 20:52:06 +01:00
" 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 <C-t> :NERDTreeToggle<CR><CR>
let NERDTreeIgnore=[
\ ".*\\.class$",
\ ".*\\.o$",
\ ".*\\.hi$",
\ ".*\\.pyc$"
\ ]
" Configuring ctrlp
noremap <C-p> :CtrlP<CR>
noremap <C-o> :CtrlPBuffer<CR>
2015-03-05 17:58:21 +01:00
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
2014-11-27 20:52:06 +01:00
" Configuring Airline
let g:airline_powerline_fonts=1
" Configuring YouCompleteMe
2014-12-21 22:57:35 +01:00
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
2014-11-27 20:52:06 +01:00
" Loading Solarized
set t_Co=256
let g:solarized_termcolors=256
let g:solarized_contrast="normal"
let g:solarized_underline=0
2015-03-05 17:58:21 +01:00
let g:solarized_termtrans=1
2015-05-04 20:23:46 +02:00
" Loaing base16
let base16colorspace=256
2014-11-27 20:52:06 +01:00
2015-05-18 14:17:09 +02:00
" Configuring LaTeX-Box
let g:LatexBox_Folding = 1
2014-11-27 20:52:06 +01:00
" }}}
" General Options {{{
2015-03-05 17:58:21 +01:00
" ================================================================== "
2014-11-27 20:52:06 +01:00
2015-05-04 20:23:46 +02:00
syntax enable
set background=dark
2015-09-03 12:35:56 +02:00
colorscheme desert
silent! colorscheme base16-3024 " conditional colorscheme
2015-05-04 20:23:46 +02:00
2014-11-27 20:52:06 +01:00
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
2015-03-05 17:58:21 +01:00
" wrap lines at 70 characters
set formatprg=par\ -w70
2014-11-27 20:52:06 +01:00
set formatoptions=t
2015-03-05 17:58:21 +01:00
set textwidth=70
2014-11-27 20:52:06 +01:00
" 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 <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
2014-11-27 22:13:37 +01:00
" Keep selection after indenting
vnoremap > >gv
vnoremap < <gv
2014-11-27 20:52:06 +01:00
" some shortcuts
" go to start of line
noremap H ^
" go to end of line
noremap L g_
" fuck you K
noremap K <nop>
" center screen with <space>
noremap <space> zz
" rewrite file with sudo
cmap w!! w !sudo tee % >/dev/null
" paste the clipboard
noremap <C-b> :r!xclip -sel c -o<CR><CR>
2015-03-05 17:58:21 +01:00
noremap <C-m> :w !xclip -sel c<CR><CR>
2014-11-27 20:52:06 +01:00
2015-09-09 18:23:10 +02:00
" Unfold everything upon opening a new file
"autocmd BufRead * normal zR
set foldlevelstart=2
2014-11-27 20:52:06 +01:00
" }}}
" Filetype specific configuration. {{{
2015-03-05 17:58:21 +01:00
" ================================================================== "
2014-11-27 20:52:06 +01:00
" Haskell {{{
2015-03-05 17:58:21 +01:00
" ------------------------------------------------------------------ "
2014-11-27 20:52:06 +01:00
autocmd FileType haskell call HaskellHook()
autocmd BufRead,BufNewFile *.lhs call HaskellHook()
autocmd BufRead,BufNewFile *.hsc set filetype=haskell
function HaskellHook()
" Ghci shortcut
noremap <C-i> :!ghci -Wall '%'<CR><CR>
" Haskell Styling
noremap <C-c> :%!stylish-haskell<CR>
noremap <C-x> :!hlint %<CR>
" Vim-hoogle
noremap <C-h> :Hoogle
noremap <C-j> :HoogleClose<CR>
endfunction
" }}}
" Java {{{
2015-03-05 17:58:21 +01:00
" ------------------------------------------------------------------ "
2014-11-27 20:52:06 +01:00
autocmd FileType java call JavaHook()
function JavaHook()
" Javac shortcut
noremap <C-c> :!javac %<CR>
" Java shortcut
noremap <C-i> :!java %:r<CR>
endfunction
" }}}
2015-05-04 20:23:46 +02:00
" Shell {{{
" ------------------------------------------------------------------ "
autocmd FileType sh call ShellHook()
function ShellHook()
" Execute in subshell
noremap <C-i> :!bash ./%<CR>
endfunction
" }}}
2014-11-27 20:52:06 +01:00
" C {{{
2015-03-05 17:58:21 +01:00
" ------------------------------------------------------------------ "
2014-11-27 20:52:06 +01:00
autocmd FileType c call CHook()
function CHook()
" gcc shortcut
noremap <C-c> :!gcc % -o %:r<CR>
" execute
noremap <C-i> :!./%:r<CR>
endfunction
" }}}
" Ruby {{{
2015-03-05 17:58:21 +01:00
" ------------------------------------------------------------------ "
2014-11-27 20:52:06 +01:00
autocmd FileType ruby call RubyHook()
autocmd FileType eruby call RubyHook()
2015-09-09 18:23:10 +02:00
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
2014-11-27 20:52:06 +01:00
function RubyHook()
setlocal tabstop=2
setlocal shiftwidth=2
set softtabstop=2
noremap <C-i> :!irb -Ilib -r ./%<CR><CR>
" Use rake as makeprogram
set makeprg=rake
" Folding
2015-09-09 18:23:10 +02:00
set foldmethod=expr
set foldexpr=RubyFold(v:lnum)
set foldtext=RubyFoldText()
2014-11-27 20:52:06 +01:00
endfunction
" }}}
" R {{{
2015-03-05 17:58:21 +01:00
" ------------------------------------------------------------------ "
2014-11-27 20:52:06 +01:00
autocmd FileType r call RHook()
function RHook()
" Interactive shortcut
noremap <C-i> :'<,'>w !R --no-save --interactive<CR><CR>
endfunction
" }}}
" Latex {{{
2015-03-05 17:58:21 +01:00
" ------------------------------------------------------------------ "
2014-11-27 20:52:06 +01:00
autocmd FileType tex call TexHook()
function TexHook()
setlocal tabstop=2
setlocal shiftwidth=2
2015-01-20 20:49:09 +01:00
setlocal softtabstop=2
2015-05-18 14:17:09 +02:00
" setlocal foldmethod=marker
2014-11-27 20:52:06 +01:00
" Make a pdf
2015-05-27 14:10:44 +02:00
noremap <C-c> :!pdflatex -shell-escape '%'<CR><CR>
2015-10-08 15:33:27 +02:00
noremap <C-i> :!rifle '%:p:r.pdf'<CR><CR>
endfunction
" }}}
" Markdown {{{
2015-03-05 17:58:21 +01:00
" ------------------------------------------------------------------ "
autocmd Filetype markdown call MarkdownHook()
function MarkdownHook()
" Making and showing html
noremap <C-c> :!markdown '%:p' > '%:p:r.html'<CR><CR>
2015-10-08 15:33:27 +02:00
noremap <C-i> :!rifle '%:p:r.html'<CR><CR>
2014-11-27 20:52:06 +01:00
endfunction
" }}}
" Python {{{
2015-03-05 17:58:21 +01:00
" ------------------------------------------------------------------ "
2014-11-27 20:52:06 +01:00
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 <C-i> :!python -i '%'<CR><CR>
noremap <C-x> :call Pylint()<CR>
" Uncomment to fold. Slows down SuperTab extremely
set foldmethod=expr
set foldexpr=PythonFold(v:lnum)
set foldtext=PythonFoldText()
endfunction
" }}}
" }}}
" vim: foldmethod=marker