Skip to content

Commit 81ea0d6

Browse files
committed
Add light theme and fix some configurations
1 parent 3f5f417 commit 81ea0d6

File tree

6 files changed

+190
-39
lines changed

6 files changed

+190
-39
lines changed

lua/rakis/colors.lua

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ local M = {}
4545
M.default = {
4646
none = "NONE",
4747
bg = hsl(18, 20, 4),
48-
bg_secondary = hsl(18, 20, 6),
48+
bg_secondary = hsl(18, 20, 10),
4949
bg_highlight = hsl(12, 30, 17),
5050
fg = hsl(20, 30, 55),
5151
base01 = hsl(14, 20, 41),
@@ -82,37 +82,37 @@ M.default = {
8282
---@field light RakisPalette
8383
M.light = {
8484
bg = hsl(53, 67, 84),
85-
bg_secondary = hsl(18, 20, 6),
86-
bg_highlight = hsl(22, 70, 88),
85+
bg_secondary = hsl(53, 68, 76),
86+
bg_highlight = hsl(47, 77, 83),
8787
fg = hsl(20, 30, 55),
88-
base01 = hsl(14, 20, 41),
89-
base02 = hsl(12, 50, 25),
90-
base03 = hsl(12, 30, 12),
91-
yellow01 = hsl(40, 94, 80),
92-
yellow02 = hsl(40, 90, 64),
93-
yellow03 = hsl(40, 90, 50),
94-
orange01 = hsl(27, 98, 70),
95-
orange02 = hsl(27, 95, 55),
96-
orange03 = hsl(27, 100, 42),
97-
red01 = hsl(4, 95, 78),
98-
red02 = hsl(4, 90, 65),
99-
red03 = hsl(4, 80, 55),
100-
magenta01 = hsl(355, 40, 66),
101-
magenta02 = hsl(355, 34, 55),
102-
magenta03 = hsl(355, 34, 45),
103-
magenta04 = hsl(355, 35, 33),
104-
violet01 = hsl(264, 35, 70),
105-
violet02 = hsl(264, 33, 58),
106-
violet03 = hsl(264, 30, 44),
107-
blue01 = hsl(205, 55, 71),
108-
blue02 = hsl(205, 56, 60),
109-
blue03 = hsl(205, 58, 48),
110-
cyan01 = hsl(187, 41, 69),
111-
cyan02 = hsl(185, 44, 57),
112-
cyan03 = hsl(185, 40, 40),
113-
green01 = hsl(118, 22, 70),
114-
green02 = hsl(117, 21, 55),
115-
green03 = hsl(118, 20, 45),
88+
base01 = hsl(46, 48, 62),
89+
base02 = hsl(46, 74, 72),
90+
base03 = hsl(42, 60, 72),
91+
yellow01 = hsl(40, 90, 50),
92+
yellow02 = hsl(40, 90, 38),
93+
yellow03 = hsl(42, 93, 22),
94+
orange01 = hsl(27, 100, 42),
95+
orange02 = hsl(27, 95, 35),
96+
orange03 = hsl(27, 95, 23),
97+
red01 = hsl(4, 80, 55),
98+
red02 = hsl(4, 72, 37),
99+
red03 = hsl(4, 70, 22),
100+
magenta01 = hsl(355, 34, 55),
101+
magenta02 = hsl(355, 34, 45),
102+
magenta03 = hsl(355, 35, 33),
103+
magenta04 = hsl(355, 32, 20),
104+
violet01 = hsl(264, 30, 44),
105+
violet02 = hsl(264, 28, 33),
106+
violet03 = hsl(264, 27, 25),
107+
blue01 = hsl(205, 58, 48),
108+
blue02 = hsl(205, 60, 37),
109+
blue03 = hsl(205, 65, 27),
110+
cyan01 = hsl(185, 40, 40),
111+
cyan02 = hsl(185, 44, 30),
112+
cyan03 = hsl(185, 41, 23),
113+
green01 = hsl(118, 20, 45),
114+
green02 = hsl(118, 19, 36),
115+
green03 = hsl(118, 18, 23),
116116
}
117117

118118
return M

lua/rakis/config.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local default_colors = require("rakis.colors").default
21
local M = {}
32

43
---@class RakisHighlight
@@ -67,8 +66,8 @@ local default_options = {
6766
cache = false,
6867

6968
theme = {
70-
variant = "default",
71-
colors = default_colors,
69+
variant = "auto",
70+
colors = {},
7271
highlights = {},
7372
},
7473

@@ -78,7 +77,7 @@ local default_options = {
7877
-- dashboard = true,
7978
-- fzflua = true,
8079
-- gitpad = true,
81-
-- gitsigns = true,
80+
gitsigns = true,
8281
-- grapple = true,
8382
-- grugfar = true,
8483
-- heirline = true,
@@ -96,7 +95,7 @@ local default_options = {
9695
-- notify = true,
9796
-- rainbow_delimiters = true,
9897
-- telescope = true,
99-
-- treesitter = true,
98+
treesitter = true,
10099
-- treesittercontext = true,
101100
-- trouble = true,
102101
-- whichkey = true,

lua/rakis/extensions/gitsigns.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local M = {}
21
local util = require("rakis.util")
2+
local M = {}
33

44
--- Get extension configuration
55
--- @param opts Config

lua/rakis/extensions/treesitter.lua

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
local util = require("rakis.util")
2+
local M = {}
3+
4+
--- Get extension configuration
5+
--- @param opts Config
6+
--- @param p RakisPalette
7+
function M.get(opts, p)
8+
opts = opts or {}
9+
local highlights = {
10+
["@annotation"] = { link = "PreProc" },
11+
["@attribute"] = { link = "PreProc" },
12+
["@boolean"] = { link = "Boolean" },
13+
["@character"] = { link = "Character" },
14+
["@character.special"] = { link = "SpecialChar" },
15+
["@comment"] = { link = "Comment" },
16+
["@conditional"] = { link = "Conditional" },
17+
["@constant"] = { link = "Constant" },
18+
["@constant.builtin"] = { link = "Special" },
19+
["@constant.macro"] = { link = "Define" },
20+
["@constructor"] = { link = "Special" },
21+
["@debug"] = { link = "Debug" },
22+
["@define"] = { link = "Define" },
23+
["@exception"] = { link = "Exception" },
24+
["@field"] = { link = "Identifier" },
25+
["@float"] = { link = "Float" },
26+
["@function"] = { link = "Function" },
27+
["@function.builtin"] = { link = "Special" },
28+
["@function.call"] = { link = "@function" },
29+
["@function.macro"] = { link = "Macro" },
30+
["@include"] = { link = "Include" },
31+
["@keyword"] = { link = "Keyword" },
32+
["@keyword.coroutine"] = { link = "@keyword" },
33+
["@keyword.function"] = { link = "Keyword" },
34+
["@keyword.operator"] = { link = "@operator" },
35+
["@keyword.return"] = { link = "@keyword" },
36+
["@keyword.type"] = { fg = p.orange03, italic = true },
37+
["@label"] = { link = "Label" },
38+
["@markup.heading.1"] = { link = "markdownH1" },
39+
["@markup.heading.2"] = { link = "markdownH2" },
40+
["@markup.heading.3"] = { link = "markdownH3" },
41+
["@markup.heading.4"] = { link = "markdownH4" },
42+
["@markup.heading.5"] = { link = "markdownH5" },
43+
["@markup.heading.6"] = { link = "markdownH6" },
44+
["@markup.italic"] = { fg = p.blue03, italic = true },
45+
["@markup.link.label"] = { link = "Label" },
46+
["@markup.link.label.markdown_inline"] = { fg = p.cyan03 },
47+
["@markup.link.markdown_inline"] = { fg = p.blue03 },
48+
["@markup.link.url"] = { fg = p.blue03, underline = true },
49+
["@markup.list.checked"] = { fg = p.green02, bold = true },
50+
["@markup.list.unchecked"] = { fg = p.magenta03, bold = true },
51+
["@markup.quote"] = { link = "Comment" },
52+
["@markup.strong"] = { fg = p.violet01, bold = true },
53+
["@method"] = { link = "Function" },
54+
["@method.call"] = { link = "@method" },
55+
["@namespace"] = { link = "Include" },
56+
["@none"] = { default = true },
57+
["@number"] = { link = "Number" },
58+
["@operator"] = { link = "Operator" },
59+
["@parameter"] = { link = "Identifier" },
60+
["@preproc"] = { link = "PreProc" },
61+
["@property"] = { link = "Identifier" },
62+
["@punctuation.bracket"] = { link = "Delimiter" },
63+
["@punctuation.delimiter"] = { link = "Delimiter" },
64+
["@punctuation.special"] = { link = "Delimiter" },
65+
["@repeat"] = { link = "Repeat" },
66+
["@storageclass"] = { link = "StorageClass" },
67+
["@string"] = { link = "String" },
68+
["@string.escape"] = { link = "SpecialChar" },
69+
["@string.regex"] = { link = "String" },
70+
["@string.special"] = { link = "SpecialChar" },
71+
["@symbol"] = { link = "Identifier" },
72+
["@tag"] = { link = "Label" },
73+
["@tag.attribute"] = { link = "@property" },
74+
["@tag.delimiter"] = { link = "Delimiter" },
75+
["@text"] = { link = "@none" },
76+
["@text.danger"] = { link = "WarningMsg" },
77+
["@text.emphasis"] = { italic = true },
78+
["@text.environment"] = { link = "Macro" },
79+
["@text.environment.name"] = { link = "Type" },
80+
["@text.literal"] = { link = "String" },
81+
["@text.math"] = { link = "Special" },
82+
["@text.note"] = { link = "SpecialComment" },
83+
["@text.reference"] = { link = "Constant" },
84+
["@text.strike"] = { strikethrough = true },
85+
["@text.strong"] = { bold = true, default = true },
86+
["@text.title"] = { link = "markdownH1" },
87+
["@text.title.2"] = { link = "markdownH2" },
88+
["@text.title.3"] = { link = "markdownH3" },
89+
["@text.title.4"] = { link = "markdownH4" },
90+
["@text.title.5"] = { link = "markdownH5" },
91+
["@text.todo"] = { link = "Todo" },
92+
["@text.underline"] = { underline = true },
93+
["@text.uri"] = { link = "Underlined" },
94+
["@text.warning"] = { link = "Todo" },
95+
["@type"] = { link = "Type" },
96+
["@type.builtin"] = { fg = util.blend(p.violet02, p.magenta03, 0.65) },
97+
["@type.definition"] = { link = "Typedef" },
98+
["@type.qualifier"] = { link = "@keyword" },
99+
["@variable"] = { fg = p.fg },
100+
["@variable.builtin"] = { link = "Special" },
101+
}
102+
return highlights
103+
end
104+
105+
return M

lua/rakis/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ M.colorscheme = M.load
1717

1818
vim.api.nvim_create_user_command("RakisToggleMode", function()
1919
local new_variant = util.toggle_theme_variant()
20-
util.toggle_lualine_theme()
20+
-- util.toggle_lualine_theme()
2121
vim.api.nvim_exec_autocmds("User", { pattern = "RakisToggleMode", data = new_variant })
2222
end, {})
2323

@@ -36,7 +36,7 @@ vim.api.nvim_create_autocmd("OptionSet", {
3636
if vim.g.rakis_opts.theme.variant ~= "auto" or vim.fn.execute("colorscheme"):find("rakis") == nil then
3737
return
3838
end
39-
util.toggle_lualine_theme()
39+
-- util.toggle_lualine_theme()
4040
end,
4141
})
4242

lua/rakis/util.lua

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,51 @@ function M.parse_extra_template(template, t)
236236
return template
237237
end
238238

239+
--- Override options with a new table of values.
240+
--- @param new_opts Config
241+
--- @return Config
242+
function M.set_options(new_opts)
243+
local opts = vim.g.rakis_opts
244+
vim.g.rakis_opts = vim.tbl_deep_extend("force", opts, new_opts)
245+
246+
return vim.g.rakis_opts
247+
end
248+
249+
--- Apply options to the colorscheme.
250+
--- @param opts Config
251+
function M.apply_options(opts)
252+
-- Update the colorscheme
253+
config.setup(opts)
254+
vim.cmd("colorscheme rakis")
255+
end
256+
257+
--- Used for toggling the theme variant when the variant is set to "auto". Uses the 'set background' command to toggle between 'light' and 'dark'.
258+
--- @return string new variant
259+
function M.toggle_theme_auto()
260+
local variant = vim.o.background
261+
if variant == "dark" then
262+
variant = "light"
263+
else
264+
variant = "dark"
265+
end
266+
vim.cmd(":set background=" .. variant)
267+
return variant == "dark" and "default" or "light"
268+
end
269+
270+
--- Toggle the theme variant between "default" and "light".
271+
--- @return string new variant
272+
function M.toggle_theme_variant()
273+
local opts = vim.g.rakis_opts
274+
-- Handle the "auto" variant without overwriting the value in opts.
275+
if opts.theme.variant == "auto" then
276+
return M.toggle_theme_auto()
277+
end
278+
279+
opts.theme.variant = opts.theme.variant == "default" and "light" or "default"
280+
M.set_options(opts)
281+
M.apply_options(opts)
282+
283+
return opts.theme.variant
284+
end
285+
239286
return M

0 commit comments

Comments
 (0)