vimrc 5.0 KB

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