vimrc 5.0 KB

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