diff --git a/lua/catppuccin/config.lua b/lua/catppuccin/config.lua index 15907f5..e518fa9 100644 --- a/lua/catppuccin/config.lua +++ b/lua/catppuccin/config.lua @@ -6,8 +6,8 @@ config.options = { term_colors = false, compile = { enable = false, - path = vim.fn.stdpath "cache" .. "/catppuccin", - suffix = "_compiled" + path = vim.fn.stdpath("cache") .. "/catppuccin", + suffix = "_compiled", }, dim_inactive = { enable = false, diff --git a/lua/catppuccin/groups/integrations/coc_nvim.lua b/lua/catppuccin/groups/integrations/coc_nvim.lua index 4029d14..08db590 100644 --- a/lua/catppuccin/groups/integrations/coc_nvim.lua +++ b/lua/catppuccin/groups/integrations/coc_nvim.lua @@ -1,25 +1,25 @@ local M = {} function M.get() - local error = cp.red - local warning = cp.yellow - local info = cp.sky - local hint = cp.teal + local error = cp.red + local warning = cp.yellow + local info = cp.sky + local hint = cp.teal - return { - -- These groups are for the coc.nvim, the documentation is here (https://github.com/neoclide/coc.nvim/blob/master/doc/coc.txt#L2365). - CocErrorHighlight = { fg = error }, - CocErrorSign = { fg = error }, - CocErrorVirtualText = { fg = error }, - CocHintHighlight = { fg = hint }, - CocHintSign = { fg = hint }, - CocHintVirtualText = { fg = hint }, - CocInfoHighlight = { fg = info }, - CocInfoSign = { fg = info }, - CocInfoVirtualText = { fg = info }, - CocWarningHighlight = { fg = warning }, - CocWarningSign = { fg = warning }, - } + return { + -- These groups are for the coc.nvim, the documentation is here (https://github.com/neoclide/coc.nvim/blob/master/doc/coc.txt#L2365). + CocErrorHighlight = { fg = error }, + CocErrorSign = { fg = error }, + CocErrorVirtualText = { fg = error }, + CocHintHighlight = { fg = hint }, + CocHintSign = { fg = hint }, + CocHintVirtualText = { fg = hint }, + CocInfoHighlight = { fg = info }, + CocInfoSign = { fg = info }, + CocInfoVirtualText = { fg = info }, + CocWarningHighlight = { fg = warning }, + CocWarningSign = { fg = warning }, + } end return M diff --git a/lua/catppuccin/groups/integrations/indent_blankline.lua b/lua/catppuccin/groups/integrations/indent_blankline.lua index 484ae17..4a0da87 100644 --- a/lua/catppuccin/groups/integrations/indent_blankline.lua +++ b/lua/catppuccin/groups/integrations/indent_blankline.lua @@ -1,19 +1,18 @@ local M = {} function M.get() - local hi = { IndentBlanklineChar = { fg = cp.surface0 }, IndentBlanklineContextChar = { fg = cp.text }, } if cnf.integrations.indent_blankline.colored_indent_levels then - hi["IndentBlanklineIndent6"] = {blend = 0, fg = cp.yellow} - hi["IndentBlanklineIndent5"] = {blend = 0, fg = cp.red} - hi["IndentBlanklineIndent4"] = {blend = 0, fg = cp.teal} - hi["IndentBlanklineIndent3"] = {blend = 0, fg = cp.peach} - hi["IndentBlanklineIndent2"] = {blend = 0, fg = cp.blue} - hi["IndentBlanklineIndent1"] = {blend = 0, fg = cp.pink} + hi["IndentBlanklineIndent6"] = { blend = 0, fg = cp.yellow } + hi["IndentBlanklineIndent5"] = { blend = 0, fg = cp.red } + hi["IndentBlanklineIndent4"] = { blend = 0, fg = cp.teal } + hi["IndentBlanklineIndent3"] = { blend = 0, fg = cp.peach } + hi["IndentBlanklineIndent2"] = { blend = 0, fg = cp.blue } + hi["IndentBlanklineIndent1"] = { blend = 0, fg = cp.pink } end return hi diff --git a/lua/catppuccin/groups/integrations/leap.lua b/lua/catppuccin/groups/integrations/leap.lua index f4f75f8..4410a65 100644 --- a/lua/catppuccin/groups/integrations/leap.lua +++ b/lua/catppuccin/groups/integrations/leap.lua @@ -11,27 +11,26 @@ local function get_prepared() end function M.get() - if not get_prepared() then local catppuccin = require("catppuccin") if catppuccin.after_loading ~= nil then - catppuccin.after_loading = function () + catppuccin.after_loading = function() catppuccin.after_loading() - require'leap'.init_highlight(true) + require("leap").init_highlight(true) end else - catppuccin.after_loading = function () - require'leap'.init_highlight(true) + catppuccin.after_loading = function() + require("leap").init_highlight(true) end end set_prepared(true) end return { - LeapLabelPrimary = {bg = cp.surface1, fg = cp.text}, - LeapLabelSecondary = {bg = cp.surface1, fg = cp.text}, - LeapBackdrop = {bg = cp.base, fg = cp.overlay0}, - LeapMatch = {bg = cp.base, fg = cp.red, style = { "underline" }}, + LeapLabelPrimary = { bg = cp.surface1, fg = cp.text }, + LeapLabelSecondary = { bg = cp.surface1, fg = cp.text }, + LeapBackdrop = { bg = cp.base, fg = cp.overlay0 }, + LeapMatch = { bg = cp.base, fg = cp.red, style = { "underline" } }, } end diff --git a/lua/catppuccin/groups/integrations/lightspeed.lua b/lua/catppuccin/groups/integrations/lightspeed.lua index f4b09bb..bb19bec 100644 --- a/lua/catppuccin/groups/integrations/lightspeed.lua +++ b/lua/catppuccin/groups/integrations/lightspeed.lua @@ -11,33 +11,32 @@ local function get_prepared() end function M.get() - if not get_prepared() then set_prepared(vim.api.nvim_create_autocmd("User", { pattern = "CatppuccinLoaded", - callback = function () + callback = function() if pcall(require, "lightspeed") then require("lightspeed").init_highlight() end - end + end, })) end return { - LightspeedLabel = {bg = cp.surface1, fg = cp.text}, - LightspeedOverlapped = {bg = cp.surface1, fg = cp.text}, - LightspeedLabelDistant = {bg = cp.mauve, fg = cp.text}, - LightspeedLabelDistantOverlapped = {bg = cp.mauve, fg = cp.text}, - LightspeedShortcut = {bg = cp.base, fg = cp.peach, style = { "italic" }}, - LightspeedShortcutOverlapped = {bg = cp.base, fg = cp.peach, style = { "bold" }}, - LightspeedMaskedChar = {bg = cp.base, fg = cp.red, style = { "undercurl" }}, - LightspeedGreyWash = {bg = cp.base, fg = cp.overlay0}, - LightspeedUnlabeledMatch = {bg = cp.base, fg = cp.red, style = { "underline" }}, - LightspeedOneCharMatch = {bg = cp.base, fg = cp.red, style = { "underline" }}, - LightspeedUniqueChar = {bg = cp.base, fg = cp.green, style = { "strikethrough" }}, - LightspeedPendingOpArea = {bg = cp.base, fg = cp.green, style = { "strikethrough" }}, - LightspeedPendingChangeOpArea = {bg = cp.base, fg = cp.green, style = { "strikethrough" }}, - LightspeedCursor = {fg = cp.base, bg = cp.text}, + LightspeedLabel = { bg = cp.surface1, fg = cp.text }, + LightspeedOverlapped = { bg = cp.surface1, fg = cp.text }, + LightspeedLabelDistant = { bg = cp.mauve, fg = cp.text }, + LightspeedLabelDistantOverlapped = { bg = cp.mauve, fg = cp.text }, + LightspeedShortcut = { bg = cp.base, fg = cp.peach, style = { "italic" } }, + LightspeedShortcutOverlapped = { bg = cp.base, fg = cp.peach, style = { "bold" } }, + LightspeedMaskedChar = { bg = cp.base, fg = cp.red, style = { "undercurl" } }, + LightspeedGreyWash = { bg = cp.base, fg = cp.overlay0 }, + LightspeedUnlabeledMatch = { bg = cp.base, fg = cp.red, style = { "underline" } }, + LightspeedOneCharMatch = { bg = cp.base, fg = cp.red, style = { "underline" } }, + LightspeedUniqueChar = { bg = cp.base, fg = cp.green, style = { "strikethrough" } }, + LightspeedPendingOpArea = { bg = cp.base, fg = cp.green, style = { "strikethrough" } }, + LightspeedPendingChangeOpArea = { bg = cp.base, fg = cp.green, style = { "strikethrough" } }, + LightspeedCursor = { fg = cp.base, bg = cp.text }, } end diff --git a/lua/catppuccin/groups/integrations/native_lsp.lua b/lua/catppuccin/groups/integrations/native_lsp.lua index 3394e9c..3324fcc 100644 --- a/lua/catppuccin/groups/integrations/native_lsp.lua +++ b/lua/catppuccin/groups/integrations/native_lsp.lua @@ -2,8 +2,7 @@ local M = {} local ucolors = require("catppuccin.utils.colors") function M.get() - - local options = require("catppuccin.config").options + local options = require("catppuccin.config").options local virtual_text = options.integrations.native_lsp.virtual_text local underlines = options.integrations.native_lsp.underlines @@ -22,10 +21,26 @@ function M.get() LspReferenceWrite = { bg = cp.surface1 }, -- used for highlighting "write" references -- hightlight diagnostics in numberline - DiagnosticVirtualTextError = { bg = ucolors.darken(error, darkening_percentage, cp.base), fg = error, style = virtual_text.errors }, -- Used as the mantle highlight group. Other Diagnostic highlights link to this by default - DiagnosticVirtualTextWarn = { bg = ucolors.darken(warning, darkening_percentage, cp.base), fg = warning, style = virtual_text.warnings }, -- Used as the mantle highlight group. Other Diagnostic highlights link to this by default - DiagnosticVirtualTextInfo = { bg = ucolors.darken(info, darkening_percentage, cp.base), fg = info, style = virtual_text.information }, -- Used as the mantle highlight group. Other Diagnostic highlights link to this by default - DiagnosticVirtualTextHint = { bg = ucolors.darken(hint, darkening_percentage, cp.base), fg = hint, style = virtual_text.hints }, -- Used as the mantle highlight group. Other Diagnostic highlights link to this by default + DiagnosticVirtualTextError = { + bg = ucolors.darken(error, darkening_percentage, cp.base), + fg = error, + style = virtual_text.errors, + }, -- Used as the mantle highlight group. Other Diagnostic highlights link to this by default + DiagnosticVirtualTextWarn = { + bg = ucolors.darken(warning, darkening_percentage, cp.base), + fg = warning, + style = virtual_text.warnings, + }, -- Used as the mantle highlight group. Other Diagnostic highlights link to this by default + DiagnosticVirtualTextInfo = { + bg = ucolors.darken(info, darkening_percentage, cp.base), + fg = info, + style = virtual_text.information, + }, -- Used as the mantle highlight group. Other Diagnostic highlights link to this by default + DiagnosticVirtualTextHint = { + bg = ucolors.darken(hint, darkening_percentage, cp.base), + fg = hint, + style = virtual_text.hints, + }, -- Used as the mantle highlight group. Other Diagnostic highlights link to this by default DiagnosticError = { bg = cp.none, fg = error, style = virtual_text.errors }, -- Used as the mantle highlight group. Other Diagnostic highlights link to this by default DiagnosticWarn = { bg = cp.none, fg = warning, style = virtual_text.warnings }, -- Used as the mantle highlight group. Other Diagnostic highlights link to this by default diff --git a/lua/catppuccin/groups/integrations/nvimtree.lua b/lua/catppuccin/groups/integrations/nvimtree.lua index f5bd237..a415278 100644 --- a/lua/catppuccin/groups/integrations/nvimtree.lua +++ b/lua/catppuccin/groups/integrations/nvimtree.lua @@ -9,7 +9,6 @@ function M.get() root_dir_color = cp.blue end - return { NvimTreeFolderName = { fg = cp.blue }, NvimTreeFolderIcon = { fg = cp.blue }, diff --git a/lua/catppuccin/groups/integrations/telescope.lua b/lua/catppuccin/groups/integrations/telescope.lua index 0b776d6..6ccd49a 100644 --- a/lua/catppuccin/groups/integrations/telescope.lua +++ b/lua/catppuccin/groups/integrations/telescope.lua @@ -6,16 +6,16 @@ function M.get() 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 }, + 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/groups/integrations/treesitter.lua b/lua/catppuccin/groups/integrations/treesitter.lua index 3528de4..b79136d 100644 --- a/lua/catppuccin/groups/integrations/treesitter.lua +++ b/lua/catppuccin/groups/integrations/treesitter.lua @@ -53,7 +53,7 @@ function M.get() TSNote = { fg = cp.base, bg = cp.blue }, TSWarning = { fg = cp.base, bg = cp.yellow }, TSDanger = { fg = cp.base, bg = cp.red }, - TSConstMacro = { fg = cp.mauve }; -- For constants that are defined by macros: NULL in cp. + TSConstMacro = { fg = cp.mauve }, -- For constants that are defined by macros: NULL in cp. -- TSError = { fg = cp.red }, -- For syntax/parser errors. -- rustTSField = { fg = cp.surface1 }, -- For fields. TSLabel = { fg = cp.sapphire }, -- For labels: label: in C and :label: in Lua. @@ -98,7 +98,7 @@ function M.get() -- lua luaTSConstructor = { fg = cp.lavender }, -- For constructor calls and definitions: = { } in Lua, and Java constructors. - -- typescript + -- typescript typescriptTSConstructor = { fg = cp.lavender }, -- TSX (Typescript React) diff --git a/lua/catppuccin/init.lua b/lua/catppuccin/init.lua index 5c05520..8d79ee3 100644 --- a/lua/catppuccin/init.lua +++ b/lua/catppuccin/init.lua @@ -1,6 +1,6 @@ local M = {} -local flavours = {"latte", "frappe", "macchiato", "mocha"} +local flavours = { "latte", "frappe", "macchiato", "mocha" } local command = vim.api.nvim_create_user_command @@ -11,14 +11,14 @@ command("Catppuccin", function(inp) return end vim.g.catppuccin_flavour = inp.args - vim.cmd "colorscheme catppuccin" + vim.cmd("colorscheme catppuccin") end, { nargs = 1, complete = function(line) return vim.tbl_filter(function(val) return vim.startswith(val, line) end, flavours) - end + end, }) command("CatppuccinCompile", function() @@ -42,7 +42,9 @@ function M.load() if config.compile.enable == true then local compiled_path = config.compile.path .. (vim.loop.os_uname().sysname == "Windows" and "\\" or "/") - .. vim.g.catppuccin_flavour .. config.compile.suffix .. ".lua" + .. vim.g.catppuccin_flavour + .. config.compile.suffix + .. ".lua" local f = io.open(compiled_path, "r") if f ~= nil then io.close(f) diff --git a/lua/catppuccin/lib/compiler.lua b/lua/catppuccin/lib/compiler.lua index b4a03ff..4f26b8c 100644 --- a/lua/catppuccin/lib/compiler.lua +++ b/lua/catppuccin/lib/compiler.lua @@ -3,19 +3,20 @@ local M = {} -- Credit: https://github.com/EdenEast/nightfox.nvim local fmt = string.format local function inspect(t) - local list = {} - for k, v in pairs(t) do - local q = type(v) == "string" and [["]] or "" - table.insert(list, fmt([[%s = %s%s%s]], k, q, v, q)) - end + local list = {} + for k, v in pairs(t) do + local q = type(v) == "string" and [["]] or "" + table.insert(list, fmt([[%s = %s%s%s]], k, q, v, q)) + end - table.sort(list) - return fmt([[{ %s }]], table.concat(list, ", ")) + table.sort(list) + return fmt([[{ %s }]], table.concat(list, ", ")) end function util.compile() local theme = require("catppuccin.lib.mapper").apply() - local lines = { [[ + local lines = { + [[ -- This file is autogenerated by CATPPUCCIN. -- Do not make changes directly to this file. @@ -23,16 +24,17 @@ vim.cmd("hi clear") if vim.fn.exists("syntax_on") then vim.cmd("syntax reset") end -vim.g.colors_name = "catppuccin"]] } +vim.g.colors_name = "catppuccin"]], + } local config = require("catppuccin.config").options local custom_highlights = config.custom_highlights for property, value in pairs(theme.properties) do if type(value) == "string" then table.insert(lines, fmt('vim.o.%s = "%s"', property, value)) elseif type(value) == "bool" then - table.insert(lines, fmt('vim.o.%s = %s', property, value)) + table.insert(lines, fmt("vim.o.%s = %s", property, value)) elseif type(value) == "table" then - table.insert(lines, fmt('vim.o.%s = %s', property, inspect(value))) + table.insert(lines, fmt("vim.o.%s = %s", property, inspect(value))) end end local tbl = vim.tbl_deep_extend("keep", theme.integrations, theme.base) @@ -61,19 +63,49 @@ vim.g.colors_name = "catppuccin"]] } end if config.term_colors then - local colors = { "overlay0", "red", "green", "yellow", "blue", "pink", "sky", "text", "overlay1", "red", "green", "yellow", "blue", "pink", "sky", "text"} + local colors = { + "overlay0", + "red", + "green", + "yellow", + "blue", + "pink", + "sky", + "text", + "overlay1", + "red", + "green", + "yellow", + "blue", + "pink", + "sky", + "text", + } for i = 0, 15 do table.insert(lines, fmt('vim.g.terminal_color_%d = "%s"', i, theme.terminal[colors[i + 1]])) end end - os.execute(string.format("mkdir %s %s", vim.loop.os_uname().sysname == 'Windows' and "" or "-p", config.compile.path)) - local file = io.open(config.compile.path .. (vim.loop.os_uname().sysname == 'Windows' and "\\" or "/") .. vim.g.catppuccin_flavour .. config.compile.suffix .. ".lua", "w") + os.execute( + string.format("mkdir %s %s", vim.loop.os_uname().sysname == "Windows" and "" or "-p", config.compile.path) + ) + local file = io.open( + config.compile.path + .. (vim.loop.os_uname().sysname == "Windows" and "\\" or "/") + .. vim.g.catppuccin_flavour + .. config.compile.suffix + .. ".lua", + "w" + ) file:write(table.concat(lines, "\n")) file:close() end function util.clean() local config = require("catppuccin.config").options - local compiled_path = config.compile.path .. (vim.loop.os_uname().sysname == 'Windows' and "\\" or "/") .. vim.g.catppuccin_flavour .. config.compile.suffix .. ".lua" + local compiled_path = config.compile.path + .. (vim.loop.os_uname().sysname == "Windows" and "\\" or "/") + .. vim.g.catppuccin_flavour + .. config.compile.suffix + .. ".lua" os.remove(compiled_path) end diff --git a/lua/catppuccin/lib/ui.lua b/lua/catppuccin/lib/ui.lua index b69b37e..b8cc126 100644 --- a/lua/catppuccin/lib/ui.lua +++ b/lua/catppuccin/lib/ui.lua @@ -13,10 +13,10 @@ function M.dim() ucolors.darken(cp.base, dim_percentage, cp.mantle) ) end - return ucolors.vary_color( - { latte = ucolors.lighten("#FBFCFD", dim_percentage, latte.base) }, - ucolors.lighten(cp.surface0, dim_percentage, cp.base) - ) + return ucolors.vary_color( + { latte = ucolors.lighten("#FBFCFD", dim_percentage, latte.base) }, + ucolors.lighten(cp.surface0, dim_percentage, cp.base) + ) end return M diff --git a/lua/catppuccin/palettes/init.lua b/lua/catppuccin/palettes/init.lua index 1d5712e..1a89b5b 100644 --- a/lua/catppuccin/palettes/init.lua +++ b/lua/catppuccin/palettes/init.lua @@ -12,13 +12,13 @@ function M.get_palette() end if type(cnf.color_overrides) == "table" then - for _, pal in pairs({"all", flvr}) do + for _, pal in pairs({ "all", flvr }) do if cnf.color_overrides[pal] ~= nil then for k, v in pairs(cnf.color_overrides[pal]) do if palette[k] then palette[k] = v else - echo('"'..k .. '" is not a valid catppucin palette color', "warn") + echo('"' .. k .. '" is not a valid catppucin palette color', "warn") end end end diff --git a/lua/catppuccin/utils/data.lua b/lua/catppuccin/utils/data.lua index 241f04f..3944cfb 100644 --- a/lua/catppuccin/utils/data.lua +++ b/lua/catppuccin/utils/data.lua @@ -1,11 +1,11 @@ local M = {} function M.set_of(list) - local set = {} - for i = 1, #list do - set[list[i]] = true - end - return set + local set = {} + for i = 1, #list do + set[list[i]] = true + end + return set end return M diff --git a/lua/catppuccin/utils/echo.lua b/lua/catppuccin/utils/echo.lua index 5f69443..0f4f3cc 100644 --- a/lua/catppuccin/utils/echo.lua +++ b/lua/catppuccin/utils/echo.lua @@ -1,7 +1,7 @@ local TITLE = "Catppuccin" return function(msg, kind) - local has_notify_plugin = pcall(require, "notify") + local has_notify_plugin = pcall(require, "notify") local level = {} if kind == "error" then @@ -15,11 +15,11 @@ return function(msg, kind) level.type = "info" end - if has_notify_plugin then - vim.notify(msg, level.log, { - title = TITLE, - }) - else - vim.notify(("%s (%s): %s"):format(TITLE, level.type,msg), level.log) - end + if has_notify_plugin then + vim.notify(msg, level.log, { + title = TITLE, + }) + else + vim.notify(("%s (%s): %s"):format(TITLE, level.type, msg), level.log) + end end