diff --git a/modules/programs/zed-editor.nix b/modules/programs/zed-editor.nix index 44706ef43..472fc1698 100644 --- a/modules/programs/zed-editor.nix +++ b/modules/programs/zed-editor.nix @@ -105,6 +105,25 @@ in in the wiki. ''; }; + + themes = mkOption { + description = '' + Each theme is written to + {file}`$XDG_CONFIG_HOME/zed/themes/theme-name.json` + where the name of each attribute is the theme-name + + See for the structure of a + Zed theme + ''; + type = types.attrsOf ( + types.oneOf [ + jsonFormat.type + types.path + types.lines + ] + ); + default = { }; + }; }; }; @@ -136,16 +155,34 @@ in } ); - xdg.configFile."zed/settings.json" = ( - mkIf (mergedSettings != { }) { - source = jsonFormat.generate "zed-user-settings" mergedSettings; - } - ); + xdg.configFile = + lib.attrsets.unionOfDisjoint + { + "zed/settings.json" = ( + mkIf (mergedSettings != { }) { + source = jsonFormat.generate "zed-user-settings" mergedSettings; + } + ); - xdg.configFile."zed/keymap.json" = ( - mkIf (cfg.userKeymaps != { }) { - source = jsonFormat.generate "zed-user-keymaps" cfg.userKeymaps; - } - ); + "zed/keymap.json" = ( + mkIf (cfg.userKeymaps != { }) { + source = jsonFormat.generate "zed-user-keymaps" cfg.userKeymaps; + } + ); + } + ( + lib.mapAttrs' ( + n: v: + lib.nameValuePair "zed/themes/${n}.json" { + source = + if lib.isString v then + pkgs.writeText "zed-theme-${n}" v + else if builtins.isPath v || lib.isStorePath v then + v + else + jsonFormat.generate "zed-theme-${n}" v; + } + ) cfg.themes + ); }; } diff --git a/tests/modules/programs/zed-editor/default.nix b/tests/modules/programs/zed-editor/default.nix index 2fcd8da2c..4a4e90667 100644 --- a/tests/modules/programs/zed-editor/default.nix +++ b/tests/modules/programs/zed-editor/default.nix @@ -3,4 +3,5 @@ zed-install-remote-server = ./install-remote-server.nix; zed-keymap = ./keymap.nix; zed-settings = ./settings.nix; + zed-themes = ./themes; } diff --git a/tests/modules/programs/zed-editor/themes/default.nix b/tests/modules/programs/zed-editor/themes/default.nix new file mode 100644 index 000000000..3060a92a0 --- /dev/null +++ b/tests/modules/programs/zed-editor/themes/default.nix @@ -0,0 +1,25 @@ +{ config, ... }: +{ + programs.zed-editor = { + enable = true; + package = config.lib.test.mkStubPackage { }; + themes = { + path = ./one.json; + string = builtins.readFile ./one.json; + json = builtins.fromJSON (builtins.readFile ./one.json); + }; + }; + + nmt.script = toString ( + map + (theme: '' + assertFileExists "home-files/.config/zed/themes/${theme}.json" + assertFileContent "home-files/.config/zed/themes/${theme}.json" "${./one.json}" + '') + [ + "path" + "string" + "json" + ] + ); +} diff --git a/tests/modules/programs/zed-editor/themes/one.json b/tests/modules/programs/zed-editor/themes/one.json new file mode 100644 index 000000000..01589ecf9 --- /dev/null +++ b/tests/modules/programs/zed-editor/themes/one.json @@ -0,0 +1,765 @@ +{ + "$schema": "https://zed.dev/schema/themes/v0.2.0.json", + "author": "Zed Industries", + "name": "One", + "themes": [ + { + "appearance": "dark", + "name": "One Dark", + "style": { + "background": "#3b414dff", + "border": "#464b57ff", + "border.disabled": "#414754ff", + "border.focused": "#47679eff", + "border.selected": "#293b5bff", + "border.transparent": "#00000000", + "border.variant": "#363c46ff", + "conflict": "#dec184ff", + "conflict.background": "#dec1841a", + "conflict.border": "#5d4c2fff", + "created": "#a1c181ff", + "created.background": "#a1c1811a", + "created.border": "#38482fff", + "deleted": "#d07277ff", + "deleted.background": "#d072771a", + "deleted.border": "#4c2b2cff", + "drop_target.background": "#83899480", + "editor.active_line.background": "#2f343ebf", + "editor.active_line_number": "#d0d4da", + "editor.active_wrap_guide": "#c8ccd41a", + "editor.background": "#282c33ff", + "editor.document_highlight.read_background": "#74ade81a", + "editor.document_highlight.write_background": "#555a6366", + "editor.foreground": "#acb2beff", + "editor.gutter.background": "#282c33ff", + "editor.highlighted_line.background": "#2f343eff", + "editor.hover_line_number": "#acb0b4", + "editor.invisible": "#878a98ff", + "editor.line_number": "#4e5a5f", + "editor.subheader.background": "#2f343eff", + "editor.wrap_guide": "#c8ccd40d", + "element.active": "#454a56ff", + "element.background": "#2e343eff", + "element.disabled": "#2e343eff", + "element.hover": "#363c46ff", + "element.selected": "#454a56ff", + "elevated_surface.background": "#2f343eff", + "error": "#d07277ff", + "error.background": "#d072771a", + "error.border": "#4c2b2cff", + "ghost_element.active": "#454a56ff", + "ghost_element.background": "#00000000", + "ghost_element.disabled": "#2e343eff", + "ghost_element.hover": "#363c46ff", + "ghost_element.selected": "#454a56ff", + "hidden": "#878a98ff", + "hidden.background": "#696b771a", + "hidden.border": "#414754ff", + "hint": "#788ca6ff", + "hint.background": "#5a6f891a", + "hint.border": "#293b5bff", + "icon": "#dce0e5ff", + "icon.accent": "#74ade8ff", + "icon.disabled": "#878a98ff", + "icon.muted": "#a9afbcff", + "icon.placeholder": "#a9afbcff", + "ignored": "#878a98ff", + "ignored.background": "#696b771a", + "ignored.border": "#464b57ff", + "info": "#74ade8ff", + "info.background": "#74ade81a", + "info.border": "#293b5bff", + "link_text.hover": "#74ade8ff", + "modified": "#dec184ff", + "modified.background": "#dec1841a", + "modified.border": "#5d4c2fff", + "pane.focused_border": null, + "panel.background": "#2f343eff", + "panel.focused_border": null, + "players": [ + { + "background": "#74ade8ff", + "cursor": "#74ade8ff", + "selection": "#74ade83d" + }, + { + "background": "#be5046ff", + "cursor": "#be5046ff", + "selection": "#be50463d" + }, + { + "background": "#bf956aff", + "cursor": "#bf956aff", + "selection": "#bf956a3d" + }, + { + "background": "#b477cfff", + "cursor": "#b477cfff", + "selection": "#b477cf3d" + }, + { + "background": "#6eb4bfff", + "cursor": "#6eb4bfff", + "selection": "#6eb4bf3d" + }, + { + "background": "#d07277ff", + "cursor": "#d07277ff", + "selection": "#d072773d" + }, + { + "background": "#dec184ff", + "cursor": "#dec184ff", + "selection": "#dec1843d" + }, + { + "background": "#a1c181ff", + "cursor": "#a1c181ff", + "selection": "#a1c1813d" + } + ], + "predictive": "#5a6a87ff", + "predictive.background": "#5a6a871a", + "predictive.border": "#38482fff", + "renamed": "#74ade8ff", + "renamed.background": "#74ade81a", + "renamed.border": "#293b5bff", + "scrollbar.thumb.background": "#c8ccd44c", + "scrollbar.thumb.border": "#363c46ff", + "scrollbar.thumb.hover_background": "#363c46ff", + "scrollbar.track.background": "#00000000", + "scrollbar.track.border": "#2e333cff", + "search.match_background": "#74ade866", + "status_bar.background": "#3b414dff", + "success": "#a1c181ff", + "success.background": "#a1c1811a", + "success.border": "#38482fff", + "surface.background": "#2f343eff", + "syntax": { + "attribute": { + "color": "#74ade8ff", + "font_style": null, + "font_weight": null + }, + "boolean": { + "color": "#bf956aff", + "font_style": null, + "font_weight": null + }, + "comment": { + "color": "#5d636fff", + "font_style": null, + "font_weight": null + }, + "comment.doc": { + "color": "#878e98ff", + "font_style": null, + "font_weight": null + }, + "constant": { + "color": "#dfc184ff", + "font_style": null, + "font_weight": null + }, + "constructor": { + "color": "#73ade9ff", + "font_style": null, + "font_weight": null + }, + "embedded": { + "color": "#dce0e5ff", + "font_style": null, + "font_weight": null + }, + "emphasis": { + "color": "#74ade8ff", + "font_style": null, + "font_weight": null + }, + "emphasis.strong": { + "color": "#bf956aff", + "font_style": null, + "font_weight": 700 + }, + "enum": { + "color": "#d07277ff", + "font_style": null, + "font_weight": null + }, + "function": { + "color": "#73ade9ff", + "font_style": null, + "font_weight": null + }, + "hint": { + "color": "#788ca6ff", + "font_style": null, + "font_weight": 700 + }, + "keyword": { + "color": "#b477cfff", + "font_style": null, + "font_weight": null + }, + "label": { + "color": "#74ade8ff", + "font_style": null, + "font_weight": null + }, + "link_text": { + "color": "#73ade9ff", + "font_style": "normal", + "font_weight": null + }, + "link_uri": { + "color": "#6eb4bfff", + "font_style": null, + "font_weight": null + }, + "number": { + "color": "#bf956aff", + "font_style": null, + "font_weight": null + }, + "operator": { + "color": "#6eb4bfff", + "font_style": null, + "font_weight": null + }, + "predictive": { + "color": "#5a6a87ff", + "font_style": "italic", + "font_weight": null + }, + "preproc": { + "color": "#dce0e5ff", + "font_style": null, + "font_weight": null + }, + "primary": { + "color": "#acb2beff", + "font_style": null, + "font_weight": null + }, + "property": { + "color": "#d07277ff", + "font_style": null, + "font_weight": null + }, + "punctuation": { + "color": "#acb2beff", + "font_style": null, + "font_weight": null + }, + "punctuation.bracket": { + "color": "#b2b9c6ff", + "font_style": null, + "font_weight": null + }, + "punctuation.delimiter": { + "color": "#b2b9c6ff", + "font_style": null, + "font_weight": null + }, + "punctuation.list_marker": { + "color": "#d07277ff", + "font_style": null, + "font_weight": null + }, + "punctuation.special": { + "color": "#b1574bff", + "font_style": null, + "font_weight": null + }, + "string": { + "color": "#a1c181ff", + "font_style": null, + "font_weight": null + }, + "string.escape": { + "color": "#878e98ff", + "font_style": null, + "font_weight": null + }, + "string.regex": { + "color": "#bf956aff", + "font_style": null, + "font_weight": null + }, + "string.special": { + "color": "#bf956aff", + "font_style": null, + "font_weight": null + }, + "string.special.symbol": { + "color": "#bf956aff", + "font_style": null, + "font_weight": null + }, + "tag": { + "color": "#74ade8ff", + "font_style": null, + "font_weight": null + }, + "text.literal": { + "color": "#a1c181ff", + "font_style": null, + "font_weight": null + }, + "title": { + "color": "#d07277ff", + "font_style": null, + "font_weight": 400 + }, + "type": { + "color": "#6eb4bfff", + "font_style": null, + "font_weight": null + }, + "variable": { + "color": "#acb2beff", + "font_style": null, + "font_weight": null + }, + "variable.special": { + "color": "#bf956aff", + "font_style": null, + "font_weight": null + }, + "variant": { + "color": "#73ade9ff", + "font_style": null, + "font_weight": null + } + }, + "tab.active_background": "#282c33ff", + "tab.inactive_background": "#2f343eff", + "tab_bar.background": "#2f343eff", + "terminal.ansi.black": "#282c33ff", + "terminal.ansi.blue": "#74ade8ff", + "terminal.ansi.bright_black": "#525561ff", + "terminal.ansi.bright_blue": "#385378ff", + "terminal.ansi.bright_cyan": "#3a565bff", + "terminal.ansi.bright_green": "#4d6140ff", + "terminal.ansi.bright_magenta": "#5e2b26ff", + "terminal.ansi.bright_red": "#673a3cff", + "terminal.ansi.bright_white": "#dce0e5ff", + "terminal.ansi.bright_yellow": "#e5c07bff", + "terminal.ansi.cyan": "#6eb4bfff", + "terminal.ansi.dim_black": "#dce0e5ff", + "terminal.ansi.dim_blue": "#bed5f4ff", + "terminal.ansi.dim_cyan": "#b9d9dfff", + "terminal.ansi.dim_green": "#d1e0bfff", + "terminal.ansi.dim_magenta": "#e6a79eff", + "terminal.ansi.dim_red": "#eab7b9ff", + "terminal.ansi.dim_white": "#575d65ff", + "terminal.ansi.dim_yellow": "#f1dfc1ff", + "terminal.ansi.green": "#a1c181ff", + "terminal.ansi.magenta": "#be5046ff", + "terminal.ansi.red": "#d07277ff", + "terminal.ansi.white": "#dce0e5ff", + "terminal.ansi.yellow": "#dec184ff", + "terminal.background": "#282c33ff", + "terminal.bright_foreground": "#dce0e5ff", + "terminal.dim_foreground": "#282c33ff", + "terminal.foreground": "#dce0e5ff", + "text": "#dce0e5ff", + "text.accent": "#74ade8ff", + "text.disabled": "#878a98ff", + "text.muted": "#a9afbcff", + "text.placeholder": "#878a98ff", + "title_bar.background": "#3b414dff", + "title_bar.inactive_background": "#2e343eff", + "toolbar.background": "#282c33ff", + "unreachable": "#a9afbcff", + "unreachable.background": "#8389941a", + "unreachable.border": "#464b57ff", + "version_control.added": "#27a657ff", + "version_control.deleted": "#e06c76ff", + "version_control.modified": "#d3b020ff", + "warning": "#dec184ff", + "warning.background": "#dec1841a", + "warning.border": "#5d4c2fff" + } + }, + { + "appearance": "light", + "name": "One Light", + "style": { + "background": "#dcdcddff", + "border": "#c9c9caff", + "border.disabled": "#d3d3d4ff", + "border.focused": "#7d82e8ff", + "border.selected": "#cbcdf6ff", + "border.transparent": "#00000000", + "border.variant": "#dfdfe0ff", + "conflict": "#a48819ff", + "conflict.background": "#faf2e6ff", + "conflict.border": "#f4e7d1ff", + "created": "#669f59ff", + "created.background": "#dfeadbff", + "created.border": "#c8dcc1ff", + "deleted": "#d36151ff", + "deleted.background": "#fbdfd9ff", + "deleted.border": "#f6c6bdff", + "drop_target.background": "#7e808780", + "editor.active_line.background": "#ebebecbf", + "editor.active_line_number": "#44454b", + "editor.active_wrap_guide": "#383a411a", + "editor.background": "#fafafaff", + "editor.document_highlight.read_background": "#5c78e225", + "editor.document_highlight.write_background": "#a3a3a466", + "editor.foreground": "#242529ff", + "editor.gutter.background": "#fafafaff", + "editor.highlighted_line.background": "#ebebecff", + "editor.hover_line_number": "#61616b", + "editor.invisible": "#a3a3a4ff", + "editor.line_number": "#b4b4bb", + "editor.subheader.background": "#ebebecff", + "editor.wrap_guide": "#383a410d", + "element.active": "#cacacaff", + "element.background": "#ebebecff", + "element.disabled": "#ebebecff", + "element.hover": "#dfdfe0ff", + "element.selected": "#cacacaff", + "elevated_surface.background": "#ebebecff", + "error": "#d36151ff", + "error.background": "#fbdfd9ff", + "error.border": "#f6c6bdff", + "ghost_element.active": "#cacacaff", + "ghost_element.background": "#00000000", + "ghost_element.disabled": "#ebebecff", + "ghost_element.hover": "#dfdfe0ff", + "ghost_element.selected": "#cacacaff", + "hidden": "#7e8086ff", + "hidden.background": "#dcdcddff", + "hidden.border": "#d3d3d4ff", + "hint": "#7274a7ff", + "hint.background": "#e2e2faff", + "hint.border": "#cbcdf6ff", + "icon": "#242529ff", + "icon.accent": "#5c78e2ff", + "icon.disabled": "#7e8086ff", + "icon.muted": "#58585aff", + "icon.placeholder": "#58585aff", + "ignored": "#7e8086ff", + "ignored.background": "#dcdcddff", + "ignored.border": "#c9c9caff", + "info": "#5c78e2ff", + "info.background": "#e2e2faff", + "info.border": "#cbcdf6ff", + "link_text.hover": "#5c78e2ff", + "modified": "#a48819ff", + "modified.background": "#faf2e6ff", + "modified.border": "#f4e7d1ff", + "pane.focused_border": null, + "panel.background": "#ebebecff", + "panel.focused_border": null, + "players": [ + { + "background": "#5c78e2ff", + "cursor": "#5c78e2ff", + "selection": "#5c78e23d" + }, + { + "background": "#984ea5ff", + "cursor": "#984ea5ff", + "selection": "#984ea53d" + }, + { + "background": "#ad6e26ff", + "cursor": "#ad6e26ff", + "selection": "#ad6e263d" + }, + { + "background": "#a349abff", + "cursor": "#a349abff", + "selection": "#a349ab3d" + }, + { + "background": "#3a82b7ff", + "cursor": "#3a82b7ff", + "selection": "#3a82b73d" + }, + { + "background": "#d36151ff", + "cursor": "#d36151ff", + "selection": "#d361513d" + }, + { + "background": "#dec184ff", + "cursor": "#a48819ff", + "selection": "#dec1843d" + }, + { + "background": "#669f59ff", + "cursor": "#669f59ff", + "selection": "#669f593d" + } + ], + "predictive": "#9b9ec6ff", + "predictive.background": "#dfeadbff", + "predictive.border": "#c8dcc1ff", + "renamed": "#5c78e2ff", + "renamed.background": "#e2e2faff", + "renamed.border": "#cbcdf6ff", + "scrollbar.thumb.background": "#383a414c", + "scrollbar.thumb.border": "#dfdfe0ff", + "scrollbar.thumb.hover_background": "#dfdfe0ff", + "scrollbar.track.background": "#00000000", + "scrollbar.track.border": "#eeeeeeff", + "search.match_background": "#5c79e266", + "status_bar.background": "#dcdcddff", + "success": "#669f59ff", + "success.background": "#dfeadbff", + "success.border": "#c8dcc1ff", + "surface.background": "#ebebecff", + "syntax": { + "attribute": { + "color": "#5c78e2ff", + "font_style": null, + "font_weight": null + }, + "boolean": { + "color": "#ad6e25ff", + "font_style": null, + "font_weight": null + }, + "comment": { + "color": "#a2a3a7ff", + "font_style": null, + "font_weight": null + }, + "comment.doc": { + "color": "#7c7e86ff", + "font_style": null, + "font_weight": null + }, + "constant": { + "color": "#669f59ff", + "font_style": null, + "font_weight": null + }, + "constructor": { + "color": "#5c78e2ff", + "font_style": null, + "font_weight": null + }, + "embedded": { + "color": "#242529ff", + "font_style": null, + "font_weight": null + }, + "emphasis": { + "color": "#5c78e2ff", + "font_style": null, + "font_weight": null + }, + "emphasis.strong": { + "color": "#ad6e25ff", + "font_style": null, + "font_weight": 700 + }, + "enum": { + "color": "#d3604fff", + "font_style": null, + "font_weight": null + }, + "function": { + "color": "#5b79e3ff", + "font_style": null, + "font_weight": null + }, + "hint": { + "color": "#7274a7ff", + "font_style": null, + "font_weight": 700 + }, + "keyword": { + "color": "#a449abff", + "font_style": null, + "font_weight": null + }, + "label": { + "color": "#5c78e2ff", + "font_style": null, + "font_weight": null + }, + "link_text": { + "color": "#5b79e3ff", + "font_style": "italic", + "font_weight": null + }, + "link_uri": { + "color": "#3882b7ff", + "font_style": null, + "font_weight": null + }, + "number": { + "color": "#ad6e25ff", + "font_style": null, + "font_weight": null + }, + "operator": { + "color": "#3882b7ff", + "font_style": null, + "font_weight": null + }, + "predictive": { + "color": "#9b9ec6ff", + "font_style": "italic", + "font_weight": null + }, + "preproc": { + "color": "#242529ff", + "font_style": null, + "font_weight": null + }, + "primary": { + "color": "#242529ff", + "font_style": null, + "font_weight": null + }, + "property": { + "color": "#d3604fff", + "font_style": null, + "font_weight": null + }, + "punctuation": { + "color": "#242529ff", + "font_style": null, + "font_weight": null + }, + "punctuation.bracket": { + "color": "#4d4f52ff", + "font_style": null, + "font_weight": null + }, + "punctuation.delimiter": { + "color": "#4d4f52ff", + "font_style": null, + "font_weight": null + }, + "punctuation.list_marker": { + "color": "#d3604fff", + "font_style": null, + "font_weight": null + }, + "punctuation.special": { + "color": "#b92b46ff", + "font_style": null, + "font_weight": null + }, + "string": { + "color": "#649f57ff", + "font_style": null, + "font_weight": null + }, + "string.escape": { + "color": "#7c7e86ff", + "font_style": null, + "font_weight": null + }, + "string.regex": { + "color": "#ad6e26ff", + "font_style": null, + "font_weight": null + }, + "string.special": { + "color": "#ad6e26ff", + "font_style": null, + "font_weight": null + }, + "string.special.symbol": { + "color": "#ad6e26ff", + "font_style": null, + "font_weight": null + }, + "tag": { + "color": "#5c78e2ff", + "font_style": null, + "font_weight": null + }, + "text.literal": { + "color": "#649f57ff", + "font_style": null, + "font_weight": null + }, + "title": { + "color": "#d3604fff", + "font_style": null, + "font_weight": 400 + }, + "type": { + "color": "#3882b7ff", + "font_style": null, + "font_weight": null + }, + "variable": { + "color": "#242529ff", + "font_style": null, + "font_weight": null + }, + "variable.special": { + "color": "#ad6e25ff", + "font_style": null, + "font_weight": null + }, + "variant": { + "color": "#5b79e3ff", + "font_style": null, + "font_weight": null + } + }, + "tab.active_background": "#fafafaff", + "tab.inactive_background": "#ebebecff", + "tab_bar.background": "#ebebecff", + "terminal.ansi.black": "#fafafaff", + "terminal.ansi.blue": "#5c78e2ff", + "terminal.ansi.bright_black": "#aaaaaaff", + "terminal.ansi.bright_blue": "#b5baf2ff", + "terminal.ansi.bright_cyan": "#a3bedaff", + "terminal.ansi.bright_green": "#b2cfa9ff", + "terminal.ansi.bright_magenta": "#cea6d3ff", + "terminal.ansi.bright_red": "#f0b0a4ff", + "terminal.ansi.bright_white": "#242529ff", + "terminal.ansi.bright_yellow": "#826221ff", + "terminal.ansi.cyan": "#3a82b7ff", + "terminal.ansi.dim_black": "#242529ff", + "terminal.ansi.dim_blue": "#2d3d75ff", + "terminal.ansi.dim_cyan": "#254058ff", + "terminal.ansi.dim_green": "#354d2eff", + "terminal.ansi.dim_magenta": "#4b2a50ff", + "terminal.ansi.dim_red": "#6f312aff", + "terminal.ansi.dim_white": "#97979aff", + "terminal.ansi.dim_yellow": "#786441ff", + "terminal.ansi.green": "#669f59ff", + "terminal.ansi.magenta": "#984ea5ff", + "terminal.ansi.red": "#d36151ff", + "terminal.ansi.white": "#242529ff", + "terminal.ansi.yellow": "#dec184ff", + "terminal.background": "#fafafaff", + "terminal.bright_foreground": "#242529ff", + "terminal.dim_foreground": "#fafafaff", + "terminal.foreground": "#242529ff", + "text": "#242529ff", + "text.accent": "#5c78e2ff", + "text.disabled": "#7e8086ff", + "text.muted": "#58585aff", + "text.placeholder": "#7e8086ff", + "title_bar.background": "#dcdcddff", + "title_bar.inactive_background": "#ebebecff", + "toolbar.background": "#fafafaff", + "unreachable": "#58585aff", + "unreachable.background": "#dcdcddff", + "unreachable.border": "#c9c9caff", + "version_control.added": "#27a657ff", + "version_control.deleted": "#e06c76ff", + "version_control.modified": "#d3b020ff", + "warning": "#a48819ff", + "warning.background": "#faf2e6ff", + "warning.border": "#f4e7d1ff" + } + } + ] +}