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
|
--
-- Color scheme plugin
--
vim.pack.add({ "https://github.com/maxmx03/solarized.nvim" }) -- Solarized color scheme
local solarized_colors = {
base03 = "#002b36",
base02 = "#073642",
base01 = "#586e75",
base00 = "#657b83",
base0 = "#839496",
base1 = "#93a1a1",
base2 = "#eee8d5",
base3 = "#fdf6e3",
yellow = "#b58900",
orange = "#cb4b16",
red = "#dc322f",
magenta = "#d33682",
violet = "#6c71c4",
blue = "#268bd2",
cyan = "#2aa198",
green = "#859900",
}
local function adjust_highlight()
if vim.g.colors_name == "solarized" then
-- General highlight
vim.api.nvim_set_hl(0, "EndOfBuffer", { fg = solarized_colors.base0, update = true })
vim.api.nvim_set_hl(0, "MatchParen", { link = "CurSearch" })
if vim.o.background == "light" then
vim.api.nvim_set_hl(0, "TabLineSel", { bg = "#edffd5" })
vim.api.nvim_set_hl(0, "Cursorline", { bg = "#edffd5" })
vim.api.nvim_set_hl(0, "NormalFloat", { bg = solarized_colors.base2 })
elseif vim.o.background == "dark" then
vim.api.nvim_set_hl(0, "TabLineSel", { bg = "#043624" })
vim.api.nvim_set_hl(0, "Cursorline", { bg = "#043624" })
vim.api.nvim_set_hl(0, "NormalFloat", { bg = solarized_colors.base02 })
end
-- Markdown highlight
if vim.o.background == "light" then
vim.api.nvim_set_hl(0, "@markup.raw", { bg = solarized_colors.base2, update = true })
elseif vim.o.background == "dark" then
vim.api.nvim_set_hl(0, "@markup.raw", { bg = solarized_colors.base02, update = true })
end
vim.api.nvim_set_hl(0, "@markup.raw.block", { fg = solarized_colors.cyan, update = true })
vim.api.nvim_set_hl(0, "@markup.heading.1", { link = "@markup.heading" })
vim.api.nvim_set_hl(0, "@markup.heading.2", { link = "@markup.heading" })
vim.api.nvim_set_hl(0, "@markup.heading.3", { link = "@markup.heading" })
vim.api.nvim_set_hl(0, "@markup.heading.4", { link = "@markup.heading" })
vim.api.nvim_set_hl(0, "@markup.heading.5", { link = "@markup.heading" })
vim.api.nvim_set_hl(0, "@markup.heading.6", { link = "@markup.heading" })
end
end
local function next_colorscheme()
local colorschemes = vim.fn.getcompletion("", "color")
vim.g.colors_name = vim.g.colors_name or "default"
for i = 1, #colorschemes do
if colorschemes[i] == vim.g.colors_name then
vim.cmd.colorscheme(colorschemes[(i % #colorschemes) + 1])
vim.notify("Color scheme set to " .. vim.g.colors_name)
return
end
end
end
local function random_colorscheme()
local colorschemes = vim.fn.getcompletion("", "color")
vim.cmd.colorscheme(colorschemes[math.random(#colorschemes)])
vim.notify("Color scheme set to " .. vim.g.colors_name)
end
local function toggle_theme()
vim.opt.background = vim.o.background == "light" and "dark" or "light"
vim.notify("Color theme set to " .. vim.o.background)
end
-- Adjust colors after the color scheme has loaded
vim.api.nvim_create_autocmd("ColorScheme", {
desc = "Adjust color scheme",
group = vim.g.dotfiles.augroup,
callback = adjust_highlight,
})
-- Adjust colors when the theme (light/dark) changes
vim.api.nvim_create_autocmd("OptionSet", {
desc = "Adjust color scheme",
pattern = "background",
group = vim.g.dotfiles.augroup,
callback = adjust_highlight,
})
vim.cmd.colorscheme("solarized") -- Default colorscheme
vim.opt.background = "dark" -- Default theme
vim.api.nvim_create_user_command("ColorsNext", next_colorscheme, { desc = "Load next color scheme" })
vim.api.nvim_create_user_command("ColorsRandom", random_colorscheme, { desc = "Load random color scheme" })
vim.api.nvim_create_user_command("ColorsThemeToggle", toggle_theme, { desc = "Toggle light/dark theme" })
|