gruvbox.vim 8.9 KB

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