feat: reworked dimming feature with new lib ui

dev
Pocco81 2 years ago
parent d87fa3a826
commit 97c972aa86

@ -2,9 +2,13 @@
local config = {}
config.options = {
dim_inactive = false,
transparent_background = false,
term_colors = false,
dim_inactive = {
enable = true,
shade = "dark",
percentage = 10
},
styles = {
comments = "italic",
conditionals = "italic",

@ -3,10 +3,9 @@ local M = {}
function M.get(cp)
local cnf = require("catppuccin.config").options
local transparent_background = cnf.transparent_background
local dim_inactive = cnf.dim_inactive
local bg_highlight = (transparent_background and dim_inactive and cp.dim)
local bg_highlight = (transparent_background and cnf.dim_inactive.enable and cp.dim)
or (transparent_background and "NONE")
or (dim_inactive and cp.dim)
or (cnf.dim_inactive.enable and cp.dim)
or cp.base
local inactive_bg = transparent_background and "NONE" or cp.mantle

@ -2,9 +2,9 @@ local M = {}
function M.get(cp)
local cnf = require("catppuccin.config").options
local bg_highlight = (cnf.transparent_background and cnf.dim_inactive and cp.dim)
local bg_highlight = (cnf.transparent_background and cnf.dim_inactive.enable and cp.dim)
or (cnf.transparent_background and "NONE")
or (cnf.dim_inactive and cp.dim)
or (cnf.dim_inactive.enable and cp.dim)
or cp.base
return {
GitSignsAdd = { fg = cp.green, bg = bg_highlight }, -- diff mode: Added line |diff.txt|

@ -3,10 +3,9 @@ local M = {}
function M.get(cp)
local cnf = require("catppuccin.config").options
local transparent_background = cnf.transparent_background
local dim_inactive = cnf.dim_inactive
local bg_highlight = (transparent_background and dim_inactive and cp.dim)
local bg_highlight = (transparent_background and cnf.dim_inactive.enable and cp.dim)
or (transparent_background and "NONE")
or (dim_inactive and cp.dim)
or (cnf.dim_inactive.enable and cp.dim)
or cp.base
return {
rainbowcol1 = { bg = bg_highlight, fg = cp.red },

@ -1,5 +1,5 @@
local colors_util = require("catppuccin.utils.colors")
local util = require("catppuccin.utils.util")
local ucolors = require("catppuccin.ucolors.ucolors")
local lui = require("catppuccin.lib.ui")
local cp
local M = {}
@ -10,7 +10,7 @@ local function get_properties()
background = "dark",
}
if colors_util.assert_brightness(cp.base) then
if ucolors.assert_brightness(cp.base) then
props["background"] = "light"
end
@ -18,8 +18,6 @@ local function get_properties()
end
local function get_base()
cp.none = "NONE"
return {
Comment = { fg = cp.surface2, style = cnf.styles.comments }, -- just comments
ColorColumn = { bg = cp.surface0 }, -- used for the columns set with 'colorcolumn'
@ -29,9 +27,9 @@ local function get_base()
CursorIM = { fg = cp.base, bg = cp.text }, -- like Cursor, but used when in IME mode |CursorIM|
CursorColumn = { bg = cp.mantle }, -- Screen-column at the cursor, when 'cursorcolumn' is secp.
CursorLine = {
bg = colors_util.vary_color(
{ latte = util.lighten(cp.mantle, 0.70, cp.base) },
util.darken(cp.surface0, 0.64, cp.base)
bg = ucolors.vary_color(
{ latte = ucolors.lighten(cp.mantle, 0.70, cp.base) },
ucolors.darken(cp.surface0, 0.64, cp.base)
),
}, -- Screen-line at the cursor, when 'cursorline' is secp. Low-priority if forecrust (ctermfg OR guifg) is not secp.
Directory = { fg = cp.blue }, -- directory names (and other special names in listings)
@ -43,7 +41,7 @@ local function get_base()
SignColumn = { bg = cnf.transparent_background and cp.none or cp.base, fg = cp.surface1 }, -- column where |signs| are displayed
SignColumnSB = { bg = cp.crust, fg = cp.surface1 }, -- column where |signs| are displayed
Substitute = { bg = cp.surface1, fg = cp.pink }, -- |:substitute| replacement text highlighting
LineNr = { fg = cp.surface1 }, -- colors_util.vary_color({latte = cp.crust}, cp.surface1) }, -- Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is secp.
LineNr = { fg = cp.surface1 }, -- colors_ucolors.vary_color({latte = cp.crust}, cp.surface1) }, -- Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is secp.
CursorLineNr = { fg = cp.lavender }, -- Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line. highlights the number in numberline.
MatchParen = { fg = cp.peach, style = "bold" }, -- The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt|
ModeMsg = { fg = cp.text, style = "bold" }, -- 'showmode' message (e.g., "-- INSERT -- ")
@ -54,8 +52,8 @@ local function get_base()
Normal = { fg = cp.text, bg = cnf.transparent_background and cp.none or cp.base }, -- normal text
NormalNC = {
fg = cp.text,
bg = (cnf.transparent_background and cnf.dim_inactive and cp.dim)
or (cnf.dim_inactive and cp.dim)
bg = (cnf.transparent_background and cnf.dim_inactive.enable and cp.dim)
or (cnf.dim_inactive.enable and cp.dim)
or (cnf.transparent_background and cp.none)
or cp.base,
}, -- normal text in non-current windows
@ -208,11 +206,8 @@ local function get_integrations()
end
end
final_integrations = vim.tbl_deep_extend(
"force",
final_integrations,
require("catppuccin.core.remaps").get_hig_remaps() or {}
)
final_integrations =
vim.tbl_deep_extend("force", final_integrations, require("catppuccin.core.remaps").get_hig_remaps() or {})
return final_integrations
end
@ -224,6 +219,9 @@ function M.apply()
_G.cnf = require("catppuccin.config").options
cp = require("catppuccin.core.palettes.init").get_palette()
cp.none = "NONE"
cp.dim = lui.dim()
local theme = {}
theme.properties = get_properties() -- nvim settings
theme.base = get_base() -- basic hi groups

@ -0,0 +1,15 @@
local M = {}
local cp = require("catppuccin.core.palettes.init").get_palette()
local cnf = require("catppuccin.config").options
local dim_percentage = cnf.dim_inactive.percentage
local ucolors = require("catppuccin.ucolors.ucolors")
function M.dim()
if cnf.dim_inactive.shade == "dark" then
return ucolors.darken(cp.base, dim_percentage, cp.crust)
end
return ucolors.lighten(cp.base, dim_percentage, cp.surface0)
end
return M
Loading…
Cancel
Save