Skip to content

Commit

Permalink
Merge branch 'main' into refactor/syntax-highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jint-lzxy committed Jul 9, 2023
2 parents ea74ecc + 278bfeb commit 2310246
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 40 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,20 @@ pounce = false
</tr>
<!-- pounce.nvim -->

<!-- rainbow-delimiters.nvim -->
</tr>
<tr>
<td> <a href="https://github.com/HiPhish/rainbow-delimiters.nvim">rainbow-delimiters.nvim</a> </td>
<td>

```lua
rainbow_delimiters = true
```

</td>
</tr>
<!-- rainbow-delimiters.nvim -->

<!-- symbols-outline.nvim -->
</tr>
<tr>
Expand Down
4 changes: 4 additions & 0 deletions doc/catppuccin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,10 @@ pounce.nvim>lua
pounce = false
<

rainbow-delimiters.nvim>lua
rainbow_delimiters = true
<

symbols-outline.nvim>lua
symbols_outline = false
<
Expand Down
2 changes: 1 addition & 1 deletion lua/catppuccin/groups/integrations/navic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function M.get()
NavicIconsEvent = { fg = C.blue, bg = background },
NavicIconsOperator = { fg = C.sky, bg = background },
NavicIconsTypeParameter = { fg = C.blue, bg = background },
NavicText = { fg = C.teal, bg = background },
NavicText = { fg = C.sapphire, bg = background },
NavicSeparator = { fg = C.text, bg = background },
}
end
Expand Down
15 changes: 15 additions & 0 deletions lua/catppuccin/groups/integrations/rainbow_delimiters.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
local M = {}

function M.get()
return {
RainbowDelimiterRed = { fg = C.red },
RainbowDelimiterYellow = { fg = C.yellow },
RainbowDelimiterBlue = { fg = C.blue },
RainbowDelimiterOrange = { fg = C.peach },
RainbowDelimiterGreen = { fg = C.green },
RainbowDelimiterViolet = { fg = C.mauve },
RainbowDelimiterCyan = { fg = C.teal },
}
end

return M
2 changes: 1 addition & 1 deletion lua/catppuccin/groups/integrations/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
["@method.call"] = { link = "Function" }, -- For method calls.

["@constructor"] = { fg = C.sapphire }, -- For constructor calls and definitions: = { } in Lua, and Java constructors.
["@parameter"] = { fg = C.rosewater, style = { "italic" } }, -- For parameters of a function.
["@parameter"] = { fg = C.rosewater, style = O.styles.variables or {} }, -- For parameters of a function.

-- Keywords
["@keyword"] = { link = "Keyword" }, -- For keywords that don't fall in previous categories.
Expand Down
2 changes: 1 addition & 1 deletion lua/catppuccin/groups/integrations/which_key.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function M.get()
WhichKeyBorder = { link = "FloatBorder" },

