From 246f3f94daf6847c179ae4d34a2149b805bc41e0 Mon Sep 17 00:00:00 2001 From: Rahul Iyer Date: Tue, 4 Nov 2025 09:21:12 -0800 Subject: [PATCH] feat: add Xcode theme generation --- lua/tokyonight/extra/init.lua | 1 + lua/tokyonight/extra/xcode.lua | 379 +++++++++++++++++++++++++++++++++ scripts/build | 2 +- 3 files changed, 381 insertions(+), 1 deletion(-) create mode 100644 lua/tokyonight/extra/xcode.lua diff --git a/lua/tokyonight/extra/init.lua b/lua/tokyonight/extra/init.lua index 8ac3fa3ce..49b3d803b 100644 --- a/lua/tokyonight/extra/init.lua +++ b/lua/tokyonight/extra/init.lua @@ -43,6 +43,7 @@ M.extras = { tmux = { ext = "tmux", url = "https://github.com/tmux/tmux/wiki", label = "Tmux" }, wezterm = { ext = "toml", url = "https://wezfurlong.org/wezterm/config/files.html", label = "WezTerm" }, windows_terminal = { ext = "json", url = "https://aka.ms/terminal-documentation", label = "Windows Terminal" }, + xcode = { ext = "xccolortheme", url = "https://developer.apple.com/xcode/", label = "Xcode" }, xfceterm = { ext = "theme", url = "https://docs.xfce.org/apps/terminal/advanced", label = "Xfce Terminal" }, xresources = { ext = "Xresources", url = "https://wiki.archlinux.org/title/X_resources", label = "Xresources" }, yazi = { ext = "toml", url = "https://github.com/sxyazi/yazi", label = "Yazi" }, diff --git a/lua/tokyonight/extra/xcode.lua b/lua/tokyonight/extra/xcode.lua new file mode 100644 index 000000000..2634af625 --- /dev/null +++ b/lua/tokyonight/extra/xcode.lua @@ -0,0 +1,379 @@ +local function color_string(hex, alpha) + alpha = alpha or 1.0 + hex = hex:gsub("#", "") + local rgb = { + r = tonumber("0x" .. hex:sub(1, 2)) / 255, + g = tonumber("0x" .. hex:sub(3, 4)) / 255, + b = tonumber("0x" .. hex:sub(5, 6)) / 255, + } + return string.format("%.6f %.6f %.6f %.6f", rgb.r, rgb.g, rgb.b, alpha) +end + +local M = {} + +-- Default font configuration +-- You can modify these to customize the fonts used in Xcode +M.config = { + fonts = { + regular = "SFMono-Regular", + bold = "SFMono-Bold", + italic = "SFMono-Italic", + bold_italic = "SFMono-BoldItalic", + system_ui = ".AppleSystemUIFont", + system_ui_italic = ".AppleSystemUIFontItalic", + system_ui_bold = ".AppleSystemUIFontBold", + }, + sizes = { + editor = 11.0, + console = 11.0, + markup_code = 11.0, + markup_text = 11.0, + markup_heading_primary = 24.0, + markup_heading_secondary = 18.0, + markup_heading_other = 14.0, + }, +} + +function M.generate(colors, _, opts) + local config = M.config + + -- Allow overriding font configuration through opts + if opts and opts.xcode then + if opts.xcode.fonts then + config.fonts = vim.tbl_deep_extend("force", config.fonts, opts.xcode.fonts) + end + if opts.xcode.sizes then + config.sizes = vim.tbl_deep_extend("force", config.sizes, opts.xcode.sizes) + end + end + + -- Helper function to format font string + local function font(family, size) + return string.format("%s - %.1f", family, size) + end + + local xcode_theme = string.format( + [[ + + + + DVTConsoleDebuggerInputTextColor + %s + DVTConsoleDebuggerInputTextFont + %s + DVTConsoleDebuggerOutputTextColor + %s + DVTConsoleDebuggerOutputTextFont + %s + DVTConsoleDebuggerPromptTextColor + %s + DVTConsoleDebuggerPromptTextFont + %s + DVTConsoleExectuableInputTextColor + %s + DVTConsoleExectuableInputTextFont + %s + DVTConsoleExectuableOutputTextColor + %s + DVTConsoleExectuableOutputTextFont + %s + DVTConsoleTextBackgroundColor + %s + DVTConsoleTextInsertionPointColor + %s + DVTConsoleTextSelectionColor + %s + DVTDebuggerInstructionPointerColor + %s + DVTFontAndColorVersion + 1 + DVTLineSpacing + 1.1000000238418579 + DVTMarkupTextBackgroundColor + %s + DVTMarkupTextBorderColor + %s + DVTMarkupTextCodeFont + %s + DVTMarkupTextEmphasisColor + %s + DVTMarkupTextEmphasisFont + %s + DVTMarkupTextInlineCodeColor + %s + DVTMarkupTextLinkColor + %s + DVTMarkupTextLinkFont + %s + DVTMarkupTextNormalColor + %s + DVTMarkupTextNormalFont + %s + DVTMarkupTextOtherHeadingColor + %s + DVTMarkupTextOtherHeadingFont + %s + DVTMarkupTextPrimaryHeadingColor + %s + DVTMarkupTextPrimaryHeadingFont + %s + DVTMarkupTextSecondaryHeadingColor + %s + DVTMarkupTextSecondaryHeadingFont + %s + DVTMarkupTextStrongColor + %s + DVTMarkupTextStrongFont + %s + DVTScrollbarMarkerAnalyzerColor + %s + DVTScrollbarMarkerBreakpointColor + %s + DVTScrollbarMarkerDiffColor + %s + DVTScrollbarMarkerDiffConflictColor + %s + DVTScrollbarMarkerErrorColor + %s + DVTScrollbarMarkerRuntimeIssueColor + %s + DVTScrollbarMarkerWarningColor + %s + DVTSourceTextBackground + %s + DVTSourceTextBlockDimBackgroundColor + %s + DVTSourceTextCurrentLineHighlightColor + %s + DVTSourceTextInsertionPointColor + %s + DVTSourceTextInvisiblesColor + %s + DVTSourceTextSelectionColor + %s + DVTSourceTextSyntaxColors + + xcode.syntax.attribute + %s + xcode.syntax.character + %s + xcode.syntax.comment + %s + xcode.syntax.comment.doc + %s + xcode.syntax.comment.doc.keyword + %s + xcode.syntax.declaration.other + %s + xcode.syntax.declaration.type + %s + xcode.syntax.identifier.class + %s + xcode.syntax.identifier.class.system + %s + xcode.syntax.identifier.constant + %s + xcode.syntax.identifier.constant.system + %s + xcode.syntax.identifier.function + %s + xcode.syntax.identifier.function.system + %s + xcode.syntax.identifier.macro + %s + xcode.syntax.identifier.macro.system + %s + xcode.syntax.identifier.type + %s + xcode.syntax.identifier.type.system + %s + xcode.syntax.identifier.variable + %s + xcode.syntax.identifier.variable.system + %s + xcode.syntax.keyword + %s + xcode.syntax.mark + %s + xcode.syntax.markup.code + %s + xcode.syntax.number + %s + xcode.syntax.plain + %s + xcode.syntax.preprocessor + %s + xcode.syntax.string + %s + xcode.syntax.url + %s + + DVTSourceTextSyntaxFonts + + xcode.syntax.attribute + %s + xcode.syntax.character + %s + xcode.syntax.comment + %s + xcode.syntax.comment.doc + %s + xcode.syntax.comment.doc.keyword + %s + xcode.syntax.declaration.other + %s + xcode.syntax.declaration.type + %s + xcode.syntax.identifier.class + %s + xcode.syntax.identifier.class.system + %s + xcode.syntax.identifier.constant + %s + xcode.syntax.identifier.constant.system + %s + xcode.syntax.identifier.function + %s + xcode.syntax.identifier.function.system + %s + xcode.syntax.identifier.macro + %s + xcode.syntax.identifier.macro.system + %s + xcode.syntax.identifier.type + %s + xcode.syntax.identifier.type.system + %s + xcode.syntax.identifier.variable + %s + xcode.syntax.identifier.variable.system + %s + xcode.syntax.keyword + %s + xcode.syntax.mark + %s + xcode.syntax.markup.code + %s + xcode.syntax.number + %s + xcode.syntax.plain + %s + xcode.syntax.preprocessor + %s + xcode.syntax.string + %s + xcode.syntax.url + %s + + +]], + -- Console colors + color_string(colors.fg), -- DVTConsoleDebuggerInputTextColor + font(config.fonts.bold, config.sizes.console), -- DVTConsoleDebuggerInputTextFont + color_string(colors.fg), -- DVTConsoleDebuggerOutputTextColor + font(config.fonts.regular, config.sizes.console), -- DVTConsoleDebuggerOutputTextFont + color_string(colors.green), -- DVTConsoleDebuggerPromptTextColor + font(config.fonts.bold, config.sizes.console), -- DVTConsoleDebuggerPromptTextFont + color_string(colors.fg), -- DVTConsoleExectuableInputTextColor + font(config.fonts.regular, config.sizes.console), -- DVTConsoleExectuableInputTextFont + color_string(colors.fg), -- DVTConsoleExectuableOutputTextColor + font(config.fonts.bold, config.sizes.console), -- DVTConsoleExectuableOutputTextFont + color_string(colors.bg), -- DVTConsoleTextBackgroundColor + color_string(colors.fg), -- DVTConsoleTextInsertionPointColor + color_string(colors.bg_visual), -- DVTConsoleTextSelectionColor + color_string(colors.yellow), -- DVTDebuggerInstructionPointerColor + -- Markup colors + color_string(colors.bg_dark), -- DVTMarkupTextBackgroundColor + color_string(colors.border), -- DVTMarkupTextBorderColor + font(config.fonts.regular, config.sizes.markup_code), -- DVTMarkupTextCodeFont + color_string(colors.fg), -- DVTMarkupTextEmphasisColor + font(config.fonts.system_ui_italic, config.sizes.markup_text), -- DVTMarkupTextEmphasisFont + color_string(colors.fg, 0.7), -- DVTMarkupTextInlineCodeColor + color_string(colors.blue), -- DVTMarkupTextLinkColor + font(config.fonts.system_ui, config.sizes.markup_text), -- DVTMarkupTextLinkFont + color_string(colors.fg), -- DVTMarkupTextNormalColor + font(config.fonts.system_ui, config.sizes.markup_text), -- DVTMarkupTextNormalFont + color_string(colors.blue), -- DVTMarkupTextOtherHeadingColor + font(config.fonts.system_ui, config.sizes.markup_heading_other), -- DVTMarkupTextOtherHeadingFont + color_string(colors.blue), -- DVTMarkupTextPrimaryHeadingColor + font(config.fonts.system_ui, config.sizes.markup_heading_primary), -- DVTMarkupTextPrimaryHeadingFont + color_string(colors.blue), -- DVTMarkupTextSecondaryHeadingColor + font(config.fonts.system_ui, config.sizes.markup_heading_secondary), -- DVTMarkupTextSecondaryHeadingFont + color_string(colors.fg), -- DVTMarkupTextStrongColor + font(config.fonts.system_ui_bold, config.sizes.markup_text), -- DVTMarkupTextStrongFont + -- Scrollbar markers + color_string(colors.purple), -- DVTScrollbarMarkerAnalyzerColor + color_string(colors.blue), -- DVTScrollbarMarkerBreakpointColor + color_string(colors.git.change), -- DVTScrollbarMarkerDiffColor + color_string(colors.red), -- DVTScrollbarMarkerDiffConflictColor + color_string(colors.error), -- DVTScrollbarMarkerErrorColor + color_string(colors.magenta), -- DVTScrollbarMarkerRuntimeIssueColor + color_string(colors.warning), -- DVTScrollbarMarkerWarningColor + -- Source editor colors + color_string(colors.bg), -- DVTSourceTextBackground + color_string(colors.bg_dark), -- DVTSourceTextBlockDimBackgroundColor + color_string(colors.bg_highlight), -- DVTSourceTextCurrentLineHighlightColor + color_string(colors.fg), -- DVTSourceTextInsertionPointColor + color_string(colors.dark3), -- DVTSourceTextInvisiblesColor + color_string(colors.bg_visual), -- DVTSourceTextSelectionColor + -- Syntax colors + color_string(colors.blue1), -- xcode.syntax.attribute + color_string(colors.green), -- xcode.syntax.character + color_string(colors.comment), -- xcode.syntax.comment + color_string(colors.comment), -- xcode.syntax.comment.doc + color_string(colors.purple), -- xcode.syntax.comment.doc.keyword + color_string(colors.purple), -- xcode.syntax.declaration.other + color_string(colors.cyan), -- xcode.syntax.declaration.type + color_string(colors.yellow), -- xcode.syntax.identifier.class + color_string(colors.cyan), -- xcode.syntax.identifier.class.system + color_string(colors.orange), -- xcode.syntax.identifier.constant + color_string(colors.magenta), -- xcode.syntax.identifier.constant.system + color_string(colors.blue), -- xcode.syntax.identifier.function + color_string(colors.blue1), -- xcode.syntax.identifier.function.system + color_string(colors.red), -- xcode.syntax.identifier.macro + color_string(colors.red), -- xcode.syntax.identifier.macro.system + color_string(colors.cyan), -- xcode.syntax.identifier.type + color_string(colors.cyan), -- xcode.syntax.identifier.type.system + color_string(colors.fg), -- xcode.syntax.identifier.variable + color_string(colors.blue2), -- xcode.syntax.identifier.variable.system + color_string(colors.purple), -- xcode.syntax.keyword + color_string(colors.purple), -- xcode.syntax.mark + color_string(colors.orange), -- xcode.syntax.markup.code + color_string(colors.orange), -- xcode.syntax.number + color_string(colors.fg), -- xcode.syntax.plain + color_string(colors.red), -- xcode.syntax.preprocessor + color_string(colors.green), -- xcode.syntax.string + color_string(colors.blue1), -- xcode.syntax.url + -- Syntax fonts (all using editor font) + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.attribute + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.character + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.comment + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.comment.doc + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.comment.doc.keyword + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.declaration.other + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.declaration.type + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.class + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.class.system + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.constant + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.constant.system + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.function + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.function.system + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.macro + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.macro.system + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.type + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.type.system + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.variable + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.identifier.variable.system + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.keyword + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.mark + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.markup.code + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.number + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.plain + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.preprocessor + font(config.fonts.regular, config.sizes.editor), -- xcode.syntax.string + font(config.fonts.regular, config.sizes.editor) -- xcode.syntax.url + ) + return xcode_theme +end + +return M diff --git a/scripts/build b/scripts/build index 8d527c539..30275a8b0 100755 --- a/scripts/build +++ b/scripts/build @@ -1,3 +1,3 @@ -#!/bin/env bash +#!/usr/bin/env bash nvim -u tests/minit.lua --headless +"lua require('tokyonight.extra').setup()" +qa