Skip to content

Commit

Permalink
chore: rename utils files
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinSilvester committed Dec 25, 2024
1 parent 919ffc2 commit 9088ade
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 48 deletions.
51 changes: 26 additions & 25 deletions colors/custom.lua
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
-- A slightly altered version of catppucchin mocha
-- stylua: ignore
local mocha = {
rosewater = '#f5e0dc',
flamingo = '#f2cdcd',
pink = '#f5c2e7',
mauve = '#cba6f7',
red = '#f38ba8',
maroon = '#eba0ac',
peach = '#fab387',
yellow = '#f9e2af',
green = '#a6e3a1',
teal = '#94e2d5',
sky = '#89dceb',
sapphire = '#74c7ec',
blue = '#89b4fa',
lavender = '#b4befe',
text = '#cdd6f4',
subtext1 = '#bac2de',
subtext0 = '#a6adc8',
overlay2 = '#9399b2',
overlay1 = '#7f849c',
overlay0 = '#6c7086',
surface2 = '#585b70',
surface1 = '#45475a',
surface0 = '#313244',
base = '#1f1f28',
mantle = '#181825',
crust = '#11111b',
flamingo = '#f2cdcd',
pink = '#f5c2e7',
mauve = '#cba6f7',
red = '#f38ba8',
maroon = '#eba0ac',
peach = '#fab387',
yellow = '#f9e2af',
green = '#a6e3a1',
teal = '#94e2d5',
sky = '#89dceb',
sapphire = '#74c7ec',
blue = '#89b4fa',
lavender = '#b4befe',
text = '#cdd6f4',
subtext1 = '#bac2de',
subtext0 = '#a6adc8',
overlay2 = '#9399b2',
overlay1 = '#7f849c',
overlay0 = '#6c7086',
surface2 = '#585b70',
surface1 = '#45475a',
surface0 = '#313244',
base = '#1f1f28',
mantle = '#181825',
crust = '#11111b',
}

local colorscheme = {
Expand Down
2 changes: 1 addition & 1 deletion config/appearance.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local gpu_adapters = require('utils.gpu_adapter')
local gpu_adapters = require('utils.gpu-adapter')
local backdrops = require('utils.backdrops')
local colors = require('colors.custom')

Expand Down
4 changes: 2 additions & 2 deletions events/right-status.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local wezterm = require('wezterm')
local umath = require('utils.math')
local Cells = require('utils.cells')
local EventOpts = require('utils.event_opts')
local OptsValidator = require('utils.opts-validator')

---@alias Event.RightStatusOptions { date_format?: string }

Expand All @@ -16,7 +16,7 @@ EVENT_OPTS.schema = {
default = '%a %H:%M:%S',
},
}
EVENT_OPTS.validator = EventOpts:new(EVENT_OPTS.schema)
EVENT_OPTS.validator = OptsValidator:new(EVENT_OPTS.schema)

local nf = wezterm.nerdfonts
local attr = Cells.attr
Expand Down
4 changes: 2 additions & 2 deletions events/tab-title.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

local wezterm = require('wezterm')
local Cells = require('utils.cells')
local EventOpts = require('utils.event_opts')
local OptsValidator = require('utils.opts-validator')

---
-- =======================================
Expand All @@ -30,7 +30,7 @@ EVENT_OPTS.schema = {
default = true,
},
}
EVENT_OPTS.validator = EventOpts:new(EVENT_OPTS.schema)
EVENT_OPTS.validator = OptsValidator:new(EVENT_OPTS.schema)

---
-- ===================
Expand Down
File renamed without changes.
25 changes: 7 additions & 18 deletions utils/event_opts.lua → utils/opts-validator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,38 +83,27 @@ local function validate_opts_schema(schema)
end

---Event options validation class
---@class EventOpts
---@class OptsValidator
---@field schema OptsSchema
local EventOpts = {}
EventOpts.__index = EventOpts
local OptsValidator = {}
OptsValidator.__index = OptsValidator

---Create a new instance of EventOpts
---Create a new instance of OptsValidator
---@param schema OptsSchema
function EventOpts:new(schema)
function OptsValidator:new(schema)
validate_opts_schema(schema)
local event_opts = { schema = schema }
return setmetatable(event_opts, self)
end

---Get the default values for the event options based on the schema
---@generic T
---@return T
function EventOpts:get_defaults()
local defaults = {}
for _, opt in ipairs(self.schema) do
defaults[opt.name] = opt.default
end
return defaults
end

---Validate the event options against the schema
---If the options are valid, it returns the options and nil
---If a field is invalid, it returns the default value and an error message
---@generic T
---@param opts T
---@return T
---@return string|nil
function EventOpts:validate(opts)
function OptsValidator:validate(opts)
local errors = {}
local valid_opts = {}

Expand Down Expand Up @@ -185,4 +174,4 @@ function EventOpts:validate(opts)
return valid_opts, nil
end

return EventOpts
return OptsValidator

0 comments on commit 9088ade

Please sign in to comment.