gruvbox.vim 15 KB

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