vimrc 5.6 KB

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