|
| 1 | +""" |
| 2 | +Pygments styles for all Catppuccin flavours. |
| 3 | +""" |
| 4 | +from pygments.style import Style |
| 5 | +from pygments.token import ( |
| 6 | + Comment, |
| 7 | + Error, |
| 8 | + Keyword, |
| 9 | + Literal, |
| 10 | + Name, |
| 11 | + Number, |
| 12 | + Operator, |
| 13 | + Punctuation, |
| 14 | + String, |
| 15 | + Text, |
| 16 | + Token, |
| 17 | + _TokenType, |
| 18 | +) |
| 19 | + |
| 20 | +from catppuccin.flavour import Flavour |
| 21 | + |
| 22 | + |
| 23 | +def _make_styles(flavour: Flavour) -> dict[_TokenType, str]: |
| 24 | + return { |
| 25 | + Token: f"#{flavour.text.hex}", |
| 26 | + Text: f"#{flavour.text.hex}", |
| 27 | + Error: f"#{flavour.red.hex}", |
| 28 | + Keyword: f"#{flavour.mauve.hex}", |
| 29 | + Keyword.Constant: f"#{flavour.peach.hex}", |
| 30 | + Keyword.Declaration: f"#{flavour.blue.hex}", |
| 31 | + Keyword.Namespace: f"#{flavour.teal.hex}", |
| 32 | + Keyword.Pseudo: f"#{flavour.mauve.hex}", |
| 33 | + Keyword.Reserved: f"#{flavour.mauve.hex}", |
| 34 | + Keyword.Type: f"#{flavour.blue.hex}", |
| 35 | + Name: f"#{flavour.peach.hex}", |
| 36 | + Name.Attribute: f"#{flavour.blue.hex}", |
| 37 | + Name.Constant: f"#{flavour.yellow.hex}", |
| 38 | + Name.Decorator: f"#{flavour.blue.hex}", |
| 39 | + Name.Function: f"#{flavour.blue.hex}", |
| 40 | + Name.Function.Magic: f"#{flavour.sky.hex}", |
| 41 | + Name.Label: f"#{flavour.blue.hex}", |
| 42 | + Name.Tag: f"#{flavour.mauve.hex}", |
| 43 | + Literal: f"#{flavour.text.hex}", |
| 44 | + String: f"#{flavour.green.hex}", |
| 45 | + Number: f"#{flavour.peach.hex}", |
| 46 | + Punctuation: f"#{flavour.text.hex}", |
| 47 | + Operator: f"#{flavour.sky.hex}", |
| 48 | + Comment: f"#{flavour.overlay0.hex}", |
| 49 | + } |
| 50 | + |
| 51 | + |
| 52 | +class LatteStyle(Style): # pylint: disable=too-few-public-methods |
| 53 | + """Catppuccin Latte pygments style.""" |
| 54 | + |
| 55 | + styles = _make_styles(Flavour.latte()) |
| 56 | + |
| 57 | + |
| 58 | +class FrappeStyle(Style): # pylint: disable=too-few-public-methods |
| 59 | + """Catppuccin Frappé pygments style.""" |
| 60 | + |
| 61 | + styles = _make_styles(Flavour.frappe()) |
| 62 | + |
| 63 | + |
| 64 | +class MacchiatoStyle(Style): # pylint: disable=too-few-public-methods |
| 65 | + """Catppuccin Macchiato pygments style.""" |
| 66 | + |
| 67 | + styles = _make_styles(Flavour.macchiato()) |
| 68 | + |
| 69 | + |
| 70 | +class MochaStyle(Style): # pylint: disable=too-few-public-methods |
| 71 | + """Catppuccin Mocha pygments style.""" |
| 72 | + |
| 73 | + styles = _make_styles(Flavour.mocha()) |
0 commit comments