gruvbox.vim 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. " Supporting code --------------------------------------------------------------
  2. " Initialisation {{{
  3. set background=dark
  4. if version > 580
  5. hi clear
  6. if exists("syntax_on")
  7. syntax reset
  8. endif
  9. endif
  10. let g:colors_name="gruvbox"
  11. " To be done {{{
  12. """ if has("gui_running") || &t_Co == 88 || &t_Co == 256
  13. """ let s:low_color = 0
  14. """ else
  15. """ let s:low_color = 1
  16. """ endif
  17. "}}}
  18. if !has("gui_running") && &t_Co != 88 && &t_Co != 256
  19. finish
  20. endif
  21. "}}}
  22. " Palette {{{
  23. let s:gb = {}
  24. let s:gb.dark0 = ['282828', 235]
  25. let s:gb.dark1 = ['3c3836', 237]
  26. let s:gb.dark2 = ['504945', 239]
  27. let s:gb.dark3 = ['665c54', 241]
  28. let s:gb.dark4 = ['7c6f64', 243]
  29. let s:gb.medium = ['928374', 245]
  30. let s:gb.light0 = ['fdf4c1', 247]
  31. let s:gb.light1 = ['ebdbb2', 223]
  32. let s:gb.light2 = ['d5c4a1', 251]
  33. let s:gb.light3 = ['bdae93', 253]
  34. let s:gb.light4 = ['a89984', 255]
  35. let s:gb.red = ['fb4934', 167]
  36. let s:gb.orange = ['fe8019', 208]
  37. let s:gb.yellow = ['fabd2f', 214]
  38. let s:gb.green = ['b8bb26', 142]
  39. let s:gb.aqua = ['8ec07c', 108]
  40. let s:gb.blue = ['83a598', 109]
  41. let s:gb.purple = ['d3869b', 175]
  42. "}}}
  43. " Highlighting Function {{{
  44. function! s:HL(group, fg, ...)
  45. " Arguments: group, guifg, guibg, gui, guisp
  46. let histring = 'hi ' . a:group . ' '
  47. if strlen(a:fg)
  48. if a:fg == 'fg'
  49. let histring .= 'guifg=fg ctermfg=fg '
  50. elseif a:fg == 'bg'
  51. let histring .= 'guifg=bg ctermfg=bg '
  52. elseif a:fg == 'none'
  53. let histring .= 'guifg=NONE ctermfg=NONE '
  54. else
  55. let c = get(s:gb, a:fg)
  56. let histring .= 'guifg=#' . c[0] . ' ctermfg=' . c[1] . ' '
  57. endif
  58. endif
  59. if a:0 >= 1 && strlen(a:1)
  60. if a:1 == 'bg'
  61. let histring .= 'guibg=bg ctermbg=bg '
  62. elseif a:fg == 'fg'
  63. let histring .= 'guibg=fg ctermbg=fg '
  64. elseif a:1 == 'none'
  65. let histring .= 'guibg=NONE ctermfg=NONE '
  66. else
  67. let c = get(s:gb, a:1)
  68. let histring .= 'guibg=#' . c[0] . ' ctermbg=' . c[1] . ' '
  69. endif
  70. else
  71. let histring .= 'guibg=NONE ctermbg=NONE '
  72. endif
  73. if a:0 >= 2 && strlen(a:2)
  74. if a:2 == 'none'
  75. let histring .= 'gui=NONE cterm=NONE '
  76. else
  77. let histring .= 'gui=' . a:2 . ' cterm=' . a:2 . ' '
  78. endif
  79. else
  80. let histring .= 'gui=NONE cterm=NONE '
  81. endif
  82. if a:0 >= 3 && strlen(a:3)
  83. if a:3 == 'none'
  84. let histring .= 'guisp=NONE '
  85. else
  86. let c = get(s:gb, a:3)
  87. let histring .= 'guisp=#' . c[0] . ' '
  88. endif
  89. endif
  90. execute histring
  91. endfunction
  92. " }}}
  93. " Actual colorscheme -----------------------------------------------------------
  94. " Vanilla Vim {{{
  95. " General/UI {{{
  96. " Normal text
  97. call s:HL('Normal', 'light1', 'dark0')
  98. if version >= 700
  99. " Screen line that the cursor is
  100. call s:HL('CursorLine', 'none', 'dark1')
  101. " Screen column that the cursor is
  102. call s:HL('CursorColumn', 'none', 'dark1')
  103. " Tab pages line filler
  104. call s:HL('TabLineFill', 'dark4', 'bg')
  105. " Active tab page label
  106. call s:HL('TabLineSel', 'bg', 'dark4', 'bold')
  107. " Not active tab page label
  108. call s:HL('TabLine', 'dark4', 'bg')
  109. " Match paired bracket under the cursor
  110. call s:HL('MatchParen', 'orange', 'dark3', 'bold')
  111. endif
  112. if version >= 730
  113. " Highlighted screen columns
  114. call s:HL('ColorColumn', 'none', 'dark1')
  115. " Concealed element: \lambda → λ"
  116. call s:HL('Conceal', 'blue', 'none')"
  117. " Line number of CursorLine
  118. call s:HL('CursorLineNr', 'yellow', 'dark1')
  119. endif
  120. call s:HL('NonText', 'dark2')
  121. call s:HL('SpecialKey', 'dark2')
  122. call s:HL('Visual', 'none', 'dark3', 'inverse')
  123. call s:HL('VisualNOS', 'none', 'dark3', 'inverse')
  124. call s:HL('Search', 'dark0', 'yellow')
  125. call s:HL('IncSearch', 'dark0', 'yellow')
  126. call s:HL('Underlined', 'blue', '', 'underline')
  127. call s:HL('StatusLine', 'dark0', 'dark4', 'bold')
  128. call s:HL('StatusLineNC', 'light4', 'dark2', 'bold')
  129. " The column separating vertically split windows
  130. call s:HL('VertSplit', 'light4', 'dark2')
  131. " Current match in wildmenu completion
  132. call s:HL('WildMenu', 'blue', 'dark2', 'bold')
  133. " Directory names, special names in listing
  134. call s:HL('Directory', 'green', 'none', 'bold')
  135. " Titles for output from :set all, :autocmd, etc.
  136. call s:HL('Title', 'green', 'none', 'bold')
  137. " Error messages on the command line
  138. call s:HL('ErrorMsg', 'bg', 'red', 'bold')
  139. " More prompt: -- More --
  140. call s:HL('MoreMsg', 'yellow', 'none', 'bold')
  141. " Current mode message: -- INSERT --
  142. call s:HL('ModeMsg', 'yellow', 'none', 'bold')
  143. " 'Press enter' prompt and yes/no questions
  144. call s:HL('Question', 'orange', 'none', 'bold')
  145. " Warning messages
  146. call s:HL('WarningMsg', 'red', 'none', 'bold')
  147. " }}}
  148. " Gutter {{{
  149. " Line number for :number and :# commands
  150. call s:HL('LineNr', 'dark4')
  151. " Column where signs are displayed
  152. call s:HL('SignColumn', 'none', 'bg')
  153. " Line used for closed folds
  154. call s:HL('Folded', 'medium', 'dark1', 'italic')
  155. " Column where folds are displayed
  156. call s:HL('FoldColumn', 'medium', 'dark1')
  157. " }}}
  158. " Cursor {{{
  159. " Character under cursor
  160. call s:HL('Cursor', 'none', 'none', 'inverse')
  161. " Visual mode cursor, selection
  162. call s:HL('vCursor', 'none', 'none', 'inverse')
  163. " Input moder cursor
  164. call s:HL('iCursor', 'none', 'none', 'inverse')
  165. " Language mapping cursor
  166. call s:HL('lCursor', 'none', 'none', 'inverse')
  167. " }}}
  168. " Syntax highlighting {{{
  169. call s:HL('Special', 'orange')
  170. call s:HL('Comment', 'medium', 'none', 'italic')
  171. call s:HL('Todo', 'fg', 'bg', 'bold')
  172. " Generic statement
  173. call s:HL('Statement', 'red')
  174. " if, then, else, endif, swicth, etc.
  175. call s:HL('Conditional', 'red')
  176. " for, do, while, etc.
  177. call s:HL('Repeat', 'red')
  178. " case, default, etc.
  179. call s:HL('Label', 'red')
  180. " try, catch, throw
  181. call s:HL('Exception', 'red')
  182. " sizeof, "+", "*", etc.
  183. hi! def link Operator Normal
  184. " Any other keyword
  185. call s:HL('Keyword', 'red')
  186. " Variable name
  187. call s:HL('Identifier', 'blue')
  188. " Function name
  189. call s:HL('Function', 'green', 'none', 'bold')
  190. " Generic preprocessor
  191. call s:HL('PreProc', 'aqua')
  192. " Preprocessor #include
  193. call s:HL('Include', 'aqua')
  194. " Preprocessor #define
  195. call s:HL('Define', 'aqua')
  196. " Same as Define
  197. call s:HL('Macro', 'aqua')
  198. " Preprocessor #if, #else, #endif, etc.
  199. call s:HL('PreCondit', 'aqua')
  200. " Generic constant
  201. call s:HL('Constant', 'purple')
  202. " Character constant: 'c', '/n'
  203. call s:HL('Character', 'purple')
  204. " String constant: "this is a string"
  205. call s:HL('String', 'green')
  206. " Boolean constant: TRUE, false
  207. call s:HL('Boolean', 'purple')
  208. " Number constant: 234, 0xff
  209. call s:HL('Number', 'purple')
  210. " Floating point constant: 2.3e10
  211. call s:HL('Float', 'purple')
  212. " Generic type
  213. call s:HL('Type', 'yellow')
  214. " static, register, volatile, etc
  215. call s:HL('StorageClass', 'orange')
  216. " struct, union, enum, etc.
  217. call s:HL('Structure', 'aqua')
  218. " typedef
  219. call s:HL('Typedef', 'yellow')
  220. " }}}
  221. " Completion Menu {{{
  222. if version >= 700
  223. " Popup menu: normal item
  224. call s:HL('Pmenu', 'light1', 'dark2')
  225. " Popup menu: selected item
  226. call s:HL('PmenuSel', 'dark2', 'blue', 'bold')
  227. " Popup menu: scrollbar
  228. call s:HL('PmenuSbar', 'none', 'dark2')
  229. " Popup menu: scrollbar thumb
  230. call s:HL('PmenuThumb', 'none', 'dark4')
  231. endif
  232. " }}}
  233. " Diffs {{{
  234. call s:HL('DiffDelete', 'dark0', 'red')
  235. call s:HL('DiffAdd', 'dark0', 'green')
  236. "call s:HL('DiffChange', 'dark0', 'blue')
  237. "call s:HL('DiffText', 'dark0', 'yellow')
  238. " Alternative setting
  239. call s:HL('DiffChange', 'dark0', 'aqua')
  240. call s:HL('DiffText', 'dark0', 'yellow')
  241. " }}}
  242. " Spelling {{{
  243. if has("spell")
  244. " Not capitalised word
  245. call s:HL('SpellCap', 'none', 'none', 'undercurl', 'red')
  246. " Not recognized word
  247. call s:HL('SpellBad', 'none', 'none', 'undercurl', 'blue')
  248. " Wrong spelling for selected region
  249. call s:HL('SpellLocal', 'none', 'none', 'undercurl', 'aqua')
  250. " Rare word
  251. call s:HL('SpellRare', 'none', 'none', 'undercurl', 'purple')
  252. endif
  253. " }}}
  254. " }}}
  255. " Filetype specific -----------------------------------------------------------
  256. "{{{ Diff
  257. call s:HL('diffAdded', 'green')
  258. call s:HL('diffRemoved', 'red')
  259. call s:HL('diffChanged', 'aqua')
  260. call s:HL('diffFile', 'orange')
  261. call s:HL('diffNewFile', 'yellow')
  262. call s:HL('diffLine', 'blue')
  263. "}}}