From 50b1e71be5ac05d03ad8dc1f776b747466b3d3cc Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 6 Jul 2021 16:40:18 +0200 Subject: [PATCH] feat: added .Xresources --- extras/xresources_tokyonight_day.Xresources | 23 +++++++++++ extras/xresources_tokyonight_night.Xresources | 23 +++++++++++ extras/xresources_tokyonight_storm.Xresources | 23 +++++++++++ lua/tokyonight/extra/init.lua | 33 +++++++++------- lua/tokyonight/extra/xresources.lua | 38 +++++++++++++++++++ 5 files changed, 127 insertions(+), 13 deletions(-) create mode 100644 extras/xresources_tokyonight_day.Xresources create mode 100644 extras/xresources_tokyonight_night.Xresources create mode 100644 extras/xresources_tokyonight_storm.Xresources create mode 100644 lua/tokyonight/extra/xresources.lua diff --git a/extras/xresources_tokyonight_day.Xresources b/extras/xresources_tokyonight_day.Xresources new file mode 100644 index 0000000..a3e15cd --- /dev/null +++ b/extras/xresources_tokyonight_day.Xresources @@ -0,0 +1,23 @@ +! TokyoNight colors for Xresources + +*background: #e1e2e7 +*foreground: #3760bf + +*color0: #e9e9ed +*color1: #f52a65 +*color2: #587539 +*color3: #8c6c3e +*color4: #2e7de9 +*color5: #9854f1 +*color6: #007197 +*color7: #6172b0 + +*color8: #a1a6c5 +*color9: #f52a65 +*color10: #587539 +*color11: #8c6c3e +*color12: #2e7de9 +*color13: #9854f1 +*color14: #007197 +*color15: #3760bf + diff --git a/extras/xresources_tokyonight_night.Xresources b/extras/xresources_tokyonight_night.Xresources new file mode 100644 index 0000000..e152e30 --- /dev/null +++ b/extras/xresources_tokyonight_night.Xresources @@ -0,0 +1,23 @@ +! TokyoNight colors for Xresources + +*background: #1a1b26 +*foreground: #c0caf5 + +*color0: #15161E +*color1: #f7768e +*color2: #9ece6a +*color3: #e0af68 +*color4: #7aa2f7 +*color5: #bb9af7 +*color6: #7dcfff +*color7: #a9b1d6 + +*color8: #414868 +*color9: #f7768e +*color10: #9ece6a +*color11: #e0af68 +*color12: #7aa2f7 +*color13: #bb9af7 +*color14: #7dcfff +*color15: #c0caf5 + diff --git a/extras/xresources_tokyonight_storm.Xresources b/extras/xresources_tokyonight_storm.Xresources new file mode 100644 index 0000000..d010423 --- /dev/null +++ b/extras/xresources_tokyonight_storm.Xresources @@ -0,0 +1,23 @@ +! TokyoNight colors for Xresources + +*background: #24283b +*foreground: #c0caf5 + +*color0: #1D202F +*color1: #f7768e +*color2: #9ece6a +*color3: #e0af68 +*color4: #7aa2f7 +*color5: #bb9af7 +*color6: #7dcfff +*color7: #a9b1d6 + +*color8: #414868 +*color9: #f7768e +*color10: #9ece6a +*color11: #e0af68 +*color12: #7aa2f7 +*color13: #bb9af7 +*color14: #7dcfff +*color15: #c0caf5 + diff --git a/lua/tokyonight/extra/init.lua b/lua/tokyonight/extra/init.lua index 6c83466..102ea15 100644 --- a/lua/tokyonight/extra/init.lua +++ b/lua/tokyonight/extra/init.lua @@ -3,23 +3,30 @@ package.path = "./lua/?/init.lua;./lua/?.lua" local config = require("tokyonight.config") local function write(str, fileName) - print("[write] extra/" .. fileName) - local file = io.open("extras/" .. fileName, "w") - file:write(str) - file:close() + print("[write] extra/" .. fileName) + local file = io.open("extras/" .. fileName, "w") + file:write(str) + file:close() end -- map of plugin name to plugin extension -local extras = { kitty = "conf", fish = "fish", alacritty = "yml", wezterm = "toml", tmux = "tmux" } +local extras = { + kitty = "conf", + fish = "fish", + alacritty = "yml", + wezterm = "toml", + tmux = "tmux", + xresources = "Xresources", +} local styles = { "storm", "night", "day" } for extra, ext in pairs(extras) do - local plugin = require("tokyonight.extra." .. extra) - for _, style in pairs(styles) do - config.style = style - config = config or require("tokyonight.config") - config.transform_colors = true - local colors = require("tokyonight.colors").setup(config) - write(plugin.generate(colors), extra .. "_tokyonight_" .. style .. "." .. ext) - end + local plugin = require("tokyonight.extra." .. extra) + for _, style in pairs(styles) do + config.style = style + config = config or require("tokyonight.config") + config.transform_colors = true + local colors = require("tokyonight.colors").setup(config) + write(plugin.generate(colors), extra .. "_tokyonight_" .. style .. "." .. ext) + end end diff --git a/lua/tokyonight/extra/xresources.lua b/lua/tokyonight/extra/xresources.lua new file mode 100644 index 0000000..bf51bda --- /dev/null +++ b/lua/tokyonight/extra/xresources.lua @@ -0,0 +1,38 @@ +local util = require("tokyonight.util") + +local M = {} + +--- @param colors ColorScheme +function M.generate(colors) + local xr = util.template( + [[ +! TokyoNight colors for Xresources + +*background: ${bg} +*foreground: ${fg} + +*color0: ${black} +*color1: ${red} +*color2: ${green} +*color3: ${yellow} +*color4: ${blue} +*color5: ${magenta} +*color6: ${cyan} +*color7: ${fg_dark} + +*color8: ${terminal_black} +*color9: ${red} +*color10: ${green} +*color11: ${yellow} +*color12: ${blue} +*color13: ${magenta} +*color14: ${cyan} +*color15: ${fg} + +]], + colors + ) + return xr +end + +return M