1
0

vimrc 5.5 KB

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