vimrc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. " --------------
  2. " Vundle plugins
  3. " --------------
  4. set nocompatible
  5. filetype off
  6. set rtp+=~/.vim/bundle/Vundle.vim
  7. call vundle#begin()
  8. Plugin 'VundleVim/Vundle.vim'
  9. Plugin 'embear/vim-localvimrc'
  10. Plugin 'rust-lang/rust.vim'
  11. Plugin 'kongo2002/fsharp-vim'
  12. call vundle#end()
  13. filetype plugin indent on
  14. " -------------
  15. " General setup
  16. " -------------
  17. syntax enable
  18. " Automatically remove all trailing whitespace
  19. "autocmd BufWritePre * :%s/\s\+$//e
  20. " Source completion
  21. " Automatically open and close the popup menu / preview window
  22. "set omnifunc=syntaxcomplete#Complete
  23. "au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
  24. "set completeopt=menuone,menu,longest,preview
  25. set completeopt-=preview
  26. " ------
  27. " Layout
  28. " ------
  29. " try 256 color mode if envvar is set
  30. set t_Co=88
  31. if $TERM == 'xterm-256color' | set t_Co=256 | endif
  32. " Color scheme
  33. "set background=dark
  34. if &diff
  35. autocmd VimEnter * colorscheme blue
  36. else
  37. colorscheme darkspectrum
  38. runtime! plugin/guicolorscheme.vim
  39. autocmd VimEnter * GuiColorScheme darkspectrum
  40. endif
  41. set fileformats=unix " obviously...
  42. set ruler " show cursor location
  43. set modeline " read modelines
  44. set number " show line numbers
  45. set title " change the terminal's title
  46. set nocompatible " disable Vi-compatibility
  47. set laststatus=2 " always display filename
  48. set textwidth=80 " break line at 80 chars
  49. set scrolloff=5 " always keep current line five lines off the screen edge
  50. " Tabs are for heathens, we indent with spaces
  51. set expandtab smarttab
  52. set shiftwidth=4 tabstop=8 softtabstop=-1
  53. set autoindent copyindent
  54. set shiftround
  55. set backspace=indent,eol,start
  56. " Highlight tabs and trailing spaces
  57. set listchars=tab:\|\ ,trail:-
  58. set list
  59. " Don't give people epilepsy
  60. set visualbell t_vb= noerrorbells
  61. " Enable wildmenu for browsing files in :e command
  62. set wildmenu
  63. set wildcharm=<TAB>
  64. set wildignore=*.swp,*.bak,*.pyc,*.class,*.o,*.bc,*.old,*.cmi,*.cmx,*.aux
  65. " File explorer
  66. let g:netrw_liststyle=3 " Use tree-mode as default view
  67. let g:netrw_preview=1 " Preview window shown in a vsplit
  68. " ---------
  69. " Searching
  70. " ---------
  71. set history=1000 undolevels=1000
  72. set hlsearch " highlight search terms
  73. set incsearch " show search matches as you type
  74. set ignorecase smartcase " clever case sensitivity
  75. " ---------------------------
  76. " Mouse selection & scrolling
  77. " ---------------------------
  78. "set mouse=a
  79. map <ScrollWheelUp> <C-Y>
  80. map <S-ScrollWheelUp> <C-U>
  81. map <ScrollWheelDown> <C-E>
  82. map <S-ScrollWheelDown> <C-D>
  83. " -----------------------
  84. " Key bindings / commands
  85. " -----------------------
  86. " Use ';' instead of ':'
  87. nnoremap ; :
  88. " Use Q for formatting the current paragraph (or selection)
  89. vmap Q gq
  90. nmap Q gqap
  91. " Solve line jumping with long, wrapped lines (use [jk] for normal behaviour)
  92. nnoremap <down> gj
  93. nnoremap <up> gk
  94. " Window navigation with ctrl + [hjkl]
  95. map <C-h> <C-w>h
  96. map <C-j> <C-w>j
  97. map <C-k> <C-w>k
  98. map <C-l> <C-w>l
  99. " Shortcuts for common commands
  100. nmap <silent> ,/ :nohlsearch<CR>
  101. nmap <silent> ,mm :!make<CR>
  102. nmap <silent> ,ml :!make clean<CR>
  103. nmap <silent> ,mt :!make check<CR>
  104. nmap <silent> ,md :!make dist<CR>
  105. nmap <silent> ,mb :!make -B<CR>
  106. " Use w!! to save a file as root if opened with insufficient permissions
  107. cmap w!! w !sudo tee % >/dev/null
  108. " ---------------
  109. " Syntax / indent
  110. " ---------------
  111. " Some files only have 2 spaces indent
  112. autocmd FileType css,less,sass,html,ocaml,bib,llvm,tex,markdown set shiftwidth=2
  113. " Make pfd's readable
  114. autocmd BufReadPre *.pdf set ro nowrap
  115. autocmd BufReadPost *.pdf silent %!pdftotext "%" -nopgbrk -layout -q -eol unix -
  116. " Status line highlight
  117. highlight StatusLine ctermbg=black ctermfg=grey
  118. " Syntax highlighting by extension
  119. autocmd BufNewFile,BufRead *.cvc set filetype=c
  120. autocmd BufNewFile,BufRead *.fc set filetype=c
  121. autocmd BufNewFile,BufRead *.less set filetype=less
  122. autocmd BufNewFile,BufRead *.md set filetype=markdown
  123. autocmd BufNewFile,BufRead *.gv set filetype=dot
  124. autocmd BufNewFile,BufRead *.ll set filetype=llvm
  125. autocmd BufNewFile,BufRead *.inc set filetype=sh
  126. autocmd BufNewFile,BufRead *.mustache set filetype=html
  127. autocmd BufNewFile,BufRead *.ts set filetype=javascript
  128. autocmd BufNewFile,BufRead *.scss set filetype=sass
  129. autocmd BufNewFile,BufRead *.fc,*.fh set filetype=fennec
  130. autocmd BufNewFile,BufRead *.dis set filetype=dis
  131. " Highlight and underline badly spelled words when spellcheck is on
  132. highlight SpellBad guisp=#fcaf3e cterm=underline
  133. " Auto enable spellchecking for text-based files
  134. autocmd FileType tex,markdown setlocal spell nonu
  135. " 2 spaces for tabs in CSS/YAML
  136. autocmd FileType css,yaml set sw=2
  137. " -----------------------
  138. " Additional local config
  139. " -----------------------
  140. if filereadable($HOME . '/.vimrc_local')
  141. source ~/.vimrc_local
  142. endif