WhichKeyGroup = { fg = C.blue },
WhichKeySeperator = { fg = C.overlay0 },
WhichKeySeparator = { fg = C.overlay0 },
WhichKeyDesc = { fg = C.pink },
WhichKeyValue = { fg = C.overlay0 },
}
Expand Down
1 change: 1 addition & 0 deletions lua/catppuccin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ local M = {
gitsigns = true,
markdown = true,
nvimtree = true,
rainbow_delimiters = true,
semantic_tokens = not is_vim,
telescope = {
enabled = true,
Expand Down
62 changes: 25 additions & 37 deletions lua/catppuccin/lib/mapper.lua
Original file line number Diff line number Diff line change
@@ -1,39 +1,12 @@
local M = {}

local function get_integrations()
local integrations = O["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(flavour)
flavour = flavour or require("catppuccin").flavour
-- Borrowing global var
_G._O = O
_G._C = C
_G._U = U

_G.O = require("catppuccin").options
_G.C = require("catppuccin.palettes").get_palette(flavour)
_G.U = require "catppuccin.utils.colors"
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"

Expand All @@ -51,20 +24,35 @@ function M.apply(flavour)
local theme = {}
theme.syntax = require("catppuccin.groups.syntax").get()
theme.editor = require("catppuccin.groups.editor").get()
theme.integrations = get_integrations() -- plugins
local final_integrations = {}

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 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 = require("catppuccin").options.highlight_overrides
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 {}
)

-- Returning global var
_G.O = _G._O
_G.C = _G._C
_G.U = _G._U
O, C, U = _O, _C, _U -- Returning global var

return theme
end
Expand Down
1 change: 1 addition & 0 deletions lua/catppuccin/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
---@field native_lsp CtpIntegrationNativeLsp
---@field navic CtpIntegrationNavic
---@field nvimtree boolean
---@field rainbow_delimiters boolean
---@field semantic_tokens boolean
---@field telescope CtpIntegrationTelescope
---@field treesitter boolean
Expand Down
107 changes: 107 additions & 0 deletions tests/setup_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,113 @@ local configs = {
end,
},
},
backwardspy = {
flavour = os.getenv "appearance" == "light" and "latte" or "mocha",
integrations = {
gitsigns = true,
indent_blankline = { enabled = true },
leap = true,
mini = true,
neotree = true,
noice = true,
cmp = true,
notify = true,
treesitter = true,
telescope = true,
which_key = true,
},
color_overrides = {
mocha = {
base = "#171717",
mantle = "#101010",
crust = "#0C0C0C",
},
},
custom_highlights = function(colors)
local utils = require "catppuccin.utils.colors"
local tint = function(color) return utils.blend(color, colors.base, 0.2) end

return {
--
-- notify
--
NotifyBackground = { bg = colors.mantle },
--
-- noice
--
NoiceCmdlinePopup = { bg = colors.mantle },
NoiceCmdlinePopupBorder = { bg = colors.mantle, fg = colors.mantle },
--
-- telescope
--
TelescopeMatching = { fg = colors.yellow },
TelescopeSelection = { fg = colors.text, bg = colors.surface0 },
-- results
TelescopeResultsNormal = { bg = colors.mantle },
TelescopeResultsBorder = { bg = colors.mantle, fg = colors.mantle },
TelescopeResultsTitle = { fg = colors.mantle },
-- prompt
TelescopePromptNormal = { bg = colors.surface0 },
TelescopePromptBorder = { bg = colors.surface0, fg = colors.surface0 },
TelescopePromptTitle = { bg = colors.teal, fg = colors.mantle },
TelescopePromptPrefix = { bg = colors.surface0 },
-- preview
TelescopePreviewNormal = { bg = colors.crust },
TelescopePreviewBorder = { bg = colors.crust, fg = colors.crust },
TelescopePreviewTitle = { bg = colors.pink, fg = colors.mantle },
--
-- neotree
--
NeoTreeNormal = { bg = colors.mantle },
NeoTreeNormalNC = { bg = colors.mantle },
--
-- cmp
--
PmenuSel = { bg = colors.mantle, fg = "NONE" },
Pmenu = { fg = colors.text, bg = colors.crust },

CmpItemAbbrDeprecated = { fg = colors.overlay0, bg = "NONE", style = { "strikethrough" } },
CmpItemAbbrMatch = { fg = colors.yellow, bg = "NONE", style = { "bold" } },
CmpItemAbbrMatchFuzzy = { fg = colors.yellow, bg = "NONE", style = { "bold" } },
CmpItemMenu = { fg = colors.lavender, bg = "NONE", style = { "italic" } },

CmpItemKindField = { fg = colors.rosewater, bg = tint(colors.rosewater) },
CmpItemKindProperty = { fg = colors.rosewater, bg = tint(colors.rosewater) },
CmpItemKindEvent = { fg = colors.rosewater, bg = tint(colors.rosewater) },

CmpItemKindText = { fg = colors.text, bg = tint(colors.text) },
CmpItemKindModule = { fg = colors.text, bg = tint(colors.text) },
CmpItemKindVariable = { fg = colors.text, bg = tint(colors.text) },
CmpItemKindFile = { fg = colors.text, bg = tint(colors.text) },
CmpItemKindUnit = { fg = colors.text, bg = tint(colors.text) },
CmpItemKindValue = { fg = colors.text, bg = tint(colors.text) },

CmpItemKindEnum = { fg = colors.yellow, bg = tint(colors.yellow) },
CmpItemKindReference = { fg = colors.yellow, bg = tint(colors.yellow) },
CmpItemKindClass = { fg = colors.yellow, bg = tint(colors.yellow) },
CmpItemKindFolder = { fg = colors.yellow, bg = tint(colors.yellow) },
CmpItemKindEnumMember = { fg = colors.yellow, bg = tint(colors.yellow) },
CmpItemKindInterface = { fg = colors.yellow, bg = tint(colors.yellow) },

CmpItemKindKeyword = { fg = colors.mauve, bg = tint(colors.mauve) },

CmpItemKindConstant = { fg = colors.peach, bg = tint(colors.peach) },

CmpItemKindConstructor = { fg = colors.lavender, bg = tint(colors.lavender) },

CmpItemKindFunction = { fg = colors.blue, bg = tint(colors.blue) },
CmpItemKindMethod = { fg = colors.blue, bg = tint(colors.blue) },

CmpItemKindStruct = { fg = colors.teal, bg = tint(colors.teal) },
CmpItemKindOperator = { fg = colors.teal, bg = tint(colors.teal) },

CmpItemKindSnippet = { fg = colors.flamingo, bg = tint(colors.flamingo) },

CmpItemKindColor = { fg = colors.pink, bg = tint(colors.pink) },
CmpItemKindTypeParameter = { fg = colors.maroon, bg = tint(colors.maroon) },
}
end,
},
}

describe("setup", function()
Expand Down
10 changes: 10 additions & 0 deletions vim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ globals:
args:
- type: function

C:
property: full-write
O:
property: full-write
U:
property: full-write

C.rosewater:
type: string
property: read-only
Expand Down Expand Up @@ -244,6 +251,9 @@ globals:
O.integrations.ts_rainbow2:
type: bool
property: read-only
O.integrations.rainbow_delimiters:
type: bool
property: read-only

O.integrations.barbecue.dim_dirname:
type: bool
Expand Down

0 comments on commit 2310246

Please sign in to comment.