Skip to content

Commit

Permalink
fix(transparent): winblend and popup (#403)
Browse files Browse the repository at this point in the history
* fix(transparent): winblend and popup

* fix(compile): cache winblend & pumblend

* fix(compile): vim.o is not valid for vim
  • Loading branch information
nullchilly authored Feb 12, 2023
1 parent 238d1e9 commit a5f3ed5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
7 changes: 5 additions & 2 deletions lua/catppuccin/groups/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ function M.get()
or C.base,
}, -- normal text in non-current windows
NormalSB = { fg = C.text, bg = C.crust }, -- normal text in non-current windows
NormalFloat = { fg = C.text, bg = O.transparent_background and C.none or C.mantle }, -- Normal text in floating windows.
NormalFloat = { fg = C.text, bg = (O.transparent_background and vim.o.winblend == 0) and C.none or C.mantle }, -- Normal text in floating windows.
FloatBorder = { fg = C.blue },
Pmenu = { bg = O.transparent_background and C.none or U.darken(C.surface0, 0.8, C.crust), fg = C.overlay2 }, -- Popup menu: normal item.
Pmenu = {
bg = (O.transparent_background and vim.o.pumblend == 0) and C.none or U.darken(C.surface0, 0.8, C.crust),
fg = C.overlay2,
}, -- Popup menu: normal item.
PmenuSel = { fg = C.text, bg = C.surface1, style = { "bold" } }, -- Popup menu: selected item.
PmenuSbar = { bg = C.surface1 }, -- Popup menu: scrollbar.
PmenuThumb = { bg = C.overlay0 }, -- Popup menu: Thumb of the scrollbar.
Expand Down
13 changes: 0 additions & 13 deletions lua/catppuccin/groups/integrations/noice.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,10 @@ function M.get()
NoiceCmdline = { fg = C.text },
NoiceCmdlineIcon = { fg = C.sky, style = virtual_text.information },
NoiceCmdlineIconSearch = { fg = C.yellow },
NoiceCmdlinePopup = { fg = C.text, bg = O.transparent_background and C.none or C.base },
NoiceCmdlinePopupBorder = { fg = C.lavender },
NoiceCmdlinePopupBorderSearch = { fg = C.yellow },
NoiceConfirm = { fg = C.text, bg = O.transparent_background and C.none or C.base },
NoiceConfirmBorder = { fg = C.blue },
NoiceMini = { fg = C.text },
NoicePopup = { fg = C.text, bg = O.transparent_background and C.none or C.mantle },
NoicePopupBorder = { link = "FloatBorder" },
NoicePopupmenu = { link = "Pmenu" },
NoicePopupmenuBorder = { link = "FloatBorder" },
NoicePopupmenuMatch = { link = "Special" },
NoicePopupmenuSelected = { link = "PmenuSel" },
NoiceScrollbar = { link = "PmenuSbar" },
NoiceScrollbarThumb = { link = "PmenuThumb" },
NoiceSplit = { fg = C.text, bg = O.transparent_background and C.none or C.mantle },
NoiceSplitBorder = { link = "FloatBorder" },
NoiceVirtualText = { link = "DiagnosticVirtualTextInfo" },
}
end

Expand Down
1 change: 0 additions & 1 deletion lua/catppuccin/groups/integrations/which_key.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ function M.get()
WhichKeyGroup = { fg = C.blue },
WhichKeySeperator = { fg = C.overlay0 },
WhichKeyDesc = { fg = C.pink },
WhichKeyFloat = { bg = O.transparent_background and C.none or C.crust },
WhichKeyBorder = { fg = C.blue },
WhichKeyValue = { fg = C.overlay0 },
}
Expand Down
7 changes: 5 additions & 2 deletions lua/catppuccin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ local function get_flavour(default)
if default then
flavour = default
elseif vim.g.colors_name == "catppuccin" then -- after first time load
flavour = M.options.background[is_vim and vim.eval "&background" or vim.o.background]
flavour = M.options.background[vim.o.background]
else
flavour = M.flavour -- first time load
end
Expand Down Expand Up @@ -139,7 +139,10 @@ function M.setup(user_conf)

local git_path = debug.getinfo(1).source:sub(2, -24) .. ".git" .. M.path_sep .. "ORIG_HEAD"
local git = vim.fn.getftime(git_path) -- 2x faster vim.loop.fs_stat
local hash = require("catppuccin.lib.hashing").hash(user_conf) .. (git == -1 and git_path or git) -- no .git in /nix/store -> cache path
local hash = require("catppuccin.lib.hashing").hash(user_conf)
.. (git == -1 and git_path or git) -- no .git in /nix/store -> cache path
.. (vim.o.winblend == 0 and 1 or 0) -- :h winblend
.. (vim.o.pumblend == 0 and 1 or 0) -- :h pumblend

if cached ~= hash then
M.compile()
Expand Down
2 changes: 1 addition & 1 deletion lua/catppuccin/lib/vim/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ endif
set termguicolors
let g:colors_name = "catppuccin"]],
}
table.insert(lines, "set background=" .. (flavour == "latte" and [["light"]] or [["dark"]]))
table.insert(lines, "set background=" .. (flavour == "latte" and [[light]] or [[dark]]))

local tbl = vim.tbl_deep_extend("keep", theme.custom_highlights, theme.integrations, theme.syntax, theme.editor)

Expand Down
6 changes: 6 additions & 0 deletions lua/catppuccin/lib/vim/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
-- TODO: private _G.vim
vim.command [[command! CatppuccinCompile lua require('catppuccin').compile() print("Catppuccin (info): compiled cache!")]]

vim.o = setmetatable({}, {
__index = function(_, k)
if k == "background" then return vim.eval "&background" end
end,
})

vim.fn.stdpath = function(what)
if what ~= "cache" then return end
if package.config:sub(1, 1) == "\\" then
Expand Down

0 comments on commit a5f3ed5

Please sign in to comment.