diff options
Diffstat (limited to '.config/nvim/plugin/50-colors.lua')
| -rw-r--r-- | .config/nvim/plugin/50-colors.lua | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/.config/nvim/plugin/50-colors.lua b/.config/nvim/plugin/50-colors.lua new file mode 100644 index 0000000..f713a74 --- /dev/null +++ b/.config/nvim/plugin/50-colors.lua @@ -0,0 +1,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" }) |
