From 60c42920c9481968b14b5b7a565e956e1fde8dcb Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Thu, 7 Jul 2022 16:22:43 -0600 Subject: [PATCH 1/5] Add config for dimming inactive windows --- README.md | 3 +++ lua/catppuccin/config.lua | 3 ++- lua/catppuccin/core/mapper.lua | 8 +++++++- lua/catppuccin/core/palettes/frappe.lua | 1 + lua/catppuccin/core/palettes/latte.lua | 3 ++- lua/catppuccin/core/palettes/macchiato.lua | 1 + lua/catppuccin/core/palettes/mocha.lua | 1 + 7 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e063ed3..10f9e78 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ Plugin 'catppuccin/nvim', {'name': 'catppuccin'} There are already some sane defaults that you may like, however you can change them to match your taste. These are the defaults: ```lua +dim_inactive = false, transparent_background = false, term_colors = false, styles = { @@ -213,6 +214,8 @@ This settings are unrelated to any group and are independent. - `transparent_background`: (Boolean) if true, disables setting the background color. - `term_colors`: (Boolean) if true, sets terminal colors (e.g. `g:terminal_color_0`). +- `dim_inactive`: (Boolean) if true, dims the background color of inactive + window or buffer or split. #### Styles diff --git a/lua/catppuccin/config.lua b/lua/catppuccin/config.lua index 3ae05e9..6753af1 100644 --- a/lua/catppuccin/config.lua +++ b/lua/catppuccin/config.lua @@ -2,6 +2,7 @@ local config = {} config.options = { + dim_inactive = false, transparent_background = false, term_colors = false, styles = { @@ -35,7 +36,7 @@ config.options = { information = "underline", }, }, - coc_nvim = false, + coc_nvim = false, lsp_trouble = false, cmp = true, lsp_saga = false, diff --git a/lua/catppuccin/core/mapper.lua b/lua/catppuccin/core/mapper.lua index 579ecd0..fac7d4b 100644 --- a/lua/catppuccin/core/mapper.lua +++ b/lua/catppuccin/core/mapper.lua @@ -52,7 +52,13 @@ local function get_base() MoreMsg = { fg = cp.blue }, -- |more-prompt| NonText = { fg = cp.overlay0 }, -- '@' at the end of the window, characters from 'showbreak' and other characters that do not really exist in the text (e.g., ">" displayed when a double-wide character doesn't fit at the end of the line). See also |hl-EndOfBuffer|. 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 cp.none or cp.base }, -- normal text in non-current windows + NormalNC = { + fg = cp.text, + bg = (cnf.transparent_background and cnf.dim_inactive and cp.dim) + or (cnf.dim_inactive and cp.dim) + or (cnf.transparent_background and cp.none) + or cp.base, + }, -- normal text in non-current windows NormalSB = { fg = cp.text, bg = cp.crust }, -- normal text in non-current windows NormalFloat = { fg = cp.text, bg = cp.mantle }, -- Normal text in floating windows. FloatBorder = { fg = cp.blue }, diff --git a/lua/catppuccin/core/palettes/frappe.lua b/lua/catppuccin/core/palettes/frappe.lua index 3f58b4a..f54fc7d 100644 --- a/lua/catppuccin/core/palettes/frappe.lua +++ b/lua/catppuccin/core/palettes/frappe.lua @@ -32,6 +32,7 @@ local color_palette = { base = "#303446", mantle = "#292C3C", crust = "#232634", + dim = "#444858", } return color_palette diff --git a/lua/catppuccin/core/palettes/latte.lua b/lua/catppuccin/core/palettes/latte.lua index bfd72a5..2e3c967 100644 --- a/lua/catppuccin/core/palettes/latte.lua +++ b/lua/catppuccin/core/palettes/latte.lua @@ -29,9 +29,10 @@ local color_palette = { surface1 = "#BCC0CC", surface0 = "#CCD0DA", + base = "#EFF1F5", crust = "#DCE0E8", mantle = "#E6E9EF", - base = "#EFF1F5", + dim = "#D7D8DC", } return color_palette diff --git a/lua/catppuccin/core/palettes/macchiato.lua b/lua/catppuccin/core/palettes/macchiato.lua index 39f40f3..9580896 100644 --- a/lua/catppuccin/core/palettes/macchiato.lua +++ b/lua/catppuccin/core/palettes/macchiato.lua @@ -32,6 +32,7 @@ local color_palette = { base = "#24273A", mantle = "#1E2030", crust = "#181926", + dim = "#393C4D", } return color_palette diff --git a/lua/catppuccin/core/palettes/mocha.lua b/lua/catppuccin/core/palettes/mocha.lua index c8df2da..211921f 100644 --- a/lua/catppuccin/core/palettes/mocha.lua +++ b/lua/catppuccin/core/palettes/mocha.lua @@ -32,6 +32,7 @@ local color_palette = { base = "#1E1E2E", mantle = "#181825", crust = "#11111B", + dim = "#343442", } return color_palette From 863500ba19d49e30a399f8bf99d19871b46f3b09 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Thu, 7 Jul 2022 23:40:38 -0600 Subject: [PATCH 2/5] Support dim_inactive with existing integrations --- .../core/integrations/bufferline.lua | 47 ++++++++++--------- lua/catppuccin/core/integrations/gitsigns.lua | 11 +++-- .../core/integrations/ts_rainbow.lua | 23 +++++---- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/lua/catppuccin/core/integrations/bufferline.lua b/lua/catppuccin/core/integrations/bufferline.lua index a2c4a0a..1667ce6 100644 --- a/lua/catppuccin/core/integrations/bufferline.lua +++ b/lua/catppuccin/core/integrations/bufferline.lua @@ -1,29 +1,34 @@ local M = {} function M.get(cp) - local transparent_background = require("catppuccin.config").options.transparent_background - local bg_highlight = transparent_background and "NONE" or cp.base + 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) + or (transparent_background and "NONE") + or (dim_inactive and cp.dim) + or cp.base - local inactive_bg = transparent_background and "NONE" or cp.mantle + local inactive_bg = transparent_background and "NONE" or cp.mantle - return { - BufferLineFill = { bg = bg_highlight }, - BufferLineBackcrust = { fg = cp.text, bg = inactive_bg }, -- others - BufferLineBufferVisible = { fg = cp.surface1, bg = inactive_bg }, - BufferLineBufferSelected = { fg = cp.text, bg = cp.base, style = "bold,italic" }, -- current - BufferLineTab = { fg = cp.surface1, bg = cp.base }, - BufferLineTabSelected = { fg = cp.red, bg = cp.blue }, - BufferLineTabClose = { fg = cp.red, bg = inactive_bg }, - BufferLineIndicatorSelected = { fg = cp.peach, bg = cp.base }, - -- separators - BufferLineSeparator = { fg = inactive_bg, bg = inactive_bg }, - BufferLineSeparatorVisible = { fg = inactive_bg, bg = inactive_bg }, - BufferLineSeparatorSelected = { fg = inactive_bg, bg = inactive_bg }, - -- close buttons - BufferLineCloseButton = { fg = cp.surface1, bg = inactive_bg }, - BufferLineCloseButtonVisible = { fg = cp.surface1, bg = inactive_bg }, - BufferLineCloseButtonSelected = { fg = cp.red, bg = cp.base }, - } + return { + BufferLineFill = { bg = bg_highlight }, + BufferLineBackcrust = { fg = cp.text, bg = inactive_bg }, -- others + BufferLineBufferVisible = { fg = cp.surface1, bg = inactive_bg }, + BufferLineBufferSelected = { fg = cp.text, bg = cp.base, style = "bold,italic" }, -- current + BufferLineTab = { fg = cp.surface1, bg = cp.base }, + BufferLineTabSelected = { fg = cp.red, bg = cp.blue }, + BufferLineTabClose = { fg = cp.red, bg = inactive_bg }, + BufferLineIndicatorSelected = { fg = cp.peach, bg = cp.base }, + -- separators + BufferLineSeparator = { fg = inactive_bg, bg = inactive_bg }, + BufferLineSeparatorVisible = { fg = inactive_bg, bg = inactive_bg }, + BufferLineSeparatorSelected = { fg = inactive_bg, bg = inactive_bg }, + -- close buttons + BufferLineCloseButton = { fg = cp.surface1, bg = inactive_bg }, + BufferLineCloseButtonVisible = { fg = cp.surface1, bg = inactive_bg }, + BufferLineCloseButtonSelected = { fg = cp.red, bg = cp.base }, + } end return M diff --git a/lua/catppuccin/core/integrations/gitsigns.lua b/lua/catppuccin/core/integrations/gitsigns.lua index 19b0130..6110a76 100644 --- a/lua/catppuccin/core/integrations/gitsigns.lua +++ b/lua/catppuccin/core/integrations/gitsigns.lua @@ -1,10 +1,15 @@ 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) + or (cnf.transparent_background and "NONE") + or (cnf.dim_inactive and cp.dim) + or cp.base return { - GitSignsAdd = { fg = cp.green, bg = cnf.transparent_background and cp.none or cp.base }, -- diff mode: Added line |diff.txt| - GitSignsChange = { fg = cp.yellow, bg = cnf.transparent_background and cp.none or cp.base }, -- diff mode: Changed line |diff.txt| - GitSignsDelete = { fg = cp.red, bg = cnf.transparent_background and cp.none or cp.base }, -- diff mode: Deleted line |diff.txt| + GitSignsAdd = { fg = cp.green, bg = bg_highlight }, -- diff mode: Added line |diff.txt| + GitSignsChange = { fg = cp.yellow, bg = bg_highlight }, -- diff mode: Changed line |diff.txt| + GitSignsDelete = { fg = cp.red, bg = bg_highlight }, -- diff mode: Deleted line |diff.txt| } end diff --git a/lua/catppuccin/core/integrations/ts_rainbow.lua b/lua/catppuccin/core/integrations/ts_rainbow.lua index 1197c36..7b505a9 100644 --- a/lua/catppuccin/core/integrations/ts_rainbow.lua +++ b/lua/catppuccin/core/integrations/ts_rainbow.lua @@ -1,16 +1,21 @@ local M = {} function M.get(cp) - local transparent_background = require("catppuccin.config").options.transparent_background - local bg_highlight = transparent_background and "NONE" or cp.base + 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) + or (transparent_background and "NONE") + or (dim_inactive and cp.dim) + or cp.base return { - rainbowcol1 = {bg = bg_highlight, fg = cp.red}, - rainbowcol2 = {bg = bg_highlight, fg = cp.teal}, - rainbowcol3 = {bg = bg_highlight, fg = cp.yellow}, - rainbowcol4 = {bg = bg_highlight, fg = cp.blue}, - rainbowcol5 = {bg = bg_highlight, fg = cp.pink}, - rainbowcol6 = {bg = bg_highlight, fg = cp.flamingo}, - rainbowcol7 = {bg = bg_highlight, fg = cp.green}, + rainbowcol1 = { bg = bg_highlight, fg = cp.red }, + rainbowcol2 = { bg = bg_highlight, fg = cp.teal }, + rainbowcol3 = { bg = bg_highlight, fg = cp.yellow }, + rainbowcol4 = { bg = bg_highlight, fg = cp.blue }, + rainbowcol5 = { bg = bg_highlight, fg = cp.pink }, + rainbowcol6 = { bg = bg_highlight, fg = cp.flamingo }, + rainbowcol7 = { bg = bg_highlight, fg = cp.green }, } end From 7f2bdf5ed513b06384309dcab4ef739e9442251a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Salas?= Date: Sat, 9 Jul 2022 19:58:20 -0400 Subject: [PATCH 3/5] docs(README): fix coc tab spacing --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 10f9e78..50f4fd0 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ integrations = { information = "underline", }, }, - coc_nvim = false, + coc_nvim = false, lsp_trouble = false, cmp = true, lsp_saga = false, From d87fa3a826a28c309f066c3464edd2a4a1205700 Mon Sep 17 00:00:00 2001 From: frdrkolsson Date: Wed, 29 Jun 2022 11:52:40 +0200 Subject: [PATCH 4/5] Show file modified in feline plugin --- lua/catppuccin/core/integrations/feline.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/catppuccin/core/integrations/feline.lua b/lua/catppuccin/core/integrations/feline.lua index 37f1be1..b2a347c 100644 --- a/lua/catppuccin/core/integrations/feline.lua +++ b/lua/catppuccin/core/integrations/feline.lua @@ -145,7 +145,7 @@ components.active[1][3] = { hl = vi_mode_hl, } --- there is a dilema: we need to hide Diffs if ther is no git info. We can do that, but this will +-- there is a dilema: we need to hide Diffs if there is no git info. We can do that, but this will -- leave the right_semicircle colored with purple, and since we can't change the color conditonally -- then the solution is to create two right_semicircles: one with a mauve sett.bkg and the other one normal -- sett.bkg; both have the same fg (vi mode). The mauve one appears if there is git info, else the one with @@ -394,7 +394,7 @@ components.active[3][3] = { icon = "  " return icon end - return " " .. icon .. " " .. filename .. " " + return "%m" .. " " .. icon .. " " .. filename .. " " end, enabled = is_enabled(shortline, winid, 70), hl = { From 97c972aa866e687550c5bd46b7e29e81515b11d9 Mon Sep 17 00:00:00 2001 From: Pocco81 Date: Mon, 11 Jul 2022 14:13:01 -0500 Subject: [PATCH 5/5] feat: reworked dimming feature with new lib ui --- lua/catppuccin/config.lua | 6 +++- .../core/integrations/bufferline.lua | 5 ++-- lua/catppuccin/core/integrations/gitsigns.lua | 4 +-- .../core/integrations/ts_rainbow.lua | 5 ++-- lua/catppuccin/core/mapper.lua | 30 +++++++++---------- lua/catppuccin/lib/ui.lua | 15 ++++++++++ 6 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 lua/catppuccin/lib/ui.lua diff --git a/lua/catppuccin/config.lua b/lua/catppuccin/config.lua index 6753af1..e6de7a8 100644 --- a/lua/catppuccin/config.lua +++ b/lua/catppuccin/config.lua @@ -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", diff --git a/lua/catppuccin/core/integrations/bufferline.lua b/lua/catppuccin/core/integrations/bufferline.lua index 1667ce6..bf17205 100644 --- a/lua/catppuccin/core/integrations/bufferline.lua +++ b/lua/catppuccin/core/integrations/bufferline.lua @@ -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 diff --git a/lua/catppuccin/core/integrations/gitsigns.lua b/lua/catppuccin/core/integrations/gitsigns.lua index 6110a76..1642107 100644 --- a/lua/catppuccin/core/integrations/gitsigns.lua +++ b/lua/catppuccin/core/integrations/gitsigns.lua @@ -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| diff --git a/lua/catppuccin/core/integrations/ts_rainbow.lua b/lua/catppuccin/core/integrations/ts_rainbow.lua index 7b505a9..ef0061e 100644 --- a/lua/catppuccin/core/integrations/ts_rainbow.lua +++ b/lua/catppuccin/core/integrations/ts_rainbow.lua @@ -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 }, diff --git a/lua/catppuccin/core/mapper.lua b/lua/catppuccin/core/mapper.lua index fac7d4b..1412b8c 100644 --- a/lua/catppuccin/core/mapper.lua +++ b/lua/catppuccin/core/mapper.lua @@ -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 diff --git a/lua/catppuccin/lib/ui.lua b/lua/catppuccin/lib/ui.lua new file mode 100644 index 0000000..73b2884 --- /dev/null +++ b/lua/catppuccin/lib/ui.lua @@ -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