Skip to content

Commit

Permalink
refactor(extras-rio): Enhance Rio code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
byt3m4st3r committed Jul 31, 2024
1 parent 8e98903 commit bdccbd4
Showing 1 changed file with 48 additions and 60 deletions.
108 changes: 48 additions & 60 deletions lua/cyberdream/extra/rio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,68 @@ local util = require("cyberdream.util")

local M = {}

--- Generate cyberdream theme for https://zed.dev/
--- Generate cyberdream theme for https://raphamorim.io/rio/
--- @param variant string: Variation of the colorscheme to use.
function M.generate(variant)
function CreateDimColor(hex)
return util.blend(hex, colors[variant].bg, 0.8)
return util.blend(hex, variant == "default" and colors[variant].bg or colors[variant].fg, 0.8)
end

function CreateLightColor(hex)
return util.blend(hex, colors[variant].fg, 0.8)
return util.blend(hex, variant == "default" and colors[variant].fg or colors[variant].bg, 0.8)
end

local modified_colors = vim.fn.copy(colors[variant])
modified_colors.bgAltDim = CreateDimColor(colors[variant].bgAlt)
modified_colors.blueDim = CreateDimColor(colors[variant].blue)
modified_colors.cyanDim = CreateDimColor(colors[variant].cyan)
modified_colors.fgDim = CreateDimColor(colors[variant].fg)
modified_colors.greenDim = CreateDimColor(colors[variant].green)
modified_colors.magentaDim = CreateDimColor(colors[variant].magenta)
modified_colors.redDim = CreateDimColor(colors[variant].red)
modified_colors.yellowDim = CreateDimColor(colors[variant].yellow)
modified_colors.bgAltLight = CreateLightColor(colors[variant].bgAlt)
modified_colors.blueLight = CreateLightColor(colors[variant].blue)
modified_colors.cyanLight = CreateLightColor(colors[variant].cyan)
modified_colors.fgLight = CreateLightColor(colors[variant].fg)
modified_colors.greenLight = CreateLightColor(colors[variant].green)
modified_colors.magentaLight = CreateLightColor(colors[variant].magenta)
modified_colors.redLight = CreateLightColor(colors[variant].red)
modified_colors.yellowLight = CreateLightColor(colors[variant].yellow)
local extended_colors = vim.fn.copy(colors[variant])
for key, value in pairs(colors[variant]) do
extended_colors[key .. "Dim"] = CreateDimColor(value)
extended_colors[key .. "Light"] = CreateLightColor(value)
end

local template = [==[
[colors]
# Regular colors
background = '${bg}'
black = '${bgAlt}'
blue = '${blue}'
cursor = '${fg}'
cyan = '${cyan}'
foreground = '${fg}'
green = '${green}'
magenta = '${magenta}'
red = '${red}'
white = '${fg}'
yellow = '${yellow}'
[colors]
# Regular colors
background = '${bg}'
black = '${bgAlt}'
blue = '${blue}'
cursor = '${fg}'
cyan = '${cyan}'
foreground = '${fg}'
green = '${green}'
magenta = '${magenta}'
red = '${red}'
white = '${fg}'
yellow = '${yellow}'
# UI colors
tabs = '${bgHighlight}'
tabs-active = '${grey}'
selection-foreground = '${fg}'
selection-background = '${bgAlt}'
# UI colors
tabs = '${bgHighlight}'
tabs-active = '${grey}'
selection-foreground = '${fg}'
selection-background = '${bgAlt}'
# Dim colors
dim-black = '${bgAltDim}'
dim-blue = '${blueDim}'
dim-cyan = '${cyanDim}'
dim-foreground = '${fgDim}'
dim-green = '${greenDim}'
dim-magenta = '${magentaDim}'
dim-red = '${redDim}'
dim-white = '${fgDim}'
dim-yellow = '${yellowDim}'
# Dim colors
dim-black = '${bgAltDim}'
dim-blue = '${blueDim}'
dim-cyan = '${cyanDim}'
dim-foreground = '${fgDim}'
dim-green = '${greenDim}'
dim-magenta = '${magentaDim}'
dim-red = '${redDim}'
dim-white = '${fgDim}'
dim-yellow = '${yellowDim}'
# Light colors
light-black = '${bgAltLight}'
light-blue = '${blueLight}'
light-cyan = '${cyanLight}'
light-foreground = '${fgLight}'
light-green = '${greenLight}'
light-magenta = '${magentaLight}'
light-red = '${redLight}'
light-white = '${fgLight}'
light-yellow = '${yellowLight}'
]==]
# Light colors
light-black = '${bgAltLight}'
light-blue = '${blueLight}'
light-cyan = '${cyanLight}'
light-foreground = '${fgLight}'
light-green = '${greenLight}'
light-magenta = '${magentaLight}'
light-red = '${redLight}'
light-white = '${fgLight}'
light-yellow = '${yellowLight}'
]==]

return util.parse_extra_template(template, modified_colors)
return util.parse_extra_template(template, extended_colors)
end

return M

0 comments on commit bdccbd4

Please sign in to comment.