colorscheme-statusline.vim 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. " Colour Scheme & Status Line
  2. "
  3. " Available colour schemes:
  4. " - solarized
  5. " - neonwave
  6. " - alduin
  7. " Fix wrong background colour in tmux, when using 256 colours, and when vim
  8. " changes the background colour. http://sunaku.github.io/vim-256color-bce.html
  9. set t_ut=
  10. " The colour command that was last run.
  11. let g:current_colour = expand('~/dotfiles/vim/current-colour')
  12. " Status line defaults.
  13. let g:airline#extensions#wordcount#filetypes = '\vhelp|markdown|rst|org|pandoc'
  14. set noshowmode " hide modes e.g. --INSERT-- with themed status lines.
  15. " Toggle colour schemes.
  16. command! Dark set background=light
  17. \| colorscheme neonwave
  18. \| call StatusTheme('surarken')
  19. \| call writefile(['Dark'], g:current_colour)
  20. command! Light set background=light
  21. \| colorscheme vanilla-cake
  22. \| call StatusTheme('papercolor')
  23. \| call writefile(['Light'], g:current_colour)
  24. function! StatusTheme(name)
  25. " Airline functions are not available at vim start.
  26. if exists(':AirlineTheme')
  27. execute 'AirlineTheme' a:name
  28. else
  29. let g:airline_theme = a:name
  30. endif
  31. endfunction
  32. " General colour scheme overrides.
  33. autocmd ColorScheme * call CustomHighlights()
  34. function! CustomHighlights()
  35. " Mute spellcheck highlighting.
  36. " Highlights must be cleared first, or `link` will fail.
  37. highlight clear SpellBad | highlight SpellBad cterm=underline
  38. highlight clear SpellCap | highlight link SpellCap SpellBad
  39. highlight clear SpellLocal | highlight link SpellLocal SpellBad
  40. highlight clear SpellRare | highlight link SpellRare SpellBad
  41. endfunction
  42. " Use the last chosen colour scheme or default to a dark colorscheme.
  43. if filereadable(expand(g:current_colour))
  44. execute 'source' g:current_colour
  45. else
  46. Dark
  47. endif