1
0

vimrc 4.6 KB

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