colorscheme-statusline.vim 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. " Colour Scheme & Status Line
  2. "
  3. " Available colour schemes:
  4. " - solarized
  5. " - neonwave
  6. " Fix wrong background colour in tmux, when using 256 colours, and when vim
  7. " changes the background colour. http://sunaku.github.io/vim-256color-bce.html
  8. set t_ut=
  9. " The colour command that was last run.
  10. let g:current_colour = expand('~/dotfiles/vim/current-colour')
  11. " Mark if the proper solarized colour palette mode should be used.
  12. let g:solarized_palette = expand('~/dotfiles/vim/use-solarized-palette')
  13. " Status line defaults.
  14. let g:airline#extensions#wordcount#filetypes = '\vhelp|markdown|rst|org|pandoc'
  15. set noshowmode " hide modes e.g. --INSERT-- with themed status lines.
  16. " Toggle colour schemes.
  17. command! Alduin let g:alduin_Contract_Vampirism = 1
  18. \| colorscheme alduin
  19. \| call StatusTheme('ubaryd')
  20. \| call writefile(['Alduin'], g:current_colour)
  21. command! Dark set background=dark
  22. \| colorscheme solarized
  23. \| call StatusTheme('powerlineish')
  24. \| highlight SignColumn ctermbg=235
  25. \| call writefile(['Dark'], g:current_colour)
  26. command! Light set background=light
  27. \| colorscheme solarized
  28. \| call StatusTheme('papercolor')
  29. \| call writefile(['Light'], g:current_colour)
  30. command! Neon set background=light
  31. \| colorscheme neonwave
  32. \| call StatusTheme('surarken')
  33. \| call writefile(['Neon'], g:current_colour)
  34. " Toggle Solarized Colour Palette Degradation.
  35. command! SolarizedColourProper execute 'silent !touch' g:solarized_palette
  36. \| let g:solarized_termcolors=16
  37. \| execute 'source' g:current_colour
  38. command! SolarizedColourDegraded execute 'silent !rm' g:solarized_palette
  39. \| let g:solarized_termcolors=256
  40. \| execute 'source' g:current_colour
  41. function! StatusTheme(name)
  42. " Airline functions are not available at vim start.
  43. if exists(':AirlineTheme')
  44. execute 'AirlineTheme' a:name
  45. else
  46. let g:airline_theme = a:name
  47. endif
  48. endfunction
  49. " General colour scheme overrides.
  50. autocmd ColorScheme * call CustomHighlights()
  51. function! CustomHighlights()
  52. " Mute spellcheck highlighting.
  53. " Highlights must be cleared first, or `link` will fail.
  54. highlight clear SpellBad | highlight SpellBad cterm=underline
  55. highlight clear SpellCap | highlight link SpellCap SpellBad
  56. highlight clear SpellLocal | highlight link SpellLocal SpellBad
  57. highlight clear SpellRare | highlight link SpellRare SpellBad
  58. endfunction
  59. " Default to degraded solarized to avoid bad colours on new machines.
  60. if !filereadable(g:solarized_palette)
  61. let g:solarized_termcolors=256
  62. endif
  63. " Use the last chosen colour scheme or default to a dark colorscheme.
  64. if filereadable(expand(g:current_colour))
  65. execute 'source' g:current_colour
  66. else
  67. Alduin
  68. endif