1
0

vimrc 5.1 KB

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