colorscheme-statusline.vim 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_powerline_fonts = 1
  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! Dark set background=dark
  19. \| colorscheme solarized
  20. \| call StatusTheme('powerlineish')
  21. \| highlight SignColumn ctermbg=235
  22. \| call writefile(['Dark'], g:current_colour)
  23. command! Light set background=light
  24. \| colorscheme solarized
  25. \| call StatusTheme('papercolor')
  26. \| call writefile(['Light'], g:current_colour)
  27. command! Neon set background=light
  28. \| colorscheme neonwave
  29. \| call StatusTheme('surarken')
  30. \| call writefile(['Neon'], g:current_colour)
  31. " Toggle Solarized Colour Palette Degradation.
  32. command! SolarizedColourPalette execute 'silent !touch' g:solarized_palette
  33. \| let g:solarized_termcolors=16
  34. \| execute 'source' g:current_colour
  35. command! SolarizedColourDegrade execute 'silent !rm' g:solarized_palette
  36. \| let g:solarized_termcolors=256
  37. \| execute 'source' g:current_colour
  38. function! StatusTheme(name)
  39. " Airline functions are not available at vim start.
  40. if exists(':AirlineTheme')
  41. execute 'AirlineTheme' a:name
  42. else
  43. let g:airline_theme = a:name
  44. endif
  45. endfunction
  46. " General colour scheme overrides.
  47. autocmd ColorScheme * call CustomHighlights()
  48. function! CustomHighlights()
  49. highlight ExtraWhitespace ctermbg=red guibg=red
  50. " Mute spellcheck highlighting.
  51. " Highlights must be cleared first, or `link` will fail.
  52. highlight clear SpellBad | highlight SpellBad cterm=underline
  53. highlight clear SpellCap | highlight link SpellCap SpellBad
  54. highlight clear SpellLocal | highlight link SpellLocal SpellBad
  55. highlight clear SpellRare | highlight link SpellRare SpellBad
  56. endfunction
  57. " Default to degraded solarized to avoid bad colours on new machines.
  58. if !filereadable(g:solarized_palette)
  59. let g:solarized_termcolors=256
  60. endif
  61. " Use the last chosen colour scheme or default to Dark.
  62. if filereadable(expand(g:current_colour))
  63. execute 'source' g:current_colour
  64. else
  65. Dark
  66. endif