From d7f081076511f1ab38279ffb7c37c0043489bddc Mon Sep 17 00:00:00 2001 From: BattleCh1cken Date: Fri, 27 May 2022 11:51:24 -0400 Subject: [PATCH 1/3] tweaked telescope colors and added custom highlights --- lua/catppuccin/config.lua | 1 + lua/catppuccin/core/integrations/telescope.lua | 10 ++++++++++ lua/catppuccin/utils/util.lua | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/lua/catppuccin/config.lua b/lua/catppuccin/config.lua index db44af1..d69ab8a 100644 --- a/lua/catppuccin/config.lua +++ b/lua/catppuccin/config.lua @@ -70,6 +70,7 @@ config.options = { telekasten = true, symbols_outline = true, }, + custom_highlights = {}, } function config.set_options(opts) diff --git a/lua/catppuccin/core/integrations/telescope.lua b/lua/catppuccin/core/integrations/telescope.lua index d32a76a..4321323 100644 --- a/lua/catppuccin/core/integrations/telescope.lua +++ b/lua/catppuccin/core/integrations/telescope.lua @@ -6,6 +6,16 @@ function M.get(cp) TelescopeSelectionCaret = { fg = cp.flamingo }, TelescopeSelection = { fg = cp.text, bg = cp.surface0, style = "bold" }, TelescopeMatching = { fg = cp.blue }, + TelescopePromptPrefix = { bg = cp.crust }, + TelescopePromptNormal = { bg = cp.crust}, + TelescopeResultsNormal = { bg = cp.mantle}, + TelescopePreviewNormal = { bg = cp.crust }, + TelescopePromptBorder = { bg = cp.crust, fg = cp.crust }, + TelescopeResultsBorder = { bg = cp.mantle, fg = cp.crust }, + TelescopePreviewBorder = { bg = cp.crust, fg = cp.crust }, + TelescopePromptTitle = { fg = cp.crust }, + TelescopeResultsTitle = { fg = cp.text }, + TelescopePreviewTitle = { fg = cp.crust }, } end diff --git a/lua/catppuccin/utils/util.lua b/lua/catppuccin/utils/util.lua index c65324a..236b337 100644 --- a/lua/catppuccin/utils/util.lua +++ b/lua/catppuccin/utils/util.lua @@ -147,12 +147,16 @@ function util.load(theme) if vim.fn.exists("syntax_on") then vim.cmd("syntax reset") end + local custom_highlights = require("catppuccin.config").options.custom_highlights + g.colors_name = "catppuccin" + util.properties(theme.properties) util.syntax(theme.base) util.syntax(theme.integrations) + util.syntax(custom_highlights) if require("catppuccin.config").options["term_colors"] then util.terminal(theme.terminal) From 37e99450cf0ce146be7c4ab863f9827ffd4d4e75 Mon Sep 17 00:00:00 2001 From: Zhong Liu Date: Sun, 26 Jun 2022 15:03:07 +0800 Subject: [PATCH 2/3] new autocmd event `CatppuccinLoaded` --- README.md | 14 ++++++++++++++ lua/catppuccin/main.lua | 2 ++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index e063ed3..284d469 100644 --- a/README.md +++ b/README.md @@ -336,6 +336,20 @@ catppuccin.before_loading = function () end ``` +#### Autocmd + +Instead of `after_loading` hook, you can use autocmd event like this: + +```lua +vim.api.nvim_create_autocmd("User", { + pattern = "CatppuccinLoaded", + callback = function() + local colors = require("catppuccin.api.colors").get_colors() + -- do something with colors + end +}) +``` + ## 💝 Thanks to - [Pocco81](https://github.com/Pocco81) diff --git a/lua/catppuccin/main.lua b/lua/catppuccin/main.lua index 16fc21c..0f96ba7 100644 --- a/lua/catppuccin/main.lua +++ b/lua/catppuccin/main.lua @@ -21,6 +21,8 @@ local function load() if catppuccin.after_loading ~= nil then catppuccin.after_loading() end + + vim.api.nvim_exec_autocmds("User", { pattern = "CatppuccinLoaded" }) end function M.main(option) From 357dc3791184a8f7edeafaddc4cf4e8b801dd9be Mon Sep 17 00:00:00 2001 From: Zhong Liu Date: Sun, 26 Jun 2022 16:06:30 +0800 Subject: [PATCH 3/3] use autocmd event instead of `after_loading` hook --- .../core/integrations/lightspeed.lua | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lua/catppuccin/core/integrations/lightspeed.lua b/lua/catppuccin/core/integrations/lightspeed.lua index 5baf2ed..4b90a9e 100644 --- a/lua/catppuccin/core/integrations/lightspeed.lua +++ b/lua/catppuccin/core/integrations/lightspeed.lua @@ -13,19 +13,14 @@ end function M.get(cp) if not get_prepared() then - local catppuccin = require("catppuccin") - if catppuccin.after_loading ~= nil then - local callback = catppuccin.after_loading - catppuccin.after_loading = function () - callback() - require'lightspeed'.init_highlight() + set_prepared(vim.api.nvim_create_autocmd("User", { + pattern = "CatppuccinLoaded", + callback = function () + if pcall(require, "lightspeed") then + require("lightspeed").init_highlight() + end end - else - catppuccin.after_loading = function () - require'lightspeed'.init_highlight() - end - end - set_prepared(true) + })) end return {