/
mapper.lua
72 lines (60 loc) 路 2.25 KB
/
mapper.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
local M = {}
function M.apply(flavour)
flavour = flavour or require("catppuccin").flavour
local _O, _C, _U = O, C, U -- Borrowing global var (setfenv doesn't work with require)
O = require("catppuccin").options
C = require("catppuccin.palettes").get_palette(flavour)
U = require "catppuccin.utils.colors"
C.none = "NONE"
local dim_percentage = O.dim_inactive.percentage
C.dim = O.dim_inactive.shade == "dark"
and U.vary_color(
{ latte = U.darken(C.base, dim_percentage, C.mantle) },
U.darken(C.base, dim_percentage, C.mantle)
)
or U.vary_color(
{ latte = U.lighten("#FBFCFD", dim_percentage, C.base) },
U.lighten(C.surface0, dim_percentage, C.base)
)
local theme = {}
theme.syntax = require("catppuccin.groups.syntax").get()
theme.editor = require("catppuccin.groups.editor").get()
local final_integrations = {}
-- https://github.com/catppuccin/nvim/pull/624
if type(O.integrations.dap) == "table" and O.integrations.dap.enable_ui ~= nil then
O.integrations.dap_ui = O.integrations.dap.enable_ui
O.integrations.dap.enable_ui = nil
end
for integration in pairs(O.integrations) do
local cot = false
if type(O.integrations[integration]) == "table" then
if O.integrations[integration].enabled == true then cot = true end
else
if O.integrations[integration] == true then
local default = require("catppuccin").default_options.integrations[integration]
O.integrations[integration] = type(default) == "table" and default or {}
O.integrations[integration].enabled = true
cot = true
end
end
if cot then
final_integrations = vim.tbl_deep_extend(
"force",
final_integrations,
require("catppuccin.groups.integrations." .. integration).get()
)
end
end
theme.integrations = final_integrations -- plugins
theme.terminal = require("catppuccin.groups.terminal").get() -- terminal colors
local user_highlights = O.highlight_overrides
if type(user_highlights[flavour]) == "function" then user_highlights[flavour] = user_highlights[flavour](C) end
theme.custom_highlights = vim.tbl_deep_extend(
"keep",
user_highlights[flavour] or {},
type(user_highlights.all) == "function" and user_highlights.all(C) or user_highlights.all or {}
)
O, C, U = _O, _C, _U -- Returning global var
return theme
end
return M