colorscheme-statusline.vim 2.7 KB

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