oldhope.vim 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. " ------------------------------------------------------------------------------
  2. " Author: j-tom
  3. " Source: https://github.com/j-tom/vim-old-hope
  4. " Note: Based on the 'An Old Hope' theme for Atom editor
  5. " (https://atom.io/themes/an-old-hope-syntax)
  6. " ------------------------------------------------------------------------------
  7. " Functions {{{
  8. " * Detect used t_Co
  9. function! oldhope#GetTCo()
  10. if exists("&t_Co")
  11. if (&t_Co > 255)
  12. let l:tCol=256
  13. elseif (&t_Co > 15 && &t_Co < 256)
  14. let l:tCol=16
  15. else
  16. let l:tCol=8
  17. endif
  18. else " no t_Co specified probably using GUI
  19. let l:tCol=256
  20. set t_Co=l:tCol
  21. endif
  22. return l:tCol
  23. endfunction
  24. " * Set highlighting for the given group
  25. function! oldhope#SetHi(grp, fg, bg, opt)
  26. let l:gFg = a:fg['GUI']
  27. let l:gBg = a:bg['GUI']
  28. let l:gOpt = a:opt['GUI']
  29. let l:tFg = a:fg['TERM']
  30. let l:tBg = a:bg['TERM']
  31. let l:tOpt = a:opt['TERM']
  32. let l:hiStr= "hi! " .a:grp
  33. \ ." guifg=" . l:gFg
  34. \ ." guibg=" . l:gBg
  35. \ ." gui=" . l:gOpt
  36. \ ." ctermfg=" . l:tFg
  37. \ ." ctermbg=" . l:tBg
  38. \ ." cterm=" . l:tOpt
  39. execute l:hiStr
  40. endfunction
  41. " * Link highlighting of one group to another
  42. function! oldhope#LinkHi(obj, target)
  43. execute "hi! link " .a:obj ." " .a:target
  44. endfunction
  45. " }}}