gruvbox.vim 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. " -----------------------------------------------------------------------------
  2. " File: gruvbox.vim
  3. " Description: Retro groove color scheme for Vim
  4. " Author: morhetz <morhetz@gmail.com>
  5. " Source: https://github.com/morhetz/gruvbox
  6. " Last Modified: 9 Dec 2012
  7. " -----------------------------------------------------------------------------
  8. " Supporting code -------------------------------------------------------------
  9. " Initialisation: {{{
  10. "set background=dark
  11. if version > 580
  12. hi clear
  13. if exists("syntax_on")
  14. syntax reset
  15. endif
  16. endif
  17. let g:colors_name="gruvbox"
  18. " To be done {{{
  19. """ if has("gui_running") || &t_Co == 88 || &t_Co == 256
  20. """ let s:low_color = 0
  21. """ else
  22. """ let s:low_color = 1
  23. """ endif
  24. " }}}
  25. if !has("gui_running") && &t_Co != 88 && &t_Co != 256
  26. finish
  27. endif
  28. " }}}
  29. " Palette: {{{
  30. let s:gb = {}
  31. if &background == "dark"
  32. let s:gb.dark0 = ['282828', 235]
  33. let s:gb.dark1 = ['3c3836', 237]
  34. let s:gb.dark2 = ['504945', 239]
  35. let s:gb.dark3 = ['665c54', 241]
  36. let s:gb.dark4 = ['7c6f64', 243]
  37. let s:gb.medium = ['928374', 245]
  38. let s:gb.light0 = ['fdf4c1', 247]
  39. let s:gb.light1 = ['ebdbb2', 223]
  40. let s:gb.light2 = ['d5c4a1', 251]
  41. let s:gb.light3 = ['bdae93', 253]
  42. let s:gb.light4 = ['a89984', 255]
  43. let s:gb.red = ['fb4934', 167]
  44. let s:gb.orange = ['fe8019', 208]
  45. let s:gb.yellow = ['fabd2f', 214]
  46. let s:gb.green = ['b8bb26', 142]
  47. let s:gb.aqua = ['8ec07c', 108]
  48. let s:gb.blue = ['83a598', 109]
  49. let s:gb.purple = ['d3869b', 175]
  50. else
  51. let s:gb.dark0 = ['fdf4c1', 235]
  52. let s:gb.dark1 = ['ebdbb2', 237]
  53. let s:gb.dark2 = ['d5c4a1', 239]
  54. let s:gb.dark3 = ['bdae93', 241]
  55. let s:gb.dark4 = ['a89984', 243]
  56. let s:gb.medium = ['928374', 245]
  57. let s:gb.light0 = ['282828', 247]
  58. let s:gb.light1 = ['3c3836', 223]
  59. let s:gb.light2 = ['504945', 251]
  60. let s:gb.light3 = ['665c54', 253]
  61. let s:gb.light4 = ['7c6f64', 255]
  62. let s:gb.red = ['9d0006', 167]
  63. let s:gb.orange = ['af3a03', 208]
  64. let s:gb.yellow = ['b57614', 214]
  65. let s:gb.green = ['79740e', 142]
  66. let s:gb.aqua = ['427b58', 108]
  67. let s:gb.blue = ['076678', 109]
  68. let s:gb.purple = ['8f3f71', 175]
  69. endif
  70. " }}}
  71. " Highlighting Function: {{{
  72. function! s:HL(group, fg, ...)
  73. " Arguments: group, guifg, guibg, gui, guisp
  74. let histring = 'hi ' . a:group . ' '
  75. if strlen(a:fg)
  76. if a:fg == 'fg'
  77. let histring .= 'guifg=fg ctermfg=fg '
  78. elseif a:fg == 'bg'
  79. let histring .= 'guifg=bg ctermfg=bg '
  80. elseif a:fg == 'none'
  81. let histring .= 'guifg=NONE ctermfg=NONE '
  82. else
  83. let c = get(s:gb, a:fg)
  84. let histring .= 'guifg=#' . c[0] . ' ctermfg=' . c[1] . ' '
  85. endif
  86. endif
  87. if a:0 >= 1 && strlen(a:1)
  88. if a:1 == 'bg'
  89. let histring .= 'guibg=bg ctermbg=bg '
  90. elseif a:fg == 'fg'
  91. let histring .= 'guibg=fg ctermbg=fg '
  92. elseif a:1 == 'none'
  93. let histring .= 'guibg=NONE ctermfg=NONE '
  94. else
  95. let c = get(s:gb, a:1)
  96. let histring .= 'guibg=#' . c[0] . ' ctermbg=' . c[1] . ' '
  97. endif
  98. else
  99. let histring .= 'guibg=NONE ctermbg=NONE '
  100. endif
  101. if a:0 >= 2 && strlen(a:2)
  102. if a:2 == 'none'
  103. let histring .= 'gui=NONE cterm=NONE '
  104. else
  105. let histring .= 'gui=' . a:2 . ' cterm=' . a:2 . ' '
  106. endif
  107. else
  108. let histring .= 'gui=NONE cterm=NONE '
  109. endif
  110. if a:0 >= 3 && strlen(a:3)
  111. if a:3 == 'none'
  112. let histring .= 'guisp=NONE '
  113. else
  114. let c = get(s:gb, a:3)
  115. let histring .= 'guisp=#' . c[0] . ' '
  116. endif
  117. endif
  118. execute histring
  119. endfunction
  120. " }}}
  121. " Vanilla colorscheme ----------------------------------------------------------
  122. " General UI: {{{
  123. " Normal text
  124. call s:HL('Normal', 'light1', 'dark0')
  125. if version >= 700
  126. " Screen line that the cursor is
  127. call s:HL('CursorLine', 'none', 'dark1')
  128. " Screen column that the cursor is
  129. call s:HL('CursorColumn', 'none', 'dark1')
  130. " Tab pages line filler
  131. call s:HL('TabLineFill', 'dark4', 'bg')
  132. " Active tab page label
  133. call s:HL('TabLineSel', 'bg', 'dark4', 'bold')
  134. " Not active tab page label
  135. call s:HL('TabLine', 'dark4', 'bg')
  136. " Match paired bracket under the cursor
  137. " call s:HL('MatchParen', 'orange', 'dark3', 'bold')
  138. call s:HL('MatchParen', 'none', 'dark3', 'bold')
  139. endif
  140. if version >= 703
  141. " Highlighted screen columns
  142. call s:HL('ColorColumn', 'none', 'dark1')
  143. " Concealed element: \lambda → λ"
  144. call s:HL('Conceal', 'blue', 'none')"
  145. " Line number of CursorLine
  146. call s:HL('CursorLineNr', 'yellow', 'dark1')
  147. endif
  148. call s:HL('NonText', 'dark2')
  149. call s:HL('SpecialKey', 'dark2')
  150. call s:HL('Visual', 'none', 'dark3', 'inverse')
  151. call s:HL('VisualNOS', 'none', 'dark3', 'inverse')
  152. call s:HL('Search', 'dark0', 'yellow')
  153. call s:HL('IncSearch', 'dark0', 'yellow')
  154. call s:HL('Underlined', 'blue', 'none', 'underline')
  155. call s:HL('StatusLine', 'dark0', 'dark4', 'bold')
  156. call s:HL('StatusLineNC', 'light4', 'dark2', 'bold')
  157. " The column separating vertically split windows
  158. call s:HL('VertSplit', 'light4', 'dark2')
  159. " Current match in wildmenu completion
  160. call s:HL('WildMenu', 'blue', 'dark2', 'bold')
  161. " Directory names, special names in listing
  162. call s:HL('Directory', 'green', 'none', 'bold')
  163. " Titles for output from :set all, :autocmd, etc.
  164. call s:HL('Title', 'green', 'none', 'bold')
  165. " Error messages on the command line
  166. call s:HL('ErrorMsg', 'bg', 'red', 'bold')
  167. " More prompt: -- More --
  168. call s:HL('MoreMsg', 'yellow', 'none', 'bold')
  169. " Current mode message: -- INSERT --
  170. call s:HL('ModeMsg', 'yellow', 'none', 'bold')
  171. " 'Press enter' prompt and yes/no questions
  172. call s:HL('Question', 'orange', 'none', 'bold')
  173. " Warning messages
  174. call s:HL('WarningMsg', 'red', 'none', 'bold')
  175. " }}}
  176. " Gutter: {{{
  177. " Line number for :number and :# commands
  178. call s:HL('LineNr', 'dark4')
  179. " Column where signs are displayed
  180. call s:HL('SignColumn', 'none', 'bg')
  181. " Line used for closed folds
  182. call s:HL('Folded', 'medium', 'dark1', 'italic')
  183. " Column where folds are displayed
  184. call s:HL('FoldColumn', 'medium', 'dark1')
  185. " }}}
  186. " Cursor: {{{
  187. " Character under cursor
  188. call s:HL('Cursor', 'none', 'none', 'inverse')
  189. " Visual mode cursor, selection
  190. call s:HL('vCursor', 'none', 'none', 'inverse')
  191. " Input moder cursor
  192. call s:HL('iCursor', 'none', 'none', 'inverse')
  193. " Language mapping cursor
  194. call s:HL('lCursor', 'none', 'none', 'inverse')
  195. " }}}
  196. " Syntax Highlighting: {{{
  197. call s:HL('Special', 'orange')
  198. call s:HL('Comment', 'medium', 'none', 'italic')
  199. call s:HL('Todo', 'fg', 'bg', 'bold')
  200. " Generic statement
  201. call s:HL('Statement', 'red')
  202. " if, then, else, endif, swicth, etc.
  203. call s:HL('Conditional', 'red')
  204. " for, do, while, etc.
  205. call s:HL('Repeat', 'red')
  206. " case, default, etc.
  207. call s:HL('Label', 'red')
  208. " try, catch, throw
  209. call s:HL('Exception', 'red')
  210. " sizeof, "+", "*", etc.
  211. hi! def link Operator Normal
  212. " Any other keyword
  213. call s:HL('Keyword', 'red')
  214. " Variable name
  215. call s:HL('Identifier', 'blue')
  216. " Function name
  217. call s:HL('Function', 'green', 'none', 'bold')
  218. " Generic preprocessor
  219. call s:HL('PreProc', 'aqua')
  220. " Preprocessor #include
  221. call s:HL('Include', 'aqua')
  222. " Preprocessor #define
  223. call s:HL('Define', 'aqua')
  224. " Same as Define
  225. call s:HL('Macro', 'aqua')
  226. " Preprocessor #if, #else, #endif, etc.
  227. call s:HL('PreCondit', 'aqua')
  228. " Generic constant
  229. call s:HL('Constant', 'purple')
  230. " Character constant: 'c', '/n'
  231. call s:HL('Character', 'purple')
  232. " String constant: "this is a string"
  233. call s:HL('String', 'green')
  234. " Boolean constant: TRUE, false
  235. call s:HL('Boolean', 'purple')
  236. " Number constant: 234, 0xff
  237. call s:HL('Number', 'purple')
  238. " Floating point constant: 2.3e10
  239. call s:HL('Float', 'purple')
  240. " Generic type
  241. call s:HL('Type', 'yellow')
  242. " static, register, volatile, etc
  243. call s:HL('StorageClass', 'orange')
  244. " struct, union, enum, etc.
  245. call s:HL('Structure', 'aqua')
  246. " typedef
  247. call s:HL('Typedef', 'yellow')
  248. " }}}
  249. " Completion Menu: {{{
  250. if version >= 700
  251. " Popup menu: normal item
  252. call s:HL('Pmenu', 'light1', 'dark2')
  253. " Popup menu: selected item
  254. call s:HL('PmenuSel', 'dark2', 'blue', 'bold')
  255. " Popup menu: scrollbar
  256. call s:HL('PmenuSbar', 'none', 'dark2')
  257. " Popup menu: scrollbar thumb
  258. call s:HL('PmenuThumb', 'none', 'dark4')
  259. endif
  260. " }}}
  261. " Diffs: {{{
  262. call s:HL('DiffDelete', 'dark0', 'red')
  263. call s:HL('DiffAdd', 'dark0', 'green')
  264. "call s:HL('DiffChange', 'dark0', 'blue')
  265. "call s:HL('DiffText', 'dark0', 'yellow')
  266. " Alternative setting
  267. call s:HL('DiffChange', 'dark0', 'aqua')
  268. call s:HL('DiffText', 'dark0', 'yellow')
  269. " }}}
  270. " Spelling: {{{
  271. if has("spell")
  272. " Not capitalised word
  273. call s:HL('SpellCap', 'none', 'none', 'undercurl', 'red')
  274. " Not recognized word
  275. call s:HL('SpellBad', 'none', 'none', 'undercurl', 'blue')
  276. " Wrong spelling for selected region
  277. call s:HL('SpellLocal', 'none', 'none', 'undercurl', 'aqua')
  278. " Rare word
  279. call s:HL('SpellRare', 'none', 'none', 'undercurl', 'purple')
  280. endif
  281. " }}}
  282. " Plugin specific -------------------------------------------------------------
  283. " EasyMotion: {{{
  284. hi! def link EasyMotionTarget Search
  285. hi! def link EasyMotionShade Comment
  286. " }}}
  287. " Indent Guides: {{{
  288. let g:indent_guides_auto_colors = 0
  289. "call s:HL('IndentGuidesOdd', 'bg', 'dark2')
  290. "call s:HL('IndentGuidesEven', 'bg', 'dark1')
  291. call s:HL('IndentGuidesOdd', 'bg', 'dark2', 'inverse')
  292. call s:HL('IndentGuidesEven', 'bg', 'dark3', 'inverse')
  293. " }}}
  294. " Better Rainbow Parentheses: {{{
  295. let g:rbpt_colorpairs = [
  296. \ ['brown', '#458588'],
  297. \ ['Darkblue', '#b16286'],
  298. \ ['darkgray', '#cc241d'],
  299. \ ['darkgreen', '#d65d0e'],
  300. \ ['darkcyan', '#458588'],
  301. \ ['darkred', '#b16286'],
  302. \ ['darkmagenta', '#cc241d'],
  303. \ ['brown', '#d65d0e'],
  304. \ ['gray', '#458588'],
  305. \ ['black', '#b16286'],
  306. \ ['darkmagenta', '#cc241d'],
  307. \ ['Darkblue', '#d65d0e'],
  308. \ ['darkgreen', '#458588'],
  309. \ ['darkcyan', '#b16286'],
  310. \ ['darkred', '#cc241d'],
  311. \ ['red', '#d65d0e'],
  312. \ ]
  313. "}}}
  314. " Filetype specific -----------------------------------------------------------
  315. " Diff: {{{
  316. call s:HL('diffAdded', 'green')
  317. call s:HL('diffRemoved', 'red')
  318. call s:HL('diffChanged', 'aqua')
  319. call s:HL('diffFile', 'orange')
  320. call s:HL('diffNewFile', 'yellow')
  321. call s:HL('diffLine', 'blue')
  322. " }}}
  323. " Html: {{{
  324. call s:HL('htmlTag', 'blue')
  325. call s:HL('htmlEndTag', 'blue')
  326. call s:HL('htmlTagName', 'aqua', '', 'bold')
  327. call s:HL('htmlArg', 'aqua')
  328. call s:HL('htmlScriptTag', 'purple')
  329. call s:HL('htmlTagN', 'light1')
  330. call s:HL('htmlSpecialTagName', 'aqua', '', 'bold')
  331. call s:HL('htmlLink', 'light4', '', 'underline')
  332. call s:HL('htmlSpecialChar', 'orange')
  333. " }}}
  334. " Vim: {{{
  335. call s:HL('vimCommentTitle', 'light4', '', 'bold,italic')
  336. "hi! def link vimVar Identifier
  337. "hi! def link vimFunc Function
  338. "hi! def link vimUserFunc Function
  339. "call s:HL('vimUserFunc', 'green', '', 'bold')
  340. "call s:HL('vimFunction', 'green', '', 'bold')
  341. "call s:HL('vimFunc', 'blue')
  342. "call s:HL('vimFuncName', 'blue')
  343. "call s:HL('vimVar', 'purple')
  344. "call s:HL('vimIsCommand', 'purple')
  345. "call s:HL('vimMapMod', 'purple', '', 'bold,italic')
  346. "call s:HL('vimMapModKey', 'purple', '', 'bold,italic')
  347. "call s:HL('vimFunction', 'purple')
  348. "call s:HL('vimUserFunc', 'purple')
  349. "call s:HL('vimUserFunc', 'purple')
  350. "hi! def link vimFunc Function
  351. "hi! def link vimUserFunc Function
  352. " }}}