[add chroma XML style target for kitty diff ยท๐‘‘๐‘ด๐‘•๐‘‘๐‘ฉ๐‘ค **20260809210252 Ignore-this: 6584cb3ec39bd8985dd3f74c75f5e3895b6c16994af3f24f64695dc221b66a27669f9ed423909ed9 ] hunk ./bin/printer.ml 13 + | "chroma dark" -> Fmt.pr "%a" Chroma.pp_style Colorscheme.Dark + | "chroma light" -> Fmt.pr "%a" Chroma.pp_style Colorscheme.Light addfile ./lib/chroma.ml hunk ./lib/chroma.ml 1 - +(*โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ SPDX-FileCopyrightText: 2021โ€“2026 toastal โ”‚ +โ”‚ SPDX-License-Identifier: MPL-2.0 โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*) +(* Custom style schema: https://github.com/alecthomas/chroma *) +(* Chroma styles are flat XML tokens โ€” no pygments dotted names. *) +open Colorscheme + +let chroma_rules : (string * theme) list = + let c = colorscheme in + [ + ("Other", c.normal); + ("Text", c.normal); + ("Comment", c.comment); + ("CommentPreproc", c.pre_proc); + ("CommentSpecial", c.special_comment); + ("Error", c.error); + ("GenericHeading", c.title); + ("GenericDeleted", c.diff_delete); + ("GenericInserted", c.diff_add); + ("Keyword", c.keyword); + ("LiteralNumber", c.number); + ("LiteralString", c.string); + ("LiteralStringEscape", c.special_char); + ("Name", c.identifier); + ("NameBuiltin", c.special); + ("NameClass", c.structure); + ("NameConstant", c.constant); + ("NameException", c.exception'); + ("NameFunction", c.function'); + ("NameTag", c.tag); + ("Operator", c.operator); + ] + +let pp_banner (ppf : Format.formatter) () : unit = + Fmt.pf ppf {|@.|} + +let pp_entry (ppf : Format.formatter) ((attr, hl): string * Highlight.t) : unit = + let style_to_style = function + | Bold -> Some "bold" + | Italic -> Some "italic" + | Underline | StrikeThrough | Undercurl -> Some "underline" + | _ -> None + in + let styles : string list = + List.concat + [ + List.filter_map style_to_style (Styles.to_list hl.style); + Option.to_list (Option.map (fun c -> "bg:" ^ Xterm_colors.hex_string_of_unit8 c) hl.bg); + Option.to_list (Option.map (fun c -> Xterm_colors.hex_string_of_unit8 c) hl.fg); + ] + in + if styles = [] then + () + else + let style = String.concat " " styles in + Fmt.pf ppf {| @.|} attr style + +let pp_style (ppf : Format.formatter) (theme_name : theme_name) : unit = + Fmt.set_utf_8 ppf true; + let (name, counterpart, background, tname) = + match theme_name with + | Dark -> ("sugilite256-dark", "sugilite256-light", "#000000", (fun (t : theme) -> t.dark)) + | Light -> ("sugilite256-light", "sugilite256-dark", "#ffffff", (fun (t : theme) -> t.light)) + in + pp_banner ppf (); + Fmt.pf ppf "@[@." + hunk ./nix/overlay/default.nix 17 + chroma = lib.genAttrs theme_names ( + theme: self.callPackage ../package/sugilite256-chroma.nix { inherit theme; } + ); addfile ./nix/package/sugilite256-chroma.nix hunk ./nix/package/sugilite256-chroma.nix 1 - +#โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +# SPDX-FileCopyrightText: 2026 toastal โ”‚ +# SPDX-License-Identifier: MPL-2.0 โ”‚ +#โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +{ + theme, + runCommand, + bin, +}: + +runCommand "sugilite256-chroma-${theme}.xml" + { + nativeBuildInputs = [ bin ]; + meta.license = bin.meta.license; + } + '' + mkdir -p "$out/styles" + sugilite256 "chroma ${theme}" >"$out/styles/sugilite256-${theme}.xml" + ''