gruvbox.vim 14 KB

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