Integrate seamless, automatic, and persistent colorscheme switching for all neovim
plugins in my config
This commit is contained in:
parent
76a2e58ab8
commit
9c5a1479b7
7 changed files with 277 additions and 262 deletions
|
|
@ -1,16 +0,0 @@
|
|||
local has_generated = false
|
||||
local colors = require("ayu.colors")
|
||||
colors.generate(true)
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.get()
|
||||
if not has_generated then
|
||||
colors.generate(true)
|
||||
has_generated = true
|
||||
end
|
||||
|
||||
return colors
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -1,18 +1,19 @@
|
|||
local theme_colors = require("ayu.colors")
|
||||
theme_colors.generate(true)
|
||||
-- These are not apart of the Ayu color theme, however, I needed these
|
||||
-- colors while still fitting in with the rest
|
||||
local ayu_turquoise = "#5CCFE6"
|
||||
local ayu_dark_blue = "#3A7BD5"
|
||||
local utils = require("utils")
|
||||
|
||||
local colors = {
|
||||
local function setup_colors()
|
||||
-- These are not apart of the Ayu color theme, however, I needed these
|
||||
-- colors while still fitting in with the rest
|
||||
local ayu_turquoise = "#5CCFE6"
|
||||
local ayu_dark_blue = "#3A7BD5"
|
||||
|
||||
local colors = {
|
||||
info = ayu_dark_blue,
|
||||
hint = ayu_turquoise,
|
||||
warning = theme_colors.warning,
|
||||
error = theme_colors.error,
|
||||
}
|
||||
warning = utils.ayu_colors.warning,
|
||||
error = utils.ayu_colors.error,
|
||||
}
|
||||
|
||||
for _, highlight in ipairs({
|
||||
for _, highlight in ipairs({
|
||||
{ "DiagnosticUnderlineInfo", { undercurl = true, sp = colors.info } },
|
||||
{ "DiagnosticUnderlineHint", { undercurl = true, sp = colors.hint } },
|
||||
{ "DiagnosticUnderlineWarn", { undercurl = true, sp = colors.warning } },
|
||||
|
|
@ -21,10 +22,14 @@ for _, highlight in ipairs({
|
|||
{ "DiagnosticHint", { fg = colors.hint } },
|
||||
{ "DiagnosticWarn", { fg = colors.warning } },
|
||||
{ "DiagnosticError", { fg = colors.error } },
|
||||
}) do
|
||||
}) do
|
||||
vim.api.nvim_set_hl(0, highlight[1], highlight[2])
|
||||
end
|
||||
end
|
||||
|
||||
utils.create_user_event_cb("ColorsyncThemeChanged", setup_colors, "ColorsyncEvents")
|
||||
setup_colors()
|
||||
|
||||
local sev = vim.diagnostic.severity
|
||||
vim.diagnostic.config({
|
||||
underline = true,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
local uv = vim.loop
|
||||
local api = vim.api
|
||||
local utils = require("utils")
|
||||
|
||||
local function force_color_from_reference_on_others(others, reference)
|
||||
local reference_hl = vim.api.nvim_get_hl(0, { name = reference })
|
||||
|
|
@ -28,10 +28,17 @@ end
|
|||
|
||||
return {
|
||||
"Shatur/neovim-ayu",
|
||||
priority = 1010,
|
||||
config = function()
|
||||
local function set_colorscheme()
|
||||
utils.colorsync_theme = vim.fn.system({ "colorsync", "get" }):gsub("%s+", "")
|
||||
vim.o.background = utils.colorsync_theme == "ayulight" and "light" or "dark"
|
||||
|
||||
local is_mirage = utils.colorsync_theme == "ayumirage"
|
||||
|
||||
local ayu = require("ayu")
|
||||
local colors = require("ayu.colors")
|
||||
colors.generate(true)
|
||||
utils.ayu_colors = require("ayu.colors")
|
||||
utils.ayu_colors.generate(is_mirage)
|
||||
|
||||
local overrides = {
|
||||
global_variable = {
|
||||
|
|
@ -43,21 +50,21 @@ return {
|
|||
},
|
||||
namespace = {
|
||||
italic = true,
|
||||
fg = colors.markup,
|
||||
fg = utils.ayu_colors.markup,
|
||||
},
|
||||
pre_process = {
|
||||
fg = colors.keyword,
|
||||
fg = utils.ayu_colors.keyword,
|
||||
},
|
||||
default_type = {
|
||||
fg = colors.regexp
|
||||
fg = utils.ayu_colors.regexp
|
||||
},
|
||||
type = {
|
||||
fg = colors.entity,
|
||||
fg = utils.ayu_colors.entity,
|
||||
},
|
||||
}
|
||||
|
||||
ayu.setup({
|
||||
mirage = true,
|
||||
mirage = is_mirage,
|
||||
terminal = false,
|
||||
overrides = {
|
||||
-- TRANSPARENCY
|
||||
|
|
@ -106,26 +113,24 @@ return {
|
|||
},
|
||||
})
|
||||
|
||||
local function set_colorscheme()
|
||||
local active_theme = vim.fn.system({ "colorsync", "get" }):gsub("%s+", "")
|
||||
if active_theme == "ayulight" then
|
||||
api.nvim_command("colorscheme ayu-light")
|
||||
elseif active_theme == "ayumirage" then
|
||||
api.nvim_command("colorscheme ayu-mirage")
|
||||
else
|
||||
api.nvim_command("colorscheme ayu-dark")
|
||||
end
|
||||
ayu.colorscheme()
|
||||
end
|
||||
|
||||
vim.api.nvim_create_augroup("ColorsyncEvents", { clear = true })
|
||||
|
||||
local filepath = os.getenv("HOME") .. "/.local/state/colorsync/current"
|
||||
local handle = uv.new_fs_event()
|
||||
handle:start(filepath, {}, function(err, filename, status)
|
||||
handle:start(filepath, {}, function(err)
|
||||
if err then
|
||||
vim.notify("Error watching: " .. filepath .. "\n" .. err)
|
||||
return
|
||||
end
|
||||
|
||||
vim.schedule(set_colorscheme)
|
||||
vim.schedule(function()
|
||||
set_colorscheme()
|
||||
vim.api.nvim_exec_autocmds("User", { pattern = "ColorsyncThemeChanged" })
|
||||
vim.api.nvim_exec_autocmds("ColorScheme", {})
|
||||
end)
|
||||
end)
|
||||
|
||||
set_colorscheme()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
local utils = require("utils")
|
||||
|
||||
return {
|
||||
"b0o/incline.nvim",
|
||||
dependencies = {
|
||||
|
|
@ -10,9 +12,9 @@ return {
|
|||
}
|
||||
}
|
||||
},
|
||||
event = "VeryLazy",
|
||||
lazy = true,
|
||||
opts = {
|
||||
config = function()
|
||||
local function setup_incline()
|
||||
require("incline").setup({
|
||||
window = {
|
||||
padding = 0,
|
||||
},
|
||||
|
|
@ -105,8 +107,8 @@ return {
|
|||
end
|
||||
|
||||
return {
|
||||
guibg = "#1e2030",
|
||||
guifg = "#cad3f5",
|
||||
guibg = utils.ayu_colors.panel_bg,
|
||||
guifg = utils.ayu_colors.fg,
|
||||
{ " " },
|
||||
{ get_diagnostic_label() },
|
||||
{ get_git_diff() },
|
||||
|
|
@ -116,5 +118,10 @@ return {
|
|||
{ " " }
|
||||
}
|
||||
end,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
utils.create_user_event_cb("ColorsyncThemeChanged", setup_incline, "ColorsyncEvents")
|
||||
setup_incline()
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
local utils = require("utils")
|
||||
|
||||
local saved_hlsearch = false
|
||||
local saved_highlights = {}
|
||||
|
||||
|
|
@ -23,7 +25,7 @@ end
|
|||
|
||||
local function save_and_set_invisible_inlay_hints_hl()
|
||||
saved_highlights = vim.api.nvim_get_hl(0, { name = "LspInlayHint" })
|
||||
vim.api.nvim_set_hl(0, "LspInlayHint", { fg = require("colors").get().bg, bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "LspInlayHint", { fg = utils.ayu_colors.bg, bg = "none" })
|
||||
end
|
||||
|
||||
local function restore_inlay_hints_hl()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
local utils = require("utils")
|
||||
|
||||
local function resize_mode()
|
||||
if require("window_management").is_in_resizing_mode() then
|
||||
return "▲ Resizing ▼ "
|
||||
|
|
@ -26,7 +28,9 @@ return {
|
|||
},
|
||||
event = "VeryLazy",
|
||||
lazy = true,
|
||||
opts = {
|
||||
config = function()
|
||||
local function setup_lualine()
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
theme = "ayu",
|
||||
globalstatus = true,
|
||||
|
|
@ -66,5 +70,10 @@ return {
|
|||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
utils.create_user_event_cb("ColorsyncThemeChanged", setup_lualine, "ColorsyncEvents")
|
||||
setup_lualine()
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
local M = {}
|
||||
|
||||
M.colorsync_theme = nil
|
||||
M.ayu_colors = nil
|
||||
|
||||
function M.set_keymap_list(keymap_list, mode)
|
||||
mode = mode or "n"
|
||||
M.foreach(keymap_list, function(mapping)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue