BREAKING CHANGE: reworked most directories and function calls

dev
Pocco81 2 years ago
parent 24191b87a2
commit c41a6272f7

@ -1,7 +1,7 @@
local M = {}
function M.get_colors()
return require("catppuccin.core.palettes.init").get_palette()
return require("catppuccin.palettes.init").get_palette()
end
return M

@ -1,25 +1,10 @@
local ucolors = require("catppuccin.utils.colors")
local lui = require("catppuccin.lib.ui")
local cp
local M = {}
local function get_properties()
local props = {
termguicolors = true,
background = "dark",
}
if ucolors.assert_brightness(cp.base) then
props["background"] = "light"
end
return props
end
local ucolors = require("catppuccin.utils.colors")
local lui = require("catppuccin.lib.ui")
local function get_base()
function M.get()
return {
Comment = { fg = cp.surface2, style = cnf.styles.comments }, -- just comments
ColorColumn = { bg = cp.surface0 }, -- used for the columns set with 'colorcolumn'
Conceal = { fg = cp.overlay1 }, -- placeholder characters substituted for concealed text (see 'conceallevel')
Cursor = { fg = cp.base, bg = cp.text }, -- character under the cursor
@ -91,146 +76,7 @@ local function get_base()
-- overlay0ed out groups should chain up to their "preferred" group by
-- default,
-- Unoverlay0 and edit if you want more specific syntax highlighting.
-- code itself
Constant = { fg = cp.peach }, -- (preferred) any constant
String = { fg = cp.green, style = cnf.styles.strings }, -- a string constant: "this is a string"
Character = { fg = cp.teal }, -- a character constant: 'c', '\n'
Number = { fg = cp.peach }, -- a number constant: 234, 0xff
Float = { fg = cp.peach }, -- a floating point constant: 2.3e10
Boolean = { fg = cp.peach }, -- a boolean constant: TRUE, false
Identifier = { fg = cp.flamingo, style = cnf.styles.variables }, -- (preferred) any variable name
Function = { fg = cp.blue, style = cnf.styles.functions }, -- function name (also: methods for classes)
Statement = { fg = cp.mauve }, -- (preferred) any statement
Conditional = { fg = cp.red }, -- if, then, else, endif, switch, etcp.
Repeat = { fg = cp.red }, -- for, do, while, etcp.
Label = { fg = cp.peach }, -- case, default, etcp.
Operator = { fg = cp.sky }, -- "sizeof", "+", "*", etcp.
Keyword = { fg = cp.pink, style = cnf.styles.keywords }, -- any other keyword
-- Exception = { }, -- try, catch, throw
PreProc = { fg = cp.pink }, -- (preferred) generic Preprocessor
Include = { fg = cp.pink }, -- preprocessor #include
-- Define = { }, -- preprocessor #define
-- Macro = { }, -- same as Define
-- PreCondit = { }, -- preprocessor #if, #else, #endif, etcp.
StorageClass = { fg = cp.yellow }, -- static, register, volatile, etcp.
Structure = { fg = cp.yellow }, -- struct, union, enum, etcp.
Typedef = { fg = cp.yellow }, -- A typedef
Special = { fg = cp.pink }, -- (preferred) any special symbol
Type = { fg = cp.blue }, -- (preferred) int, long, char, etcp.
-- SpecialChar = { }, -- special character in a constant
-- Tag = { }, -- you can use CTRL-] on this
-- Delimiter = { }, -- character that needs attention
-- Specialoverlay0= { }, -- special things inside a overlay0
-- Debug = { }, -- debugging statements
Underlined = { style = { "underline" } }, -- (preferred) text that stands out, HTML links
Bold = { style = { "bold" } },
Italic = { style = { "italic" } },
-- ("Ignore", below, may be invisible...)
-- Ignore = { }, -- (preferred) left blank, hidden |hl-Ignore|
Error = { fg = cp.red }, -- (preferred) any erroneous construct
Todo = { bg = cp.yellow, fg = cp.base, style = { "bold" } }, -- (preferred) anything that needs extra attention; mostly the keywords TODO FIXME and XXX
qfLineNr = { fg = cp.yellow },
qfFileName = { fg = cp.blue },
htmlH1 = { fg = cp.pink, style = { "bold" } },
htmlH2 = { fg = cp.blue, style = { "bold" } },
-- mkdHeading = { fg = cp.peach, style = { "bold" } },
-- mkdCode = { bg = cp.terminal_black, fg = cp.text },
mkdCodeDelimiter = { bg = cp.base, fg = cp.text },
mkdCodeStart = { fg = cp.flamingo, style = { "bold" } },
mkdCodeEnd = { fg = cp.flamingo, style = { "bold" } },
-- mkdLink = { fg = cp.blue, style = { "underline" } },
-- debugging
debugPC = { bg = cp.crust }, -- used for highlighting the current line in terminal-debug
debugBreakpoint = { bg = cp.base, fg = cp.overlay0 }, -- used for breakpoint colors in terminal-debug
-- illuminate
illuminatedWord = { bg = cp.surface1 },
illuminatedCurWord = { bg = cp.surface1 },
-- diff
diffAdded = { fg = cp.green },
diffRemoved = { fg = cp.red },
diffChanged = { fg = cp.yellow },
diffOldFile = { fg = cp.yellow },
diffNewFile = { fg = cp.peach },
diffFile = { fg = cp.blue },
diffLine = { fg = cp.overlay0 },
diffIndexLine = { fg = cp.pink },
DiffAdd = { fg = cp.green, bg = cp.base }, -- diff mode: Added line |diff.txt|
DiffChange = { fg = cp.yellow, bg = cp.base }, -- diff mode: Changed line |diff.txt|
DiffDelete = { fg = cp.red, bg = cp.base }, -- diff mode: Deleted line |diff.txt|
DiffText = { fg = cp.blue, bg = cp.base }, -- diff mode: Changed text within a changed line |diff.txt|
-- NeoVim
healthError = { fg = cp.red },
healthSuccess = { fg = cp.teal },
healthWarning = { fg = cp.yellow },
-- misc
-- glyphs
GlyphPalette1 = { fg = cp.red },
GlyphPalette2 = { fg = cp.teal },
GlyphPalette3 = { fg = cp.yellow },
GlyphPalette4 = { fg = cp.blue },
GlyphPalette6 = { fg = cp.teal },
GlyphPalette7 = { fg = cp.text },
GlyphPalette9 = { fg = cp.red },
}
end
local function get_integrations()
local integrations = cnf["integrations"]
local final_integrations = {}
for integration in pairs(integrations) do
local cot = false
if type(integrations[integration]) == "table" then
if integrations[integration]["enabled"] == true then
cot = true
end
else
if integrations[integration] == true then
cot = true
end
end
if cot then
final_integrations = vim.tbl_deep_extend(
"force",
final_integrations,
require("catppuccin.core.integrations." .. integration).get(cp)
)
end
end
return final_integrations
end
local function get_terminal()
return cp
end
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
theme.integrations = get_integrations() -- plugins
theme.terminal = get_terminal() -- terminal colors
-- uninstantiate to avoid poluting global scope and because it's not needed anymore
_G.cnf = nil
return theme
end
return M

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
BufferCurrent = { bg = cp.surface1, fg = cp.text },
BufferCurrentIndex = { bg = cp.surface1, fg = cp.blue },

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
local cnf = require("catppuccin.config").options
local transparent_background = cnf.transparent_background
local bg_highlight = (transparent_background and cnf.dim_inactive.enable and cp.dim)

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
CmpItemAbbr = { fg = cp.overlay2 },
CmpItemAbbrDeprecated = { fg = cp.overlay0, style = { "strikethrough" } },

@ -1,8 +1,6 @@
local M = {}
local util = require("catppuccin.utils.util")
function M.get(cp)
function M.get()
local error = cp.red
local warning = cp.yellow
local info = cp.sky

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
DashboardShortCut = { fg = cp.pink },
DashboardHeader = { fg = cp.blue },

@ -26,7 +26,7 @@ local assets = {
slim_dot = "",
}
local clrs = require("catppuccin.core.palettes.init").get_palette()
local clrs = require("catppuccin.palettes.init").get_palette()
-- settings
local sett = {

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
FernBranchText = { fg = cp.blue },
}

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
GitGutterAdd = { fg = cp.green },
GitGutterChange = { fg = cp.yellow },

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
local cnf = require("catppuccin.config").options
local bg_highlight = (cnf.transparent_background and cnf.dim_inactive.enable and cp.dim)
or (cnf.transparent_background and "NONE")

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
HopNextKey = { bg = cp.base, fg = cp.peach, style = { "bold", "underline" } },
HopNextKey1 = { bg = cp.base, fg = cp.blue, style = { "bold" } },

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
local hi = {
IndentBlanklineChar = { fg = cp.surface0 },

@ -10,7 +10,7 @@ local function get_prepared()
return is_prepared
end
function M.get(cp)
function M.get()
if not get_prepared() then
local catppuccin = require("catppuccin")

@ -10,7 +10,7 @@ local function get_prepared()
return is_prepared
end
function M.get(cp)
function M.get()
if not get_prepared() then
set_prepared(vim.api.nvim_create_autocmd("User", {

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
DiagnosticError = { fg = cp.red },
DiagnosticWarning = { fg = cp.yellow },

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
LspTroubleText = { fg = cp.green },
LspTroubleCount = { fg = cp.pink, bg = cp.surface1 },

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
markdownHeadingDelimiter = { fg = cp.peach, style = { "bold" } },
markdownCode = { fg = cp.flamingo },

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
local transparent_background = require("catppuccin.config").options.transparent_background
local bg_highlight = transparent_background and "NONE" or cp.base

@ -1,7 +1,7 @@
local M = {}
local ucolors = require("catppuccin.utils.colors")
function M.get(cp)
function M.get()
local options = require("catppuccin.config").options
local virtual_text = options.integrations.native_lsp.virtual_text

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
NeogitBranch = { fg = cp.pink },
NeogitRemote = { fg = cp.pink },

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
local config = require("catppuccin.config").options
local neotree = config.integrations.neotree

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
NotifyERRORBorder = { fg = cp.red },
NotifyERRORIcon = { fg = cp.red },

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
local config = require("catppuccin.config").options
local nvimtree = config.integrations.nvimtree

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
FocusedSymbol = { fg = cp.yellow, bg = cp.base },
}

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
tkLink = { fg = cp.blue },
tkBrackets = { fg = cp.pink },

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
TelescopeBorder = { fg = cp.blue },
TelescopeSelectionCaret = { fg = cp.flamingo },

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
-- local delimeters = cp.overlay2
local operators = cp.sky
local cl = cp.mauve -- conditionals, loops

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
local cnf = require("catppuccin.config").options
local transparent_background = cnf.transparent_background
local bg_highlight = (transparent_background and cnf.dim_inactive.enable and cp.dim)

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
Sneak = { fg = cp.overlay2, bg = cp.pink },
SneakScope = { bg = cp.text },

@ -1,6 +1,6 @@
local M = {}
function M.get(cp)
function M.get()
return {
WhichKey = { fg = cp.flamingo },
WhichKeyGroup = { fg = cp.blue },

@ -0,0 +1,18 @@
local M = {}
local ucolors = require("catppuccin.utils.colors")
function M.get()
local props = {
termguicolors = true,
background = "dark",
}
if ucolors.assert_brightness(cp.base) then
props["background"] = "light"
end
return props
end
return M

@ -0,0 +1,104 @@
local M = {}
function M.get()
return {
Comment = { fg = cp.surface2, style = cnf.styles.comments }, -- just comments
Constant = { fg = cp.peach }, -- (preferred) any constant
String = { fg = cp.green, style = cnf.styles.strings }, -- a string constant: "this is a string"
Character = { fg = cp.teal }, -- a character constant: 'c', '\n'
Number = { fg = cp.peach }, -- a number constant: 234, 0xff
Float = { fg = cp.peach }, -- a floating point constant: 2.3e10
Boolean = { fg = cp.peach }, -- a boolean constant: TRUE, false
Identifier = { fg = cp.flamingo, style = cnf.styles.variables }, -- (preferred) any variable name
Function = { fg = cp.blue, style = cnf.styles.functions }, -- function name (also: methods for classes)
Statement = { fg = cp.mauve }, -- (preferred) any statement
Conditional = { fg = cp.red }, -- if, then, else, endif, switch, etcp.
Repeat = { fg = cp.red }, -- for, do, while, etcp.
Label = { fg = cp.peach }, -- case, default, etcp.
Operator = { fg = cp.sky }, -- "sizeof", "+", "*", etcp.
Keyword = { fg = cp.pink, style = cnf.styles.keywords }, -- any other keyword
-- Exception = { }, -- try, catch, throw
PreProc = { fg = cp.pink }, -- (preferred) generic Preprocessor
Include = { fg = cp.pink }, -- preprocessor #include
-- Define = { }, -- preprocessor #define
-- Macro = { }, -- same as Define
-- PreCondit = { }, -- preprocessor #if, #else, #endif, etcp.
StorageClass = { fg = cp.yellow }, -- static, register, volatile, etcp.
Structure = { fg = cp.yellow }, -- struct, union, enum, etcp.
Typedef = { fg = cp.yellow }, -- A typedef
Special = { fg = cp.pink }, -- (preferred) any special symbol
Type = { fg = cp.blue }, -- (preferred) int, long, char, etcp.
-- SpecialChar = { }, -- special character in a constant
-- Tag = { }, -- you can use CTRL-] on this
-- Delimiter = { }, -- character that needs attention
-- Specialoverlay0= { }, -- special things inside a overlay0
-- Debug = { }, -- debugging statements
Underlined = { style = { "underline" } }, -- (preferred) text that stands out, HTML links
Bold = { style = { "bold" } },
Italic = { style = { "italic" } },
-- ("Ignore", below, may be invisible...)
-- Ignore = { }, -- (preferred) left blank, hidden |hl-Ignore|
Error = { fg = cp.red }, -- (preferred) any erroneous construct
Todo = { bg = cp.yellow, fg = cp.base, style = { "bold" } }, -- (preferred) anything that needs extra attention; mostly the keywords TODO FIXME and XXX
qfLineNr = { fg = cp.yellow },
qfFileName = { fg = cp.blue },
htmlH1 = { fg = cp.pink, style = { "bold" } },
htmlH2 = { fg = cp.blue, style = { "bold" } },
-- mkdHeading = { fg = cp.peach, style = { "bold" } },
-- mkdCode = { bg = cp.terminal_black, fg = cp.text },
mkdCodeDelimiter = { bg = cp.base, fg = cp.text },
mkdCodeStart = { fg = cp.flamingo, style = { "bold" } },
mkdCodeEnd = { fg = cp.flamingo, style = { "bold" } },
-- mkdLink = { fg = cp.blue, style = { "underline" } },
-- debugging
debugPC = { bg = cp.crust }, -- used for highlighting the current line in terminal-debug
debugBreakpoint = { bg = cp.base, fg = cp.overlay0 }, -- used for breakpoint colors in terminal-debug
-- illuminate
illuminatedWord = { bg = cp.surface1 },
illuminatedCurWord = { bg = cp.surface1 },
-- diff
diffAdded = { fg = cp.green },
diffRemoved = { fg = cp.red },
diffChanged = { fg = cp.yellow },
diffOldFile = { fg = cp.yellow },
diffNewFile = { fg = cp.peach },
diffFile = { fg = cp.blue },
diffLine = { fg = cp.overlay0 },
diffIndexLine = { fg = cp.pink },
DiffAdd = { fg = cp.green, bg = cp.base }, -- diff mode: Added line |diff.txt|
DiffChange = { fg = cp.yellow, bg = cp.base }, -- diff mode: Changed line |diff.txt|
DiffDelete = { fg = cp.red, bg = cp.base }, -- diff mode: Deleted line |diff.txt|
DiffText = { fg = cp.blue, bg = cp.base }, -- diff mode: Changed text within a changed line |diff.txt|
-- NeoVim
healthError = { fg = cp.red },
healthSuccess = { fg = cp.teal },
healthWarning = { fg = cp.yellow },
-- misc
-- glyphs
GlyphPalette1 = { fg = cp.red },
GlyphPalette2 = { fg = cp.teal },
GlyphPalette3 = { fg = cp.yellow },
GlyphPalette4 = { fg = cp.blue },
GlyphPalette6 = { fg = cp.teal },
GlyphPalette7 = { fg = cp.text },
GlyphPalette9 = { fg = cp.red },
Define = { link = "PreProc" }, -- preprocessor #define
Macro = { link = "PreProc" }, -- same as Define
PreCondit = { link = "PreProc" }, -- preprocessor #if, #else, #endif, etc.
SpecialChar = { link = "Special" }, -- special character in a constant
Tag = { link = "Special" }, -- you can use CTRL-] on this
Delimiter = { link = "Special" }, -- character that needs attention
SpecialComment = { link = "Special" }, -- special things inside a comment
Debug = { link = "Special" }, -- debugging statements
}
end
return M

@ -0,0 +1,31 @@
local M = {}
function M.get()
return {
terminal_color_0 = cp.overlay0,
terminal_color_8 = cp.overlay1,
terminal_color_1 = cp.red,
terminal_color_9 = cp.red,
terminal_color_2 = cp.green,
terminal_color_10 = cp.green,
terminal_color_3 = cp.yellow,
terminal_color_11 = cp.yellow,
terminal_color_4 = cp.blue,
terminal_color_12 = cp.blue,
terminal_color_5 = cp.pink,
terminal_color_13 = cp.pink,
terminal_color_6 = cp.sky,
terminal_color_14 = cp.sky,
terminal_color_7 = cp.text,
terminal_color_15 = cp.text,
}
end
return M

@ -0,0 +1,107 @@
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
table.sort(list)
return fmt([[{ %s }]], table.concat(list, ", "))
end
function M.compile()
local theme = require("catppuccin.lib.mapper").apply()
local lines = {
[[
-- This file is autogenerated by CATPPUCCIN.
-- Do not make changes directly to this file.
vim.cmd("hi clear")
if vim.fn.exists("syntax_on") then
vim.cmd("syntax reset")
end
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
table.insert(lines, fmt("vim.o.%s = %s", property, value))
end
local tbl = vim.tbl_deep_extend("keep", theme.integrations, theme.base)
tbl = vim.tbl_deep_extend("keep", custom_highlights, tbl)
for group, color in pairs(tbl) do
if color.link then
table.insert(lines, fmt([[vim.api.nvim_set_hl(0, "%s", { link = "%s" })]], group, color.link))
else
if color.style then
if color.style ~= "NONE" then
if type(color.style) == "table" then
for _, style in ipairs(color.style) do
color[style] = true
end
else
color[color.style] = true
end
end
end
color.style = nil
vim.api.nvim_set_hl(0, group, color)
table.insert(lines, fmt([[vim.api.nvim_set_hl(0, "%s", %s)]], group, inspect(color)))
end
end
if config.term_colors then
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"
)
file:write(table.concat(lines, "\n"))
file:close()
end
function M.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"
os.remove(compiled_path)
end
return M

@ -0,0 +1,52 @@
local M = {}
local g = vim.g
function M.highlight(group, color)
if color.link then
vim.api.nvim_set_hl(0, group, {
link = color.link,
})
else
if color.style then
for _, style in ipairs(color.style) do
color[style] = true
end
end
color.style = nil
vim.api.nvim_set_hl(0, group, color)
end
end
function M.syntax(tbl)
for group, colors in pairs(tbl) do
M.highlight(group, colors)
end
end
function M.properties(tbl)
for property, value in pairs(tbl) do
vim.o[property] = value
end
end
function M.load(theme)
vim.cmd("hi clear")
if vim.fn.exists("syntax_on") then
vim.cmd("syntax reset")
end
g.colors_name = "catppuccin"
local custom_highlights = require("catppuccin.config").options.custom_highlights
M.properties(theme.properties)
M.syntax(theme.editor)
M.syntax(theme.syntax)
M.syntax(theme.integrations)
M.syntax(custom_highlights)
if require("catppuccin.config").options["term_colors"] then
M.properties(theme.terminal)
end
end
return M

@ -0,0 +1,54 @@
local M = {}
local lui = require("catppuccin.lib.ui")
local function get_integrations()
local integrations = cnf["integrations"]
local final_integrations = {}
for integration in pairs(integrations) do
local cot = false
if type(integrations[integration]) == "table" then
if integrations[integration]["enabled"] == true then
cot = true
end
else
if integrations[integration] == true then
cot = true
end
end
if cot then
final_integrations = vim.tbl_deep_extend(
"force",
final_integrations,
require("catppuccin.groups.integrations." .. integration).get()
)
end
end
return final_integrations
end
function M.apply()
_G.cnf = require("catppuccin.config").options
_G.cp = require("catppuccin.palettes.init").get_palette()
cp.none = "NONE"
cp.dim = lui.dim()
local theme = {}
theme.properties = require("catppuccin.groups.properties").get() -- nvim settings
theme.syntax = require("catppuccin.groups.syntax").get()
theme.editor = require("catppuccin.groups.editor").get()
theme.integrations = get_integrations() -- plugins
theme.terminal = require("catppuccin.groups.terminal").get() -- terminal colors
-- uninstantiate to avoid poluting global scope and because it's not needed anymore
_G.cnf = nil
_G.cp = nil
return theme
end
return M

@ -1,10 +1,10 @@
local M = {}
local cp = require("catppuccin.core.palettes.init").get_palette()
local cp = require("catppuccin.palettes.init").get_palette()
local cnf = require("catppuccin.config").options
local dim_percentage = cnf.dim_inactive.percentage
local ucolors = require("catppuccin.utils.colors")
local latte = require("catppuccin.core.palettes.latte")
local latte = require("catppuccin.palettes.latte")
function M.dim()
if cnf.dim_inactive.shade == "dark" then

@ -1,7 +1,6 @@
local M = {}
local flavours = {"latte", "frappe", "macchiato", "mocha"}
local command = vim.api.nvim_create_user_command
command("Catppuccin", function(inp)
@ -18,11 +17,11 @@ end, {
})
command("CatppuccinCompile", function()
require("catppuccin.utils.util").compile()
require("catppuccin.lib.compiler").compile()
end, {})
command("CatppuccinClean", function()
require("catppuccin.utils.util").clean()
require("catppuccin.lib.compiler").clean()
end, {})
local function load()
@ -44,9 +43,9 @@ local function load()
end
end
-- colorscheme gets evaluated from mapper.lua
local theme = require("catppuccin.core.mapper").apply()
local utils = require("catppuccin.utils.util")
utils.load(theme)
local theme = require("catppuccin.lib.mapper").apply()
local highlighter = require("catppuccin.lib.highlighter")
highlighter.load(theme)
if catppuccin.after_loading ~= nil then
catppuccin.after_loading()

@ -6,9 +6,9 @@ local echo = require("catppuccin.utils.echo")
function M.get_palette()
local flvr = vim.g.catppuccin_flavour
local palette = require("catppuccin.core.palettes.mocha")
local palette = require("catppuccin.palettes.mocha")
if flvr == "mocha" or flvr == "latte" or flvr == "macchiato" or flvr == "frappe" then
palette = require("catppuccin.core.palettes." .. flvr)
palette = require("catppuccin.palettes." .. flvr)
end
if type(cnf.color_overrides) == "table" then
@ -18,7 +18,7 @@ function M.get_palette()
if palette[k] then
palette[k] = v
else
echo('Warning: "' .. k .. '" is not a valid catppucin palette color')
echo('"'..k .. '" is not a valid catppucin palette color', "warn")
end
end
end

@ -1,6 +1,6 @@
local M = {}
local hsluv = require("catppuccin.utils.hsluv")
local hsluv = require("catppuccin.lib.hsluv")
M.bg = "#000000"
M.fg = "#ffffff"

@ -1,149 +0,0 @@
local g = vim.g
local util = {}
function util.highlight(group, color)
if color.link then
vim.api.nvim_set_hl(0, group, {
link = color.link,
})
else
if color.style then
for _, style in ipairs(color.style) do
color[style] = true
end
end
color.style = nil
vim.api.nvim_set_hl(0, group, color)
end
end
function util.syntax(tbl)
for group, colors in pairs(tbl) do
util.highlight(group, colors)
end
end
function util.properties(tbl)
for property, value in pairs(tbl) do
vim.o[property] = value
end
end
function util.terminal(cp)
g.terminal_color_0 = cp.overlay0
g.terminal_color_8 = cp.overlay1
g.terminal_color_1 = cp.red
g.terminal_color_9 = cp.red
g.terminal_color_2 = cp.green
g.terminal_color_10 = cp.green
g.terminal_color_3 = cp.yellow
g.terminal_color_11 = cp.yellow
g.terminal_color_4 = cp.blue
g.terminal_color_12 = cp.blue
g.terminal_color_5 = cp.pink
g.terminal_color_13 = cp.pink
g.terminal_color_6 = cp.sky
g.terminal_color_14 = cp.sky
g.terminal_color_7 = cp.text
g.terminal_color_15 = cp.text
end
function util.load(theme)
vim.cmd("hi clear")
if vim.fn.exists("syntax_on") then
vim.cmd("syntax reset")
end
g.colors_name = "catppuccin"
local custom_highlights = require("catppuccin.config").options.custom_highlights
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)
end
end
-- 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
table.sort(list)
return fmt([[{ %s }]], table.concat(list, ", "))
end
function util.compile()
local theme = require("catppuccin.core.mapper").apply()
local lines = { [[
-- This file is autogenerated by CATPPUCCIN.
-- Do not make changes directly to this file.
vim.cmd("hi clear")
if vim.fn.exists("syntax_on") then
vim.cmd("syntax reset")
end
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
table.insert(lines, fmt("vim.o.%s = %s", property, value))
end
local tbl = vim.tbl_deep_extend("keep", theme.integrations, theme.base)
tbl = vim.tbl_deep_extend("keep", custom_highlights, tbl)
for group, color in pairs(tbl) do
if color.link then
table.insert(lines, fmt([[vim.api.nvim_set_hl(0, "%s", { link = "%s" })]], group, color.link))
else
if color.style then
if color.style ~= "NONE" then
if type(color.style) == "table" then
for _, style in ipairs(color.style) do
color[style] = true
end
else
color[color.style] = true
end
end
end
color.style = nil
vim.api.nvim_set_hl(0, group, color)
table.insert(lines, fmt([[vim.api.nvim_set_hl(0, "%s", %s)]], group, inspect(color)))
end
end
if config.term_colors then
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")
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"
os.remove(compiled_path)
end
return util

@ -1,4 +1,4 @@
local cp = require("catppuccin.core.palettes.init").get_palette()
local cp = require("catppuccin.palettes.init").get_palette()
local catppuccin = {}
catppuccin.normal = {

@ -1,4 +1,4 @@
local cp = require("catppuccin.core.palettes.init").get_palette()
local cp = require("catppuccin.palettes.init").get_palette()
local catppuccin = {}
catppuccin.normal = {

Loading…
Cancel
Save