1
0

vimrc 5.0 KB

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