Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(syntax)!: reimplement the syntax highlighter #481

Closed
4 changes: 2 additions & 2 deletions lua/catppuccin/groups/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ function M.get()
PmenuThumb = { bg = C.overlay0 }, -- Popup menu: Thumb of the scrollbar.
Question = { fg = C.blue }, -- |hit-enter| prompt and yes/no questions
QuickFixLine = { bg = C.surface1, style = { "bold" } }, -- Current |quickfix| item in the quickfix window. Combined with |hl-CursorLine| when the cursor is there.
Search = { bg = U.darken(C.sky, 0.30, C.base), fg = C.text }, -- Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out.
IncSearch = { bg = U.darken(C.sky, 0.90, C.base), fg = C.mantle }, -- 'incsearch' highlighting; also used for the text replaced with ":s///c"
Search = { bg = C.surface1, fg = C.pink, style = { "bold" } }, -- Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out.
IncSearch = { bg = C.pink, fg = C.surface1 }, -- 'incsearch' highlighting; also used for the text replaced with ":s///c"
CurSearch = { bg = C.red, fg = C.mantle }, -- 'cursearch' highlighting: highlights the current search you're on differently
SpecialKey = { link = "NonText" }, -- Unprintable characters: text displayed differently from what it really is. But not 'listchars' textspace. |hl-Whitespace|
SpellBad = { sp = C.red, style = { "undercurl" } }, -- Word that is not recognized by the spellchecker. |spell| Combined with the highlighting used otherwise.
Expand Down
2 changes: 1 addition & 1 deletion lua/catppuccin/groups/integrations/native_lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function M.get()
local error = C.red
local warning = C.yellow
local info = C.sky
local hint = C.teal
local hint = C.rosewater
local darkening_percentage = 0.095

