local themes = { { name = "Catppuccin mocha", colorscheme = "catppuccin", before = [[ require("catppuccin").setup({ flavor = "mocha" }) ]], }, { name = "Monokai", colorscheme = "monokai" }, { name = "Neon default", colorscheme = "neon", before = [[ vim.g.neon_style = "default" ]] }, { name = "Neon dark", colorscheme = "neon", before = [[ vim.g.neon_style = "dark" ]] }, } local function run(code) if type(code) == "string" and code ~= "" then local fn = load(code) if fn then pcall(fn) end end end local theme_plugin_names = { "catppuccin", "monokai", "neon" } local function load_theme_plugins() local lz = require("lz.n") for _, name in ipairs(theme_plugin_names) do pcall(lz.trigger_load, name) end end local function apply_saved_theme() local f = io.open(vim.fn.stdpath("data") .. "/themery/state.json", "r") if not f then return end local ok, data = pcall(vim.json.decode, f:read("*a")) f:close() if not ok or type(data) ~= "table" or not data.colorscheme then return end local lz = require("lz.n") pcall(lz.trigger_load, data.colorscheme) run(data.globalBeforeCode) run(data.beforeCode) if pcall(vim.cmd.colorscheme, data.colorscheme) then run(data.afterCode) run(data.globalAfterCode) return end for _, theme in ipairs(themes) do pcall(lz.trigger_load, theme.colorscheme) if pcall(vim.cmd.colorscheme, theme.colorscheme) then return end end end vim.keymap.set("n", "mt", "Themery", { desc = "Open Themery" }) return { { src = "https://github.com/catppuccin/nvim", name = "catppuccin", spec = { "catppuccin", colorscheme = "catppuccin", after = function() require("catppuccin").setup({ flavor = "mocha" }) end, }, }, { src = "https://github.com/tanvirtin/monokai.nvim", name = "monokai", spec = { "monokai", colorscheme = "monokai" }, }, { src = "https://github.com/rafamadriz/neon", name = "neon", spec = { "neon", colorscheme = "neon" }, }, { src = "https://github.com/zaldih/themery.nvim", name = "themery", spec = { "themery", cmd = "Themery", beforeAll = function() load_theme_plugins() apply_saved_theme() end, after = function() require("themery").setup({ themes = themes }) end, }, }, }