1
0

vimrc 4.7 KB

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