return {
Expand Down
32 changes: 17 additions & 15 deletions lua/catppuccin/groups/integrations/semantic_tokens.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,37 @@ If you want to stay on nvim 0.7, disable the integration.
return {}
end
return {
["@lsp.type.boolean"] = { link = "@boolean" },
["@lsp.type.builtinType"] = { link = "@type.builtin" },
["@lsp.type.class"] = { link = "@type" },
["@lsp.type.comment"] = { link = "@comment" },
["@lsp.type.enum"] = { link = "@type" },
["@lsp.type.enumMember"] = { link = "@constant" },
["@lsp.type.escapeSequence"] = { link = "@string.escape" },
["@lsp.type.formatSpecifier"] = { link = "@punctuation.special" },
["@lsp.type.interface"] = { fg = C.flamingo },
["@lsp.type.event"] = { link = "@event" },
["@lsp.type.formatSpecifier"] = { link = "@string.special" },
["@lsp.type.interface"] = { link = "@type" },
["@lsp.type.keyword"] = { link = "@keyword" },
["@lsp.type.modifier"] = { link = "@keyword" },
["@lsp.type.namespace"] = { link = "@namespace" },
["@lsp.type.number"] = { link = "@number" },
["@lsp.type.operator"] = { link = "@operator" },
["@lsp.type.parameter"] = { link = "@parameter" },
["@lsp.type.property"] = { link = "@property" },
["@lsp.type.property.cpp"] = { link = "@property.cpp" },
["@lsp.type.regex"] = { link = "@string.regex" },
["@lsp.type.selfKeyword"] = { link = "@variable.builtin" },
["@lsp.type.typeAlias"] = { link = "@type.definition" },
["@lsp.type.unresolvedReference"] = { link = "@error" },
["@lsp.type.struct"] = { link = "@type" },
["@lsp.type.typeParameter"] = { link = "@type" },
["@lsp.type.variable"] = {}, -- use treesitter styles for regular variables
["@lsp.typemod.class.defaultLibrary"] = { link = "@type.builtin" },
["@lsp.typemod.enum.defaultLibrary"] = { link = "@type.builtin" },
["@lsp.typemod.enumMember.defaultLibrary"] = { link = "@constant.builtin" },
["@lsp.typemod.function.defaultLibrary"] = { link = "@function.builtin" },
["@lsp.typemod.keyword.async"] = { link = "@keyword.coroutine" },
["@lsp.typemod.macro.defaultLibrary"] = { link = "@function.builtin" },
["@lsp.typemod.method.defaultLibrary"] = { link = "@function.builtin" },
["@lsp.typemod.enum.defaultLibrary"] = { link = "@type" },
["@lsp.typemod.enumMember.defaultLibrary"] = { link = "@constant" },
["@lsp.typemod.function.defaultLibrary"] = { link = "@function" },
["@lsp.typemod.keyword.async"] = { link = "@keyword" },
["@lsp.typemod.macro.defaultLibrary"] = { link = "@constant.macro" },
["@lsp.typemod.method.defaultLibrary"] = { link = "@function" },
["@lsp.typemod.operator.injected"] = { link = "@operator" },
["@lsp.typemod.string.injected"] = { link = "@string" },
["@lsp.typemod.type.defaultLibrary"] = { link = "@type.builtin" },
["@lsp.typemod.variable.defaultLibrary"] = { link = "@variable.builtin" },
["@lsp.typemod.type.defaultLibrary"] = { link = "@type" },
["@lsp.typemod.variable.defaultLibrary"] = { link = "@variable" },
["@lsp.typemod.variable.injected"] = { link = "@variable" },
}
end
Expand Down
22 changes: 11 additions & 11 deletions lua/catppuccin/groups/integrations/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
["@function"] = { link = "Function" }, -- For function (calls and definitions).
["@function.builtin"] = { fg = C.peach, style = O.styles.functions or {} }, -- For builtin functions: table.insert in Lua.
["@function.call"] = { link = "Function" }, -- function calls
["@function.macro"] = { fg = C.teal, style = O.styles.functions or {} }, -- For macro defined functions (calls and definitions): each macro_rules in Rust.
["@function.macro"] = { link = "Constant" }, -- For macro defined functions (calls and definitions): each macro_rules in RusC.
["@method"] = { link = "Function" }, -- For method definitions.
["@method.call"] = { link = "Function" }, -- For method calls.

["@constructor"] = { fg = C.sapphire }, -- For constructor calls and definitions: = { } in Lua, and Java constructors.
["@parameter"] = { fg = C.maroon, style = O.styles.variables or {} }, -- 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.
["@keyword.function"] = { fg = C.mauve, style = O.styles.keywords or {} }, -- For keywords used to define a function.
["@keyword.operator"] = { fg = C.mauve, style = O.styles.operators or {} }, -- For new keyword operator
["@keyword.return"] = { fg = C.mauve, style = O.styles.keywords or {} },
["@keyword.function"] = { fg = C.maroon, style = O.styles.keywords or {} }, -- For keywords used to define a function.
["@keyword.operator"] = { link = "Operator" }, -- For new keyword operator
["@keyword.return"] = { fg = C.pink, style = O.styles.keywords or {} },
-- JS & derivative
["@keyword.export"] = { fg = C.sky, style = O.styles.keywords },

Expand All @@ -73,19 +73,18 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci

["@storageclass"] = { link = "StorageClass" }, -- visibility/life-time/etc. modifiers (e.g. `static`)
["@attribute"] = { link = "Constant" }, -- attribute annotations (e.g. Python decorators)
["@field"] = { fg = C.lavender }, -- For fields.
["@property"] = { fg = C.lavender, style = O.styles.properties or {} }, -- Same as TSField.
["@field"] = { fg = C.rosewater }, -- For fields.
["@property"] = { fg = C.rosewater, style = O.styles.properties or {} }, -- Same as TSField.

-- Identifiers

["@variable"] = { fg = C.text, style = O.styles.variables or {} }, -- Any variable name that does not have another highlight.
["@variable"] = { link = "Identifier" }, -- Any variable name that does not have another highlight.
["@variable.builtin"] = { fg = C.red, style = O.styles.properties or {} }, -- Variable names that are defined by the languages, like this or self.

["@constant"] = { link = "Constant" }, -- For constants
["@constant.builtin"] = { fg = C.peach, style = O.styles.keywords or {} }, -- For constant that are built in the language: nil in Lua.
["@constant.builtin"] = { fg = C.lavender, style = O.styles.properties or {} }, -- For constant that are built in the language: nil in Lua.
["@constant.macro"] = { link = "Macro" }, -- For constants that are defined by macros: NULL in C.

["@namespace"] = { fg = C.lavender, style = { "italic" } }, -- For identifiers referring to modules and namespaces.
["@namespace"] = { fg = C.rosewater }, -- For identifiers referring to modules and namespaces.
["@symbol"] = { fg = C.flamingo },

-- Text
Expand Down Expand Up @@ -149,6 +148,7 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci

-- lua
["@constructor.lua"] = { fg = C.flamingo }, -- For constructor calls and definitions: = { } in Lua.
["@field.lua"] = { fg = C.lavender },

-- typescript
["@property.typescript"] = { fg = C.lavender, style = O.styles.properties or {} },
Expand Down
18 changes: 9 additions & 9 deletions lua/catppuccin/groups/syntax.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ function M.get()
Number = { fg = C.peach, style = O.styles.numbers or {} }, -- a number constant: 234, 0xff
Float = { link = "Number" }, -- a floating point constant: 2.3e10
Boolean = { fg = C.peach, style = O.styles.booleans or {} }, -- a boolean constant: TRUE, false
Identifier = { fg = C.flamingo, style = O.styles.variables or {} }, -- (preferred) any variable name
Identifier = { fg = C.text, style = O.styles.variables or {} }, -- (preferred) any variable name
Function = { fg = C.blue, style = O.styles.functions or {} }, -- function name (also: methods for classes)
Statement = { fg = C.mauve }, -- (preferred) any statement
Conditional = { fg = C.mauve, style = O.styles.conditionals or {} }, -- if, then, else, endif, switch, etc.
Repeat = { fg = C.mauve, style = O.styles.loops or {} }, -- for, do, while, etc.
Label = { fg = C.sapphire }, -- case, default, etc.
Label = { fg = C.rosewater }, -- case, default, etc.
Operator = { fg = C.sky, style = O.styles.operators or {} }, -- "sizeof", "+", "*", etc.
Keyword = { fg = C.mauve, style = O.styles.keywords or {} }, -- any other keyword
Exception = { fg = C.mauve, style = O.styles.keywords or {} }, -- try, catch, throw
Keyword = { fg = C.maroon, style = O.styles.keywords or {} }, -- any other keyword
Exception = { fg = C.peach, style = O.styles.keywords or {} }, -- try, catch, throw

PreProc = { fg = C.pink }, -- (preferred) generic Preprocessor
Include = { fg = C.mauve, style = O.styles.keywords or {} }, -- preprocessor #include
Include = { fg = C.teal, style = O.styles.keywords or {} }, -- preprocessor #include
Define = { link = "PreProc" }, -- preprocessor #define
Macro = { fg = C.mauve }, -- same as Define
Macro = { link = "Constant" }, -- same as Define
PreCondit = { link = "PreProc" }, -- preprocessor #if, #else, #endif, etc.

StorageClass = { fg = C.yellow }, -- static, register, volatile, etc.
Structure = { fg = C.yellow }, -- struct, union, enum, etc.
StorageClass = { link = "Keyword" }, -- static, register, volatile, etc.
Structure = { link = "Keyword" }, -- struct, union, enum, etc.
Special = { fg = C.pink }, -- (preferred) any special symbol
Type = { fg = C.yellow, style = O.styles.types or {} }, -- (preferred) int, long, char, etc.
Typedef = { link = "Type" }, -- A typedef
SpecialChar = { link = "Special" }, -- special character in a constant
Tag = { fg = C.lavender, style = { "bold" } }, -- you can use CTRL-] on this
Delimiter = { fg = C.overlay2 }, -- character that needs attention
Delimiter = { fg = C.teal }, -- delimiters (e.g. `;` / `.` / `,`)
Debug = { link = "Special" }, -- debugging statements

Underlined = { style = { "underline" } }, -- (preferred) text that stands out, HTML links
Expand Down