1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
local lush = require("lush")
local hsl = lush.hsl
-- gruvbox palette
local colors = {
dark0_hard = "#1d2021",
dark0 = "#282828",
dark0_soft = "#32302f",
dark1 = "#3c3836",
dark2 = "#504945",
dark3 = "#665c54",
dark4 = "#7c6f64",
light0_hard = "#f9f5d7",
light0 = "#fbf1c7",
light0_soft = "#f2e5bc",
light1 = "#ebdbb2",
light2 = "#d5c4a1",
light3 = "#bdae93",
light4 = "#a89984",
bright_red = "#fb4934",
bright_green = "#b8bb26",
bright_yellow = "#fabd2f",
bright_blue = "#83a598",
bright_purple = "#d3869b",
bright_aqua = "#8ec07c",
bright_orange = "#fe8019",
neutral_red = "#cc241d",
neutral_green = "#98971a",
neutral_yellow = "#d79921",
neutral_blue = "#458588",
neutral_purple = "#b16286",
neutral_aqua = "#689d6a",
neutral_orange = "#d65d0e",
faded_red = "#9d0006",
faded_green = "#79740e",
faded_yellow = "#b57614",
faded_blue = "#076678",
faded_purple = "#8f3f71",
faded_aqua = "#427b58",
faded_orange = "#af3a03",
gray = "#928374",
}
-- options (dark mode by default)
local bg0 = colors.dark0
local bg1 = colors.dark1
local bg2 = colors.dark2
local bg3 = colors.dark3
local bg4 = colors.dark4
local fg0 = colors.light0
local fg1 = colors.light1
local fg2 = colors.light2
local fg3 = colors.light3
local fg4 = colors.light4
local red = colors.bright_red
local green = colors.bright_green
local yellow = colors.bright_yellow
local blue = colors.bright_blue
local purple = colors.bright_purple
local aqua = colors.bright_aqua
local orange = colors.bright_orange
local sign_column = bg1
local gray = colors.gray
-- global settings
local settings = {
contrast_dark = "medium",
contrart_light = "medium",
bold = true,
italic = true,
undercurl = true,
underline = true,
improved_strings = false,
improved_warnings = false,
invert_signs = false,
invert_selection = true,
invert_tabline = false,
italicize_comments = true,
italicize_strings = false,
}
local styles = {
italic = "italic",
inverse = "inverse",
bold = "bold",
undercurl = "undercurl",
underline = "underline",
}
-- setting default values
for k, val in pairs(settings) do
local key = "gruvbox_" .. k
if vim.g[key] == nil then
vim.g[key] = val
end
end
-- handle light/dark contrast settings
local bg = vim.o.background
local contrast = vim.g["gruvbox_contrast_" .. bg]
if contrast == "hard" then
bg0 = colors[bg .. "0_hard"]
elseif contrast == "soft" then
bg0 = colors[bg .. "0_soft"]
end
-- swap colors if light mode
if bg == "light" then
bg0 = colors.light0
bg1 = colors.light1
bg2 = colors.light2
bg3 = colors.light3
bg4 = colors.light4
fg0 = colors.dark0
fg1 = colors.dark1
fg2 = colors.dark2
fg3 = colors.dark3
fg4 = colors.dark4
red = colors.faded_red
green = colors.faded_green
yellow = colors.faded_yellow
blue = colors.faded_blue
purple = colors.faded_purple
aqua = colors.faded_aqua
orange = colors.faded_orange
end
local hls_cursor = orange
if vim.g.gruvbox_hls_cursor ~= nil then
hls_cursor = colors[vim.g.gruvbox_hls_cursor]
end
local hls_highlight = yellow
if vim.g.gruvbox_hls_cursor ~= nil then
hls_cursor = colors[vim.g.gruvbox_hls_highlight]
end
local number_column
if vim.g.gruvbox_number_column ~= nil then
number_column = hsl(colors[vim.g.gruvbox_number_column])
end
local color_column = bg1
if vim.g.gruvbox_color_column ~= nil then
color_column = colors[vim.g.gruvbox_color_column]
end
local vert_split = bg0
if vim.g.gruvbox_vert_split ~= nil then
vert_split = colors[vim.g.gruvbox_vert_split]
end
local invert_signs
if vim.g.gruvbox_invert_signs then
invert_signs = styles.inverse
end
local invert_selection = styles.inverse
if not vim.g.gruvbox_invert_selection then
invert_selection = nil
end
local invert_tabline
if vim.g.gruvbox_invert_tabline then
invert_tabline = styles.inverse
end
local tabline_sel = green
if vim.g.gruvbox_tabline_sel then
tabline_sel = colors[vim.g.gruvbox_tabline_sel]
end
local italic_comments = settings.italic
if not vim.g.gruvbox_italicize_comments then
italic_comments = nil
end
local italic_strings
if vim.g.gruvbox_italicize_strings then
italic_strings = styles.italic
end
local special = {fg = hsl(orange), bg = hsl(bg1), gui = italic_strings}
local special_string = {fg = hsl(fg1), bg = hsl(bg1), italic_strings}
if not vim.g.gruvbox_improved_strings then
special = {fg = hsl(orange)}
special_string = {fg = hsl(green), gui = italic_strings}
end
local theme = lush(function()
return {
-- EndOfBuffer { },
-- TermCursor { },
-- TermCursorNC { },
-- Substitute { },
-- MsgArea { },
-- MsgSeparator { },
-- Whitespace { },
-- Base groups
ColorColumn {bg = hsl(bg1)},
Conceal {bg = hsl(blue)},
Cursor {gui = styles.inverse},
lCursor {Cursor},
CursorIM {Cursor},
CursorColumn {bg = bg1},
CursorLine {CursorColumn},
Directory {fg = hsl(green), gui = styles.bold},
DiffAdd {fg = hsl(green), bg = hsl(bg1), gui = invert_signs},
DiffChange {fg = hsl(aqua), bg = hsl(bg1), gui = invert_signs},
DiffDelete {fg = hsl(red), bg = hsl(bg1), gui = invert_signs},
DiffText {fg = hsl(yellow), bg = hsl(bg1), gui = invert_signs},
ErrorMsg {fg = hsl(bg0), bg = hsl(red), gui = styles.bold},
VertSplit {fg = hsl(bg3), bgb = hsl(vert_split)},
Folded {fg = hsl(gray), bg = hsl(bg1), gui = styles.italic},
FoldColumn {fg = hsl(gray), bg = hsl(bg1)},
SignColumn {bg = hsl(sign_column)},
IncSearch {fg = hsl(hls_cursor), bg = hsl(bg0), gui = styles.inverse},
LineNr {fg = hsl(bg4), bg = number_column},
CursorLineNr {fg = hsl(yellow), bg = hsl(bg1)},
MatchParen {bg = hsl(bg3), gui = styles.bold},
ModeMsg {fg = hsl(yellow), gui = styles.bold},
MoreMsg {fg = hsl(yellow), gui = styles.bold},
NonText {fg = hsl(bg2)},
Normal {fg = hsl(fg0), bg = hsl(bg0)},
NormalFloat {Normal},
NormalNC {Normal},
Pmenu {fg = hsl(fg1), bg = hsl(bg2)},
PmenuSel {fg = hsl(bg2), bg = hsl(blue), gui = styles.bold},
PmenuSbar {bg = hsl(bg2)},
PmenuThumb {bg = hsl(bg4)},
Question {fg = hsl(orange), gui = styles.bold},
QuickFixLine {fg = hsl(fg0), bg = hsl(yellow), gui = styles.bold},
Search {fg = hsl(hls_highlight), bg = hsl(bg0), gui = styles.inverse},
SpecialKey {fg = hsl(fg4)},
SpellRare {gui = styles.undercurl, sep = hsl(purple)},
SpellBad {fg = hsl(red), gui = styles.underline},
StatusLine {fg = hsl(bg2), bg = hsl(fg1), gui = styles.inverse},
StatusLineNC {fg = hsl(bg1), bg = hsl(fg4), gui = styles.inverse},
TabLine {fg = hsl(bg4), bg = hsl(bg1), gui = invert_tabline},
TabLineFill {fg = hsl(bg4), bg = hsl(bg1), gui = invert_tabline},
TabLineSel {fg = hsl(tabline_sel), bg = hsl(bg1), gui = invert_tabline},
Title {fg = hsl(green), gui = styles.bold},
Visual {bg = hsl(bg3), gui = invert_selection},
VisualNOS {bg = hsl(bg3), gui = invert_selection},
WarningMsg {fg = hsl(red), gui = styles.bold},
WildMenu {fg = hsl(blue), bg = hsl(bg2), gui = styles.bold},
Constant {fg = hsl(purple)},
String {unpack(special_string)},
Character {fg = hsl(purple)},
Number {Character},
Boolean {Character},
Float {Character},
Identifier {fg = hsl(blue)},
Function {fg = hsl(green), gui = styles.bold},
Statement {fg = hsl(red)},
Conditional {fg = hsl(red)},
Repeat {fg = hsl(red)},
Label {fg = hsl(red)},
Keyword {fg = hsl(red)},
Exception {fg = hsl(red)},
Operator {fg = hsl(fg1)},
PreProc {fg = hsl(aqua)},
Include {fg = hsl(aqua)},
Define {fg = hsl(aqua)},
Macro {fg = hsl(aqua)},
PreCondit {fg = hsl(aqua)},
Type {fg = hsl(yellow)},
StorageClass {fg = hsl(orange)},
Structure {fg = hsl(aqua)},
Typedef {fg = hsl(yellow)},
Special {unpack(special)},
SpecialChar {fg = hsl(red)},
Tag {fg = hsl(aqua), gui = styles.bold},
Delimiter {fg = hsl(fg0)},
SpecialComment {fg = hsl(gray), gui = styles.italic},
Debug {fg = hsl(red)},
Underlined {gui = styles.underline},
Bold {gui = styles.bold},
Italic {gui = styles.italic},
Ignore {},
Error {fg = hsl(red), gui = styles.bold .. "," .. styles.underline}, -- TODO: check if we have some abstraction to merge two styles
Todo {fg = hsl(fg0), gui = styles.bold .. "," .. styles.italic},
-- LSP
LspDiagnosticsError {Error},
LspDiagnosticsErrorSign {fg = hsl(red), bg = hsl(sign_column), gui = invert_signs},
LspDiagnosticsErrorFloating {LspDiagnosticsError},
LspDiagnosticsWarning {fg = hsl(yellow)},
LspDiagnosticsWarningSign {
LspDiagnosticsWarning,
bg = hsl(sign_column),
gui = styles.undercurl,
sp = hsl(yellow),
},
LspDiagnosticsWarningFloating {LspDiagnosticsWarning},
LspDiagnosticsInformation {fg = hsl(blue)},
LspDiagnosticsInformationSign {
LspDiagnosticsInformation,
bg = hsl(sign_column),
gui = invert_signs,
},
LspDiagnosticsInformationFloating {LspDiagnosticsInformation},
LspDiagnosticsHint {fg = hsl(aqua)},
LspDiagnosticsHintSign {
LspDiagnosticsHint,
bg = hsl(sign_column),
gui = invert_signs,
},
LspDiagnosticsHintFloating {LspDiagnosticsHint},
-- Treesitter
TSNone {},
TSError {Error},
TSPunctDelimiter {Delimiter},
TSPunctBracket {Delimiter},
TSPunctSpecial {Delimiter},
TSConstant {Constant},
TSConstBuiltin {Special},
TSConstMacro {Define},
TSString {String},
TSStringRegex {String},
TSStringEscape {SpecialChar},
TSCharacter {Character},
TSNumber {Number},
TSBoolean {Boolean},
TSFloat {Float},
TSFunction {Function},
TSFuncBuiltin {Special},
TSFuncMacro {Macro},
TSParameter {Identifier},
TSParameterReference {TSParameter},
TSMethod {Function},
TSField {Identifier},
TSProperty {Identifier},
TSConstructor {Special},
TSConditional {Conditional},
TSRepeat {Repeat},
TSLabel {Label},
TSOperator {Operator},
TSKeyword {Keyword},
TSKeywordFunction {Keyword},
TSException {Exception},
TSType {Type},
TSTypeBuiltin {Type},
TSNamespace {Include},
TSInclude {Include},
TSAnnotation {PreProc},
TSText {TSNone},
TSStrong {gui = styles.bold},
TSEmphasis {gui = styles.italic},
TSUnderline {gui = styles.underline},
TSTitle {Title},
TSLiteral {String},
TSURI {Underlined},
TSVariable {Special},
TSVariableBuiltin {Special},
-- netrw
netrwDir {fg = hsl(aqua)},
netrwClassify {netrwDir},
netrwLink {fg = hsl(gray)},
netrwSymLink {fg = hsl(fg1)},
netrwExe {fg = hsl(yellow)},
netrwComment {netrwLink},
netrwList {fg = hsl(blue)},
netrwHelpCmd {netrwDir},
netrwCmdSep {fg = hsl(fg3)},
netrwVersion {fg = hsl(green)},
-- vim-startify
StartifyBracket {fg = hsl(fg3)},
StartifyFile {fg = hsl(fg1)},
StartifyNumber {fg = hsl(blue)},
StartifyPath {fg = hsl(gray)},
StartifySlash {StartifyPath},
StartifySection {fg = hsl(yellow)},
StartifySpecial {fg = hsl(bg2)},
StartifyHeader {fg = hsl(orange)},
StartifyFooter {fg = hsl(bg2)},
-- vim-signify
SignifySignAdd {fg = hsl(green), bg = hsl(sign_column), gui = invert_signs},
SignifySignChange {fg = hsl(aqua), bg = hsl(sign_column), gui = invert_signs},
SignifySignDelete {fg = hsl(red), bg = hsl(sign_column), gui = invert_signs},
-- lua
luaIn {fg = hsl(red)},
luaFunction {fg = hsl(aqua)},
luaTable {fg = hsl(orange)},
}
end)
return theme
-- vi:nowrap
|