|
| 1 | +local status, themer = pcall(require, "themer") |
| 2 | +if (not status) then return end |
| 3 | + |
| 4 | +themer.setup({ |
| 5 | + -- colorscheme = "nord", |
| 6 | + transparent = false, |
| 7 | + styles = { |
| 8 | + comment = { style = "italic" }, |
| 9 | + keyword = { style = "italic,bold" }, |
| 10 | + }, |
| 11 | + enable_installer = true, |
| 12 | +}) |
| 13 | + |
| 14 | +-- Configure initial theme - nordfox (this is not in Themer) |
| 15 | +local utils = require "core.utils" |
| 16 | +local cmd = vim.cmd |
| 17 | +local fn = vim.fn |
| 18 | +local nightfox_themer_path = fn.stdpath("data") .. "/themer/nightfox.nvim" |
| 19 | +local group_name = "ThemerInit" |
| 20 | +local nightfox_theme = "EdenEast/nightfox.nvim" |
| 21 | + |
| 22 | +local create_themer_autocmd = function () |
| 23 | + vim.api.nvim_create_autocmd("ChanOpen", { |
| 24 | + group = vim.api.nvim_create_augroup(group_name, {}), |
| 25 | + callback = function () |
| 26 | + local chans = vim.api.nvim_list_chans() |
| 27 | + local themer_job_id |
| 28 | + |
| 29 | + for _, value in ipairs(chans) do |
| 30 | + local correct_job_argv = "https://github.com/" .. nightfox_theme |
| 31 | + local is_themer_job = value.argv ~= nil and utils.table_has_value(value.argv, correct_job_argv) |
| 32 | + |
| 33 | + if is_themer_job then |
| 34 | + themer_job_id = value.id |
| 35 | + break |
| 36 | + end |
| 37 | + end |
| 38 | + |
| 39 | + if themer_job_id ~= nil then |
| 40 | + fn.jobwait({ themer_job_id }) |
| 41 | + vim.api.nvim_del_augroup_by_name(group_name) |
| 42 | + require("themer.modules.installer.load_installed").load_installed_themes() |
| 43 | + vim.schedule(function () |
| 44 | + cmd [[colorscheme nordfox]] |
| 45 | + cmd [[colorscheme nordfox]] |
| 46 | + end) |
| 47 | + end |
| 48 | + end, |
| 49 | + once = true, |
| 50 | + }) |
| 51 | +end |
| 52 | + |
| 53 | +if fn.empty(fn.glob(nightfox_themer_path)) > 0 then |
| 54 | + create_themer_autocmd() |
| 55 | + |
| 56 | + local themer_installer_utils = require "themer.modules.installer.utils" |
| 57 | + themer_installer_utils.install(nightfox_theme) |
| 58 | +else |
| 59 | + cmd [[colorscheme nordfox]] |
| 60 | +end |
0 commit comments