|
1 | 1 | local ts = require("cyberdream.treesitter")
|
| 2 | +local config = require("cyberdream.config") |
2 | 3 | local M = {}
|
3 | 4 |
|
4 | 5 | --- Sets the highlight group to the given table of colors.
|
@@ -98,4 +99,48 @@ function M.parse_extra_template(template, t)
|
98 | 99 | return template
|
99 | 100 | end
|
100 | 101 |
|
| 102 | +--- Override options with a new table of values. |
| 103 | +--- @param new_opts Config |
| 104 | +--- @return Config |
| 105 | +function M.set_options(new_opts) |
| 106 | + local opts = vim.g.cyberdream_opts |
| 107 | + vim.g.cyberdream_opts = vim.tbl_deep_extend("force", opts, new_opts) |
| 108 | + |
| 109 | + return vim.g.cyberdream_opts |
| 110 | +end |
| 111 | + |
| 112 | +--- Apply options to the colorscheme. |
| 113 | +--- @param opts Config |
| 114 | +function M.apply_options(opts) |
| 115 | + -- Update the colorscheme |
| 116 | + config.setup(opts) |
| 117 | + vim.cmd("colorscheme cyberdream") |
| 118 | +end |
| 119 | + |
| 120 | +--- Toggle the theme variant between "default" and "light". |
| 121 | +--- @return string new variant |
| 122 | +function M.toggle_theme_variant() |
| 123 | + local opts = vim.g.cyberdream_opts |
| 124 | + opts.theme.variant = opts.theme.variant == "default" and "light" or "default" |
| 125 | + M.set_options(opts) |
| 126 | + M.apply_options(opts) |
| 127 | + |
| 128 | + return opts.theme.variant |
| 129 | +end |
| 130 | + |
| 131 | +--- Toggle theme for lualine |
| 132 | +--- @param new_variant string "default" | "light" |
| 133 | +function M.toggle_lualine_theme(new_variant) |
| 134 | + if package.loaded["lualine"] == nil then |
| 135 | + return |
| 136 | + end |
| 137 | + |
| 138 | + local lualine_opts = require("lualine").get_config() |
| 139 | + local lualine_theme = new_variant == "default" and require("lualine.themes.cyberdream") |
| 140 | + or require("lualine.themes.cyberdream-light") |
| 141 | + |
| 142 | + lualine_opts.options.theme = lualine_theme |
| 143 | + require("lualine").setup(lualine_opts) |
| 144 | +end |
| 145 | + |
101 | 146 | return M
|
0 commit comments