Skip to content

Commit

Permalink
feat(treesitter): follow helix and markup captures
Browse files Browse the repository at this point in the history
  • Loading branch information
ofseed committed Jan 2, 2024
1 parent d885b9a commit 775e18b
Showing 1 changed file with 68 additions and 36 deletions.
104 changes: 68 additions & 36 deletions lua/catppuccin/groups/integrations/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
local colors = { -- Reference: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md

-- Misc
["@comment"] = { link = "Comment" },
["@error"] = { link = "Error" },
["@preproc"] = { link = "PreProc" }, -- various preprocessor directives & shebangs
["@define"] = { link = "Define" }, -- preprocessor definition directives
["@operator"] = { link = "Operator" }, -- For any operator: +, but also -> and * in C.

-- Comment
["@comment"] = { link = "Comment" },
["comment.note"] = { fg = C.base, bg = C.blue },
["comment.warning"] = { fg = C.base, bg = C.yellow },
["comment.error"] = { fg = C.base, bg = C.red },

-- Punctuation
["@punctuation.delimiter"] = { link = "Delimiter" }, -- For delimiters (e.g. `;` / `.` / `,`).
["@punctuation.bracket"] = { fg = C.overlay2 }, -- For brackets and parenthesis.
Expand All @@ -32,6 +36,7 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
["@string.escape"] = { fg = C.pink, style = O.styles.strings or {} }, -- For escape characters within a string.
["@string.special"] = { link = "Special" }, -- other special strings (e.g. dates)
["@string.special.symbol"] = { fg = C.flamingo },
["@string.special.url"] = { fg = C.rosewater, style = { "italic", "underline" } }, -- urls, links and emails

["@character"] = { link = "Character" }, -- character literals
["@character.special"] = { link = "SpecialChar" }, -- special characters (e.g. wildcards)
Expand All @@ -46,8 +51,8 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
["@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.
["@method"] = { link = "Function" }, -- For method definitions.
["@method.call"] = { link = "Function" }, -- For method calls.
["@function.method"] = { link = "Function" }, -- For method definitions.
["@function.method.call"] = { link = "Function" }, -- For method calls.

["@constructor"] = { fg = C.sapphire }, -- For constructor calls and definitions: = { } in Lua, and Java constructors.

Expand All @@ -56,6 +61,8 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
["@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.storage"] = { link = "StorageClass" }, -- visibility/life-time/etc. modifiers (e.g. `static`)
["@keyword.directive"] = { link = "PreProc" }, -- various preprocessor directives & shebangs
-- JS & derivative
["@keyword.export"] = { fg = C.sky, style = O.styles.keywords },

Expand All @@ -72,16 +79,15 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
["@type.definition"] = { link = "Type" }, -- type definitions (e.g. `typedef` in C)
["@type.qualifier"] = { link = "Keyword" }, -- type qualifiers (e.g. `const`)

["@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.

-- Identifiers

["@variable"] = { fg = C.text, style = O.styles.variables or {} }, -- 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.
["@variable.parameter"] = { fg = C.maroon, style = O.styles.variables or {} }, -- For parameters of a function.
["@variable.member"] = { fg = C.lavender }, -- For fields.

["@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.
Expand All @@ -95,23 +101,22 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
["@markup.emphasis"] = { fg = C.maroon, style = { "italic" } }, -- italic
["@markup.underline"] = { link = "Underline" }, -- underlined text
["@markup.strike"] = { fg = C.text, style = { "strikethrough" } }, -- strikethrough text
["@markup.headline"] = { fg = C.blue, style = { "bold" } }, -- titles like: # Example
["@markup.heading"] = { fg = C.blue, style = { "bold" } }, -- titles like: # Example
["@markup.raw"] = { fg = C.teal }, -- used for inline code in markdown and for doc in python (""")
["@markup.link.uri"] = { fg = C.rosewater, style = { "italic", "underline" } }, -- urls, links and emails
["@markup.link.url"] = { fg = C.rosewater, style = { "italic", "underline" } }, -- urls, links and emails
["@markup.math"] = { fg = C.blue }, -- math environments (e.g. `$ ... $` in LaTeX)
["@markup.environment"] = { fg = C.pink }, -- text environments of markup languages
["@markup.environment.name"] = { fg = C.blue }, -- text indicating the type of an environment
["@markup.reference"] = { link = "Tag" }, -- text references, footnotes, citations, etc.

["@markup.todo"] = { fg = C.base, bg = C.yellow }, -- todo notes
["@markup.todo.checked"] = { fg = C.green }, -- todo notes
["@markup.todo.unchecked"] = { fg = C.overlay1 }, -- todo notes
["@markup.note"] = { fg = C.base, bg = C.blue },
["@markup.warning"] = { fg = C.base, bg = C.yellow },
["@markup.danger"] = { fg = C.base, bg = C.red },
["@markup.list"] = { link = "Special" },
["@markup.list.checked"] = { fg = C.green }, -- todo notes
["@markup.list.unchecked"] = { fg = C.overlay1 }, -- todo notes

["@markup.diff.add"] = { link = "diffAdded" }, -- added text (for diff files)
["@markup.diff.delete"] = { link = "diffRemoved" }, -- deleted text (for diff files)
-- Diff
["@diff.plus"] = { link = "diffAdded" }, -- added text (for diff files)
["@diff.minus"] = { link = "diffRemoved" }, -- deleted text (for diff files)
["@diff.delta"] = { link = "diffChanged" }, -- deleted text (for diff files)

-- Tags
["@tag"] = { fg = C.mauve }, -- Tags like html tag names.
Expand All @@ -123,12 +128,12 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
["@function.builtin.bash"] = { fg = C.red, style = { "italic" } },

-- markdown
["@text.title.2.markdown"] = { link = "rainbow2" },
["@text.title.1.markdown"] = { link = "rainbow1" },
["@text.title.3.markdown"] = { link = "rainbow3" },
["@text.title.4.markdown"] = { link = "rainbow4" },
["@text.title.5.markdown"] = { link = "rainbow5" },
["@text.title.6.markdown"] = { link = "rainbow6" },
["@markup.heading.1.markdown"] = { link = "rainbow1" },
["@markup.heading.2.markdown"] = { link = "rainbow2" },
["@markup.heading.3.markdown"] = { link = "rainbow3" },
["@markup.heading.4.markdown"] = { link = "rainbow4" },
["@markup.heading.5.markdown"] = { link = "rainbow5" },
["@markup.heading.6.markdown"] = { link = "rainbow6" },

-- java
["@constant.java"] = { fg = C.teal },
Expand Down Expand Up @@ -160,14 +165,14 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
["@tag.attribute.tsx"] = { fg = C.mauve, style = { "italic" } },

-- yaml
["@field.yaml"] = { fg = C.blue }, -- For fields.
["@variable.member.yaml"] = { fg = C.blue }, -- For fields.

-- Ruby
["@string.special.symbol.ruby"] = { fg = C.flamingo },

-- PHP
["@method.php"] = { link = "Function" },
["@method.call.php"] = { link = "Function" },
["@function.method.php"] = { link = "Function" },
["@function.method.call.php"] = { link = "Function" },

-- C/CPP
["@type.builtin.c"] = { fg = C.yellow, style = {} },
Expand All @@ -181,6 +186,7 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci

-- Legacy highlights
colors["@parameter"] = colors["@variable.parameter"]
colors["@field"] = colors["@variable.member"]
colors["@namespace"] = colors["@module"]
colors["@float"] = colors["number.float"]
colors["@symbol"] = colors["@string.special.symbol"]
Expand All @@ -191,26 +197,52 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
colors["@text.emphasis"] = colors["@markup.emphasis"]
colors["@text.underline"] = colors["@markup.underline"]
colors["@text.strike"] = colors["@markup.strike"]
colors["@text.title"] = colors["@markup.headline"]
colors["@text.literal"] = colors["@markup.raw"]
colors["@text.uri"] = colors["@markup.link.uri"]
colors["@text.uri"] = colors["@markup.link.url"]
colors["@text.math"] = colors["@markup.math"]
colors["@text.environment"] = colors["@markup.environment"]
colors["@text.environment.name"] = colors["@markup.environment.name"]

colors["@text.title"] = colors["@markup.heading"]
colors["@text.literal"] = colors["@markup.raw"]
colors["@text.reference"] = colors["@markup.reference"]

colors["@text.todo"] = colors["@markup.todo"]
colors["@text.todo.checked"] = colors["@markup.todo.checked"]
colors["@text.todo.unchecked"] = colors["@markup.todo.unchecked"]
colors["@text.note"] = colors["@markup.note"]
colors["@text.warning"] = colors["@markup.warning"]
colors["@text.danger"] = colors["@markup.danger"]
colors["@text.todo.checked"] = colors["@markup.list.checked"]
colors["@text.todo.unchecked"] = colors["@markup.list.unchecked"]

-- @text.todo is now for todo comments, not todo notes like in markdown
colors["@text.todo"] = colors["comment.warning"]
colors["@text.warning"] = colors["comment.warning"]
colors["@text.note"] = colors["comment.note"]
colors["@text.danger"] = colors["comment.error"]

colors["@text.diff.add"] = colors["@markup.diff.add"]
colors["@text.diff.delete"] = colors["@markup.diff.delete"]
-- @text.uri is now
-- @markup.link.url in markup links
-- @string.special.url outside of markup
colors["text.uri"] = colors["@markup.link.uri"]

colors["@method"] = colors["@function.method"]
colors["@method.call"] = colors["@function.method.call"]

colors["@text.diff.add"] = colors["@diff.plus"]
colors["@text.diff.delete"] = colors["@diff.minus"]

colors["@preproc"] = colors["@keyword.directive"]
colors["@storageclass"] = colors["@keyword.storage"]

colors["@symbol.ruby"] = colors["@string.special.symbol.ruby"]

colors["@variable.member.yaml"] = colors["@field.yaml"]

colors["@text.title.1.markdown"] = colors["@markup.heading.1.markdown"]
colors["@text.title.2.markdown"] = colors["@markup.heading.2.markdown"]
colors["@text.title.3.markdown"] = colors["@markup.heading.3.markdown"]
colors["@text.title.4.markdown"] = colors["@markup.heading.4.markdown"]
colors["@text.title.5.markdown"] = colors["@markup.heading.5.markdown"]
colors["@text.title.6.markdown"] = colors["@markup.heading.6.markdown"]

colors["@method.php"] = colors["@function.method.php"]
colors["@method.call.php"] = colors["@function.method.call.php"]

return colors
end

Expand Down

0 comments on commit 775e18b

Please sign in to comment.