From 19c7ec478714b38fc1c62ce2515b0df0f5e004e3 Mon Sep 17 00:00:00 2001 From: nullchilly Date: Sun, 17 Jul 2022 00:26:34 +0700 Subject: [PATCH] fix(compiler): after_loading hook --- README.md | 4 ++-- lua/catppuccin/init.lua | 14 +++++++------- lua/catppuccin/lib/compiler.lua | 12 ++---------- lua/catppuccin/lib/highlighter.lua | 1 - 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index aac3b57..831ec2a 100644 --- a/README.md +++ b/README.md @@ -492,14 +492,14 @@ vim.api.nvim_create_autocmd("OptionSet", { }) ``` +For people who are hybrid between light and dark mode! + #### Abnormal colors? You need to enable [truecolor](https://wiki.archlinux.org/title/Color_output_in_console#True_color_support) Related: [:h termguicolors](https://neovim.io/doc/user/options.html#'termguicolors'), [catppuccin/nvim#182](https://github.com/catppuccin/nvim/issues/182), -For people who are hybrid between light and dark mode! - ## 💝 Thanks to - [Pocco81](https://github.com/Pocco81) diff --git a/lua/catppuccin/init.lua b/lua/catppuccin/init.lua index 896fa86..35d6b07 100644 --- a/lua/catppuccin/init.lua +++ b/lua/catppuccin/init.lua @@ -27,7 +27,7 @@ function M.load() catppuccin.before_loading() end - local loaded = nil + local compiled = nil local config = require("catppuccin.config").options if config.compile.enabled == true then @@ -40,19 +40,19 @@ function M.load() if f ~= nil then io.close(f) vim.cmd("luafile " .. compiled_path) - loaded = true + compiled = true end end - if not loaded then -- colorscheme gets evaluated from mapper.lua + if not compiled then -- colorscheme gets evaluated from mapper.lua require("catppuccin.lib.highlighter").load(require("catppuccin.lib.mapper").apply()) + end - if catppuccin.after_loading ~= nil then - catppuccin.after_loading() - end + if catppuccin.after_loading ~= nil then + catppuccin.after_loading() end - vim.api.nvim_exec_autocmds("User", { pattern = "CatppuccinLoaded" }) + vim.api.nvim_exec_autocmds("User", { pattern = "Catppuccincompiled" }) end function M.setup(custom_opts) diff --git a/lua/catppuccin/lib/compiler.lua b/lua/catppuccin/lib/compiler.lua index 36b7a4b..5d08429 100644 --- a/lua/catppuccin/lib/compiler.lua +++ b/lua/catppuccin/lib/compiler.lua @@ -49,19 +49,11 @@ vim.g.colors_name = "catppuccin"]], table.insert(lines, fmt([[vim.api.nvim_set_hl(0, "%s", { link = "%s" })]], group, color.link)) else if color.style then - if color.style ~= "NONE" then - if type(color.style) == "table" then - for _, style in ipairs(color.style) do - color[style] = true - end - else - color[color.style] = true - end + for _, style in ipairs(color.style) do + color[style] = true end end - color.style = nil - vim.api.nvim_set_hl(0, group, color) table.insert(lines, fmt([[vim.api.nvim_set_hl(0, "%s", %s)]], group, inspect(color))) end end diff --git a/lua/catppuccin/lib/highlighter.lua b/lua/catppuccin/lib/highlighter.lua index d9ad6c0..d3476fe 100644 --- a/lua/catppuccin/lib/highlighter.lua +++ b/lua/catppuccin/lib/highlighter.lua @@ -12,7 +12,6 @@ function M.highlight(group, color) color[style] = true end end - color.style = nil vim.api.nvim_set_hl(0, group, color) end